Auto-fit columns
import { Text } from "@senvenli/react/display";
import { Box, Grid, Stack } from "@senvenli/react/layout";
const PROJECTS = [
{ name: "Website redesign", tasks: "12 open tasks" },
{ name: "Mobile app", tasks: "8 open tasks" },
{ name: "Billing migration", tasks: "3 open tasks" },
{ name: "Help center", tasks: "5 open tasks" },
];
export default function Example() {
return (
<Grid minColumnWidth={180} space="space-200">
{PROJECTS.map((project) => (
<Box key={project.name} padding="space-200" radius="large" border>
<Stack space="space-050">
<Text weight="medium">{project.name}</Text>
<Text size="body-small" tone="subtle">{project.tasks}</Text>
</Stack>
</Box>
))}
</Grid>
);
}import { Grid } from "@senvenli/react/layout";Examples
Fixed columns
A set number of equal columns at every width.import { Text } from "@senvenli/react/display";
import { Box, Grid, Stack } from "@senvenli/react/layout";
const TOTALS = [
{ label: "Orders", value: "1,284" },
{ label: "Customers", value: "312" },
{ label: "Refunds", value: "9" },
];
export default function Example() {
return (
<Grid columns={3} space="space-150">
{TOTALS.map((total) => (
<Box key={total.label} padding="space-200" background="surface-sunken" radius="large">
<Stack space="space-050">
<Text size="body-small" tone="subtle">{total.label}</Text>
<Text size="body-large" weight="medium" isNumeric>{total.value}</Text>
</Stack>
</Box>
))}
</Grid>
);
}Guidelines
When to use it
- Tiles or cards in columns.
Accessibility
Built in
- Layout only; no role.
API reference
Grid
| Prop | Type | Default | Description |
|---|---|---|---|
padding | Space | – | |
paddingInline | Space | – | |
paddingBlock | Space | – | |
background | Background | – | |
radius | Radius | – | |
shadow | Shadow | – | |
border | Border | – | |
as | LayoutElement | "div" | |
space | Space | – | |
columns | 1 | 4 | 2 | 3 | 5 | 6 | – | |
minColumnWidth | number | – | Auto-fit columns no narrower than this many pixels (never wider than the grid itself), as many as fit. The one length a layout prop takes. |
paddingSpacepaddingInlineSpacepaddingBlockSpacebackgroundBackgroundradiusRadiusshadowShadowborderBorderasLayoutElementDefault"div"spaceSpacecolumns1 | 4 | 2 | 3 | 5 | 6minColumnWidthnumberAuto-fit columns no narrower than this many pixels (never wider than the grid itself), as many as fit. The one length a layout prop takes.