Backpack UI
Components
Grid

Grid

The Grid component creates a responsive, flexible grid layout. You can use it to create layouts with different column configurations depending on the screen size.

Import


_10
import { Grid, Item } from '@ef-global/backpack/Grid';

Usage


_10
<Grid>
_10
<Item>Content</Item>
_10
<Item>Content</Item>
_10
</Grid>

Examples

Default

Item bounds-start
Item offset-start
Item col-1
Item col-2
Item col-3
Item col-4
Item col-5
Item col-6
Item col-7
Item col-8
Item col-9
Item col-10
Item col-11
Item col-12
Item offset-end
Item bounds-end

_24
const BreakpointViewer = () => {
_24
const { breakpoint } = useBreakpoint();
_24
return <span className='grid-bp'>{breakpoint}</span>;
_24
};
_24
_24
const configCols = {
_24
//...
_24
};
_24
_24
const GridExample = () => {
_24
return (
_24
<Grid>
_24
{Object.keys(configCols).map((v, i) => {
_24
return (
_24
<Item key={i} column={{ s: configCols[v] }} className={'grid-demo'}>
_24
<div className={'docs-grid-item'}>Item {v}</div>
_24
</Item>
_24
);
_24
})}
_24
</Grid>
_24
);
_24
};
_24
_24
<GridExample />

Columns

boundsboundsbounds

_21
const ColumnsExample = () => (
_21
<Grid className='u-mt-xxl'>
_21
<Item
_21
column={{
_21
s: ['bounds-start', 'bounds-end'],
_21
m: ['col-1-start', 'col-6-end'],
_21
}}
_21
>
_21
<div className='grid-demo-lines'>
_21
<span className='grid-label md:u-hidden'>bounds</span>
_21
<span className='grid-label u-hidden md:u-inline-block lg:u-hidden'>
_21
bounds
_21
</span>
_21
<span className='grid-label u-hidden lg:u-inline-block'>bounds</span>
_21
</div>
_21
</Item>
_21
//...
_21
</Grid>
_21
);
_21
_21
<ColumnsExample />