This is a simple flexbox implementation with a few props modifiers.
gutter
: Add gutter between your items - default totrue
align
: The horizontal alignment - as default it will beleft
aligned- values:
left
,center
,right
- values:
valign
: The vertical alignment - as default it will bestretch
- values:
top
,middle
,bottom
,stretch
- values:
className
: Custom class name
<Relayout align="left" valign="bottom" gutter={false}>
...
</Relayout>
This is when things starts to get a bit more interesting. You can set a custom number of columns for any breakpoint you need.
You have a total number of 12 columns (where 12 == 100%
and 1 == 8.33%
).
Since we don't have a concept of row, you can add as many <RelayoutItem>
's as you want.
You can also use 0
if you want to hide the column completely - this will set the element to have a display: none;
.
The value for all the props bellow is a number ranging between 0
and 12
.
sm
: Small and up (every screen size)md
: Medium and uplg
: Large and upxl
: Extra largerelative
: If you want your item to have a position relative - important if you have children with absolute positionclassName
: Custom class name
<RelayoutItem sm="12" lg="4">
<p>12 columns on mobile and medium</p>
<p>4 columns on large and extra-large</p>
</RelayoutItem>
<RelayoutItem sm="4" md="0" lg="8" xl="12">
<p>4 columns on mobile</p>
<p>hidden on medium screens only</p>
<p>8 columns on large</p>
<p>12 columns on extra-large</p>
</RelayoutItem>
<RelayoutItem sm="0" lg="8" xl="12">
<p>hidden on mobile and medium screen</p>
<p>8 columns on large</p>
<p>12 columns on extra-large</p>
</RelayoutItem>
<RelayoutItem sm="0" xl="5">
<p>hidden on mobile, medium screen and large screen</p>
<p>5 columns on extra-large</p>
</RelayoutItem>
The wrapper will set a container with a max-width
on different breakpoints - it also includes some left/right padding.
It should never be used inside other wrappers (elements with max-width) or <RelayoutItem>
's - it's mainly used as a "root" element.
By default, the wrapper will set a max-width
from the small screens and up, so in every breakpoint you will have a max-width and padding.
But you can change this behaviour and wrap only from a specific breakpoint and up by using the from
prop, which defaults to sm
.
from
: Include a max-width and padding from this specific breakpoint up.- values:
sm
,md
,lg
,xl
- values:
className
: Custom class name
<RelayoutWrapper>
<p>I have max-width and padding on all breakpoints!</p>
</RelayoutWrapper>
<RelayoutWrapper from="lg">
<p>I have max-width only from the "large" breakpoint and up!</p>
<p>On small and medium screens I'm 100% width and without padding.</p>
</RelayoutWrapper>