Grid
A CSS grid layout with a fixed column count and token gaps.
Examples
Default
1
2
3
4
5
6
export const Default: Story = {
render: (args) => (
<Grid {...args}>
<Box>1</Box>
<Box>2</Box>
<Box>3</Box>
<Box>4</Box>
<Box>5</Box>
<Box>6</Box>
</Grid>
),
};Two Columns
Left
Right
Left
Right
export const TwoColumns: Story = {
args: {
columns: 2,
style: { width: 400 },
},
render: (args) => (
<Grid {...args}>
<Box>Left</Box>
<Box>Right</Box>
<Box>Left</Box>
<Box>Right</Box>
</Grid>
),
};Four Columns
1
2
3
4
5
6
7
8
export const FourColumns: Story = {
args: {
columns: 4,
gap: 'sm',
},
render: (args) => (
<Grid {...args}>
<Box>1</Box>
<Box>2</Box>
<Box>3</Box>
<Box>4</Box>
<Box>5</Box>
<Box>6</Box>
<Box>7</Box>
<Box>8</Box>
</Grid>
),
};Twelve Column Grid
1
2
3
4
5
6
7
8
9
10
11
12
export const TwelveColumnGrid: Story = {
args: {
columns: 12,
gap: 'xs',
},
render: (args) => (
<Grid {...args}>
{Array.from({ length: 12 }, (_, i) => (
<Box key={i}>{i + 1}</Box>
))}
</Grid>
),
};With Rows
1
2
3
4
5
6
export const WithRows: Story = {
args: {
rows: 2,
style: { height: 200 },
},
render: (args) => (
<Grid {...args}>
<Box>1</Box>
<Box>2</Box>
<Box>3</Box>
<Box>4</Box>
<Box>5</Box>
<Box>6</Box>
</Grid>
),
};Separate Gaps
1
2
3
4
5
6
export const SeparateGaps: Story = {
args: {
gap: undefined,
columnGap: 'xl',
rowGap: 'xs',
},
render: (args) => (
<Grid {...args}>
<Box>1</Box>
<Box>2</Box>
<Box>3</Box>
<Box>4</Box>
<Box>5</Box>
<Box>6</Box>
</Grid>
),
};Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
columns | 1 | 2 | 3 | 4 | 5 | 6 | 12 | No | Number of grid columns. | |
rows | number | No | Number of equal-height grid rows ( | |
gap | 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | No | Uniform gap size between grid items. | |
columnGap | 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | No | Horizontal gap size between grid columns. | |
rowGap | 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | No | Vertical gap size between grid rows. | |
align | 'start' | 'center' | 'end' | 'stretch' | No | Vertical alignment of items within the grid. | |
justify | 'start' | 'center' | 'end' | 'stretch' | No | Horizontal alignment of items within the grid. | |
as | React.ElementType | No | 'div' | Render as a different element or component (its props are type-checked). |
Any other prop is passed to the element it renders (HTMLDivElement).
Stable class names
| Part | Class |
|---|---|
root | wave-grid |