Axon 911 Frontend Docs
    Loading navigation…
U
User
Switch to light mode
  1. Primitives
  2. Grid
  3. Usage

Grid

Usage

Overview
Grid defines column (and optional row) tracks with design tokens—ideal for dashboards, queue boards, and sidebar + main shells. Prefer it when alignment must hold in two axes or when track ratios are structural (2:1, fixed metric column + flexible peers). Prefer FlexBox with item={FlexItem.*} for one-dimensional flex rows and scroll hosts inside a pane.
When to use
  • Equal or ratio column tracks (GridTemplate.EqualThirds, TwoOne, ThreeOne, EqualTenths).
  • Queue-board metric rows with tokenized fixed leading columns (QueueMetricsStandard, QueueMetricsEct).
  • Sidebar + main layouts (SidebarStartMain, MainSidebarEnd) with collapseBelow inside a container query host.
  • Card galleries that add columns as a pane grows (AutoFillMinItem).
  • Regions that move between widths, such as a panel beside the main content when wide and below it when narrow (areas with GRID_AREA_PRESETS or defineGridAreas; see API and Development).
  • Children whose span changes with the container width (columnSpan={{ initial, md, … }}; see API and Development).
  • Nested groups that must line up on one set of tracks: form sections that share a label column, or card rows whose headers, bodies and footers align (subgrid with columnSpan / rowSpan; see API and Development).
When not to use
  • Simple vertical stacks or single toolbars—FlexBox and item={FlexItem.*} are easier.
  • Scrollable flex children inside an already-defined row—use FlexItem.FillScroll on Box / FlexBox, not grid tracks.
  • Ad hoc grid-template-columns in consumer CSS—request or use an existing GridTemplate.
  • Matching fixed widths or display: contents wrappers to fake alignment between nested groups—use subgrid on the nested Grid.
Flex children inside grid cells
Grid positions cells; flex behavior inside a cell still uses Box / FlexBox props. Put paint on Box inside Grid / GridItem. For a cell that should grow and scroll, wrap content in FlexBox item={FlexItem.FillScroll} with a definite height on the grid row or cell host—not className flex rules.
Layout needPrefer
2:1 or 3:1 columnsGrid template={GridTemplate.TwoOne} or ThreeOne
Ten equal columnsGrid template={GridTemplate.EqualTenths}
Queue metrics (231px / 337px leading track)QueueMetricsStandard / QueueMetricsEct
One row, one child eats leftover height + scrollsFlexBox item={FlexItem.FillScroll} inside the cell
Toolbar + growing body in a columnOuter FlexBox; toolbar item={FlexItem.Fixed}, body FillScroll
Before and after (flex basis → GridTemplate)
Align nested groups with subgrid
Give a nested Grid subgrid={GridSubgrid.Columns} and columnSpan={GridSpan.Full} and its children sit on the parent's column tracks, so labels in separate sections share one column. GridSubgrid.Rows with rowSpan does the same for rows, so card parts line up across a row of cards. The span goes on the subgrid itself, never on a wrapping GridItem or Box. Leave gap unset to keep the parent's gutters.
Anatomy
Grid container, optional GridItem for span, Box children for content and paint. Enable containerType={ContainerType.InlineSize} on an ancestor when using collapseBelow.
Best practices
  • Do use gap from GridGap tokens.
  • Do pair collapseBelow with container queries when grids live in resizable panes.
  • Don't pass background, border, or style on Grid / GridItem—use Box inside cells.
  • Don't duplicate ratio layouts with flex and basis when a GridTemplate exists.
  • Don't set template, rows or collapseBelow on an axis a subgrid adopts; the parent owns those tracks.
Accessibility
  • Keep DOM order aligned with reading order; avoid dense flow={GridFlow.RowDense} when focus path matters.
  • Maintain spacing for text zoom in metric-heavy boards.
Related Components
  • Box — FlexItem, alignSelf, and paint inside cells.
  • Empty state for sparse grids.
Previous
Error Boundary / Accessibility
Next
Grid / API and Development
On this page
Overview
When to use
When not to use
Flex children inside grid cells
Before and after (flex basis → GridTemplate)
Align nested groups with subgrid
Anatomy
Best practices
Accessibility
Related Components