Skip to content

Grid

CSS Grid container — columns, rows, gap, templateColumns, templateRows, and the rest of the grid API as token-aware props. The right reach when you need explicit row × column placement.

  • stable
  • since v0.1.0
  • 3.94 kB
  • primitive
  • layout
  • grid

Plain <div>. Grid layout has no implicit semantics — pair with semantic children (<article>, headings) when grid items represent content; otherwise leave a Grid as a layout-only wrapper.

Preview
Open
tsx

The shortcut columns={n} produces an evenly-divided n-column track. Pass a responsive map to shift column count per breakpoint — the most common dashboard / card-grid pattern.

Preview
Open
tsx

templateColumns accepts a raw grid-template-columns string (or a responsive map) when you need non-uniform tracks — e.g. "240px 1fr" for a sidebar + main shell. Combine with gridColumn / gridRow on children to span tracks.

Preview
Open
tsx
PropTypeDefaultDescription
className
string
—
Additional class names appended after Cynosure's base classes.
style
CSSProperties
—
Inline style overrides merged last.
children
ReactNode
—
Grid children. Use `LayoutProps.gridColumn`/`gridRow`/`gridArea` on children for placement.
columns
Responsive<number>
—
Column-count shorthand — emits `repeat(N, minmax(0, 1fr))`. Superseded by `templateColumns` when both are set.
rows
Responsive<number>
—
Row-count shorthand — emits `repeat(N, minmax(0, auto))`. Superseded by `templateRows` when both are set.
templateColumns
Responsive<string>
—
Raw `grid-template-columns` — use for mixed tracks like `"200px 1fr 200px"`. Wins over `columns`.
templateRows
Responsive<string>
—
Raw `grid-template-rows`. Wins over `rows`.
autoFlow
Responsive<GridAutoFlow>
—
`grid-auto-flow` — direction new tracks are added (`row`, `column`, or `dense` variants).
autoColumns
Responsive<string>
—
`grid-auto-columns` — size for implicitly-created columns.
autoRows
Responsive<string>
—
`grid-auto-rows` — size for implicitly-created rows.
gap
—
Uniform gap in both axes. Falls back to `rowGap`/`columnGap` when set.
columnGap
—
Gap between columns. Overrides the column axis of `gap`.
rowGap
—
Gap between rows. Overrides the row axis of `gap`.
align
Responsive<GridAlignItems>
—
`align-items` — how each item sits within its cell on the block axis.
justifyItems
Responsive<GridAlignItems>
—
`justify-items` — how each item sits within its cell on the inline axis.
alignContent
Responsive<GridJustifyContent>
—
`align-content` — how tracks are distributed when the grid is shorter than its container on the block axis.
justify
Responsive<GridJustifyContent>
—
`justify-content` — how tracks are distributed along the inline axis. Matches Radix/Chakra semantics.
padding
—
Padding on all four sides. Token from the spacing scale.
paddingX
—
Horizontal padding (left + right). Overrides `padding` on the X axis.
paddingY
—
Vertical padding (top + bottom). Overrides `padding` on the Y axis.
paddingTop
—
Padding on the top edge. Beats `padding` / `paddingY`.
paddingRight
—
Padding on the right (inline-end in RTL) edge.
paddingBottom
—
Padding on the bottom edge.
paddingLeft
—
Padding on the left (inline-start in RTL) edge.
margin
—
Margin on all four sides. Accepts the spacing scale or `"auto"`.
marginX
—
Horizontal margin (left + right). Use `"auto"` to centre.
marginY
—
Vertical margin (top + bottom).
marginTop
—
Margin on the top edge.
marginRight
—
Margin on the right edge.
marginBottom
—
Margin on the bottom edge.
marginLeft
—
Margin on the left edge.
width
—
Element width. Accepts a `SpaceToken`, `LengthValue`, or named alias.
height
—
Element height. Accepts a `SpaceToken`, `LengthValue`, or named alias.
minWidth
—
Minimum width — useful for preventing flex children from collapsing.
maxWidth
—
Maximum width — `"prose"` caps to a comfortable reading measure.
minHeight
—
Minimum height.
maxHeight
—
Maximum height.
background
—
Background colour. Use a `ColorToken` like `"bg.surface"` for theme awareness.
color
—
Text colour. Inherits unless set.
borderColor
—
Border colour. Pair with `borderWidth` to make the border visible.
borderWidth
—
Border thickness in scale steps.
borderStyle
—
Border line style.
borderRadius
—
Corner rounding token.
boxShadow
—
Drop-shadow token from the elevation scale.
opacity
Responsive<number | `${number}`>
—
Opacity 0–1. Use sparingly — prefer surface tokens over translucency.
overflow
—
How content that exceeds the box is handled.
overflowX
—
Horizontal-axis overflow control. Overrides `overflow` for the X axis.
overflowY
—
Vertical-axis overflow control.
display
—
CSS `display` value. `"contents"` removes the element's box from layout.
position
—
CSS `position`. Pair with `top`/`right`/`bottom`/`left` for placement.
top
—
Top inset (when positioned). Accepts a `SpaceToken`, `"auto"`, `"0"`, or `LengthValue`.
right
—
Right inset (when positioned).
bottom
—
Bottom inset (when positioned).
left
—
Left inset (when positioned).
zIndex
—
Stacking-context layer token (`"modal"`, `"tooltip"`, …).
gridColumn
Responsive<string>
—
Grid-column shorthand (e.g. `"1 / 3"`, `"span 2"`).
gridRow
Responsive<string>
—
Grid-row shorthand.
gridArea
Responsive<string>
—
Named grid area.
flex
Responsive<"1" | "none" | "auto" | "initial" | (string & {})>
—
Shorthand: `1 | auto | none | initial | <css>`. Resolves to `flex` on the child.
flexGrow
Responsive<number | `${number}`>
—
Grow factor inside a flex container.
flexShrink
Responsive<number | `${number}`>
—
Shrink factor inside a flex container.
flexBasis
Responsive<SizeValue | "content">
—
Initial main-axis size before grow/shrink.
alignSelf
—
Override `align-items` for a single child.
justifySelf
—
Override `justify-items` for a single child (grid).
order
Responsive<number | `${number}`>
—
Flex/grid child reorder index.
asChild
boolean
—
When `true`, renders the primitive's single React child via `Slot`, forwarding className/style/ref/event handlers onto it.
as
ElementType
"div"
Rendered intrinsic element or component.
ref
ForwardedRef<Element>
—
  • Card grids: <Grid columns={{ base: 1, sm: 2, lg: 3, xl: 4 }} gap="4" /> is the canonical responsive card layout.
  • For uniform columns without writing the responsive map, reach for SimpleGrid — it’s Grid tuned for the 90% case.
  • App shells with sidebar + main: templateColumns="240px 1fr" keeps the sidebar pinned and the main column responsive in one prop.
  • Box and every layout primitive expose gridArea, gridColumn, gridRow so a Grid child can claim a span without a wrapper.