@k8ordo/ui

Grid

Lays children out on a CSS grid, with a fixed column count or auto-fill / auto-fit.

Import

ts
import { Grid } from '@k8ordo/ui';

Usage

A
B
C
D
E
F
tsx
<Grid cols={3} gap="md">
  {items.map((label) => <Card>{label}</Card>)}
</Grid>

Fixed columns

A
B
C
D
E
F
G
H
A
B
C
D
E
F
G
H
tsx
<Grid cols={2} gap="sm">…</Grid>
<Grid cols={4} gap="sm">…</Grid>

Auto-fill

With cols="auto-fill" or "auto-fit", minItemSize sets the minimum width of a cell. The number of columns then follows the width.

A
B
C
D
E
F
G
H
tsx
<Grid cols="auto-fill" minItemSize={32} gap="md">…</Grid>

Props

children?
Type: ReactNode
Default: -
cols?
Type: 1|2|3|4|5|6|'auto-fill'|'auto-fit'
Default: 'auto-fill'
gap?
Type: GapSize
Default: 'md'
minItemSize?
Type: 24|32|40|48|64|80
Default: 48
PropTypeDefault
children?ReactNode-
cols?1|2|3|4|5|6|'auto-fill'|'auto-fit''auto-fill'
gap?GapSize'md'
minItemSize?24|32|40|48|64|8048

Inherited attributes (except the ones set internally): HTMLAttributes<HTMLDivElement>

k8ordo

React libraries that use Baseline features without holding back.