Components / Layout and type
Grid
CSS grid with a fixed number of columns, or as many columns as fit (minChildWidth).
import { Grid } from "@stylhero/ui";
Example
Code
import { Grid, Paper, Stack } from "@stylhero/ui";
const tile = (label: string) => <Paper key={label} padding={3} outlined>{label}</Paper>;
function GridExample() {
return (
<Stack gap={4}>
<Grid columns={3} gap={3}>{["1", "2", "3", "4", "5", "6"].map(tile)}</Grid>
<Grid minChildWidth={140} gap={3}>{["Fits", "as", "many", "as", "it", "can"].map((l, i) => tile(l + i))}</Grid>
</Stack>
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
columns |
number |
- | Fixed number of equal columns. |
gap |
Space |
6 |
|
minChildWidth |
number |
240 |
Or: fit as many columns as possible, each at least this wide (e.g. 240). Wraps on small screens. |
Also takes every <div> attribute (id, style, data-*, aria-*, event handlers…), passed to that element.
Types
type Space = 0 | 1 | 2 | 3 | 4 | 6 | 8 | 12;
Generated from src/components/Grid.tsx. Something wrong or missing? Open an issue.