XS
SM
MD
LG
XL

@ecodev/natural-layout

View on GitHub

Getting started

Available breakpoints prefixes : xs, sm, md, lg, xl.

Usage : class="nat[-breakpoint]-class[-size]"

Examples :

Greater than medium (included) change layout to horizontal

class="nat-vertical nat-md-horizontal" 

Greater than medium (included) increase gap

class="nat-gap nat-md-gap-30" 

SCSS usage : media query

$breakpoints: (
    sm: 600px,
    md: 960px,
    lg: 1280px,
    xl: 1920px,
)
@use '@ecodev/natural-layout' as nat;

#id {
    // greater than SM
    @include nat.media(sm) { ... }

    // lesser than MD (excluded)
    @include nat.media(null, md) { ... }

    // from SM (included) to LG (exluded)
    @include nat.media(sm, lg) { ... }

    // from 1000px to 2000px, accepts null values too
    @include nat.media(1000px, 2000px) { ... }
}
XS
SM
MD
LG
XL
SM to LG
2000px to 2200

Unresponsive html markup

nat-padding

Padding on all sides / top and down / left and right :

nat-padding
nat-padding-vertical
nat-padding-horizontal

nat-margin

Margin on all sides / top and bottom / left and right :

nat-margin
nat-margin-vertical
nat-margin-horizontal

Alignments

Alignments nat-bottom, nat-top, nat-left, nat-right can be combined.

Align bottom right

nat-horizontal nat-bottom nat-right
xxx
xxx
xxx
xxx

Distribute uses space-around

nat-distribute
xxx
xxxxxxx
xxxxxxx
xxx

nat-center

nat-center is magic. If used alone it centers both axis. If used with another axis, centers on the complementary axis.

Horizontal center

nat-horizontal nat-center
xxx
xxxxxxx
xxxxxxx
xxx

Vertical center

nat-vertical nat-center
xxx
xxxxxxx
xxxxxxx
xxx

Horizontal top centered

nat-horizontal nat-center nat-top
xxx
xxxxxxx
xxxxxxx
xxx

Horizontal right centered

nat-horizontal nat-center nat-right
xxx
xxxxxxx
xxxxxxx
xxx

Vertical top centered

nat-vertical nat-center nat-top
xxx
xxxxxxx
xxxxxxx
xxx

Vertical right centered

nat-vertical nat-center nat-right
xxx
xxxxxxx
xxxxxxx
xxx

Responsive HTML markup

nat-hide

Usage : nat-hide / nat-sm-hide / nat-show / nat-sm-show

Breakpoints are only the start of size. To focus a single size, combine multiple classes


Show badges that match the current breakpoint range

Hide badges that don't match the current breakpoint range

XS only
SM only
MD only
LG only
XL only
XS
SM
MD
LG
XL

Show badges fitting in the current breakpoint range (show smaller ones).

Hide badges that don't fit in the current breakpoint range.

XS
SM
MD
LG
XL
SM
MD
LG
XL

nat-gap

Must be combined with nat-horizontal or nat-vertical.

Sizes : 0, 5, 10, 15, 20, 30

Example where gap increases with screen size :

nat-horizontal nat-gap-0 nat-sm-gap-5 nat-md-gap-10 nat-lg-gap-15 nat-xl-gap-20
xxx
xxx
xxx
xxx
xxx

Orientation specific and responsive gap :

Different responsive gap in specific orientation (small screen = bigger vertical gap, big screen = bigger horizontal gap). Usefull for form fields layouts.

nat-gap-vertical-30 nat-gap-horizontal-5 nat-md-gap-horizontal-30 nat-md-gap-vertical-5
xxx
xxx
xxx
xxx
xxx
xxx
xxx
xxx

Gap takes priority on margin in same axis to prevent addition.

nat-margin-bottom
nat-margin-bottom
nat-margin-bottom
nat-margin-bottom

nat-horizontal

nat-horizontal
111
222
333
444
555
666
777
888
999

Wrap

nat-horizontal nat-wrap
111
222
333
444
555
666
777
888
999
nat-horizontal nat-wrap-reverse
111
222
333
444
555
666
777
888
999

nat-vertical

nat-vertical
xxx
xxx
xxx

Align bottom right

nat-vertical nat-bottom nat-right
xxx
xxx
xxx

Change orientation, starting mobile first vertically, then horizontal since medium :

nat-vertical nat-md-horizontal
xxx
xxx
xxx

nat-expand

Apply on nat-horizontal or nat-vertical children.

Available sizes : 25, 33, 50, 66, 75.

xxx
nat-expand
xxx

Proportions change when greater than medium (included) :

nat-expand-33 nat-md-expand-66
nat-expand-66 nat-md-expand-33
nat-expand-66
nat-expand
nat-expand-66
nat-expand-33
nat-expand
nat-expand-33