Grid
A two-dimensional CSS grid: fixed columns or responsive auto-fit, with a token-driven gap.
Live demo
Grid arranges its children in a CSS grid with a token-driven gap (0–8). Two sizing modes cover most needs: pass columns (1–12) for a fixed equal-width column count, or pass minColWidth for a responsive auto-fit track that packs as many columns as fit at or above that minimum and reflows as the container resizes.
When both are set minColWidth wins. align and justify control how items sit within their cells. Like the other layout primitives it adds spacing and structure but no color or chrome of its own.
When to use
How this component composes with the rest of the set.
Props
6 props, straight from the manifest.
| Prop | Type | Default | Bindings | Description |
|---|---|---|---|---|
Anatomy
The named parts that make up the component, with their selectors.
root
The CSS grid container carrying the gap, column, align, and justify classes.
Tokens & coverage
What the component consumes, checked live against what the algorithm produces.
Live coverage check against the xoji-default register
(derive(xojiDefault, { anchors }) →
coverComponent(manifest, register)). Every token this component
consumes must be a key the algorithm produces.
--space-0
--space-1
--space-2
--space-3
--space-4
--space-5
--space-6
--space-7
--space-8
Slots
The children to lay out in grid cells.
Accessibility
Code
Fixed and responsive columns
A fixed three-column grid, then a responsive auto-fit grid driven by a minimum track width.
<xoji-grid columns="3" gap="4">
<xoji-card>One</xoji-card>
<xoji-card>Two</xoji-card>
<xoji-card>Three</xoji-card>
</xoji-grid>
<xoji-grid min-col-width="16rem" gap="3">
<xoji-card>Auto-fit</xoji-card>
<xoji-card>responsive</xoji-card>
<xoji-card>columns</xoji-card>
</xoji-grid>
<script lang="ts">
import { Grid, Card } from "@xoji/svelte";
</script>
<Grid columns={3} gap={4}>
<Card>One</Card>
<Card>Two</Card>
<Card>Three</Card>
</Grid>
<Grid minColWidth="16rem" gap={3}>
<Card>Auto-fit</Card>
<Card>responsive</Card>
<Card>columns</Card>
</Grid>
---
import { Grid, Card } from "@xoji/astro";
---
<Grid columns={3} gap={4}>
<Card>One</Card>
<Card>Two</Card>
<Card>Three</Card>
</Grid>
<Grid minColWidth="16rem" gap={3}>
<Card>Auto-fit</Card>
<Card>responsive</Card>
<Card>columns</Card>
</Grid>