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

Grid

API and Development

View SourceOpens in a new tabSubmit IssueOpens in a new tab
Grid is a layout host for tokenized column and row tracks. It does not carry paint—put background, border, and content on Box (or other primitives) inside cells. Use template={GridTemplate.*} for product layouts instead of consumer grid-template-columns. Pair with GridItem when a child spans multiple tracks. For one-dimensional flex inside a cell (scroll hosts, toolbars), use Box / FlexBox item (FlexItem, alignSelf).
Key props
NameTypeDefaultDescription
templateGridTemplate—Column track template (equal, ratio, sidebar, queue metrics, auto-fill).
rowsGridRows—Row template.
flowGridFlowrowAuto-placement flow.
alignGridAlign—Align items.
justifyGridJustify—Justify content.
gapGridGap—Gap spacing scale.
collapseBelowGridCollapseBelow—Single column below a container width breakpoint.
displayGridDisplaygridgrid or inline-grid.
subgridGridSubgrid—Take column tracks, row tracks, or both from the parent Grid. Requires the span for each adopted axis.
columnSpanGridSpanValue—Column tracks this Grid covers in its parent Grid; a GridResponsiveSpan changes it with the container width.
areasGridAreasLayout—Typed area layout from defineGridAreas or GRID_AREA_PRESETS; replaces template, rows and collapseBelow.
areaGridAreaRef—The parent layout's area this Grid fills, from layout.areas.
alignSelfGridAlignSelf—This Grid's block-axis alignment in its parent's cell.
justifySelfGridJustifySelf—This Grid's inline-axis alignment in its parent's cell.
rowSpanGridSpanValue—Row tracks this Grid covers in its parent Grid; a GridResponsiveSpan changes it with the container width.
See GridProps and GridItem in @prepared911/ui for the full surface.
GridTemplate
MemberTracks
EqualHalvesrepeat(2, minmax(0, 1fr))
EqualThirdsrepeat(3, minmax(0, 1fr))
EqualQuartersrepeat(4, minmax(0, 1fr))
EqualSixthsrepeat(6, minmax(0, 1fr))
EqualTwelfthsrepeat(12, minmax(0, 1fr))
EqualTenthsrepeat(10, minmax(0, 1fr))
TwoOneminmax(0, 2fr) minmax(0, 1fr)
ThreeOneminmax(0, 3fr) minmax(0, 1fr)
QueueMetricsStandardvar(--layout-queue-metrics-standard) minmax(0, 1fr) minmax(0, 1fr)
QueueMetricsEctvar(--layout-queue-metrics-ect) minmax(0, 1fr) minmax(0, 1fr)
SidebarStartMainvar(--layout-panel-fixed) minmax(0, 1fr)
MainSidebarEndminmax(0, 1fr) var(--layout-panel-fixed)
AutoFillMinItemrepeat(auto-fill, minmax(var(--layout-grid-auto-fill-min), 1fr))
FitStartMainfit-content(50%) minmax(0, 1fr)
Queue metric tokens resolve to 14.4375rem (standard) and 21.0625rem (ECT) at a 16px root.
Width-responsive spans
columnSpan and rowSpan on GridItem (and on a subgrid Grid) take a fixed GridSpan or a GridResponsiveSpan: initial applies at every width, and each GridBreakpoint key replaces it once the nearest container is wider than that breakpoint (1080, 1280, 1600, 1920, 2560, 3440px). The largest matching key wins, and a collapsing parent still forces one track, so pair spans with collapseBelow to reflow in narrow containers. Wrap the grid in a Box with containerType={ContainerType.InlineSize}.
Item alignment
alignSelf (GridAlignSelf) and justifySelf (GridJustifySelf) on a GridItem or nested Grid move that one child within its cell and override the grid's align for it only.
Area layouts
defineGridAreas builds a typed layout: GridTrack columns and rows (tokens, fr tracks or sizing keywords, or { space } steps), a matrix of area names, and below layouts for narrower containers keyed by the collapseBelow widths. Children take area={layout.areas.<name>}; a name the layout does not declare fails typecheck. GRID_AREA_PRESETS holds the approved layouts as starting points: mainAside, asideMain, headerMainAside, headerMainFooter. Reading order. DOM order must match the logical reading and focus order, which is the order of the narrowest (single-column) layout. Area layouts may rearrange children visually only in ways that keep that order sensible; they never change what a screen reader or the Tab key meets first. defineGridAreas records the order as readingOrder; put the children in that order.
Subgrid
A nested Grid normally sizes its own tracks. With subgrid, its children sit on the parent's tracks instead, so groups line up with each other. The nested Grid must be the parent's grid item, so the span goes on it: columnSpan for GridSubgrid.Columns, rowSpan for GridSubgrid.Rows, both for GridSubgrid.Both. The types require the span and reject own tracks (template, rows, collapseBelow) on an adopted axis.
GridSubgridAdoptsRequires
ColumnsParent column trackscolumnSpan
RowsParent row tracksrowSpan
BothParent column and row trackscolumnSpan and rowSpan
Gap. Leave gap unset on an adopted axis to keep the parent's gutter. A set gap replaces the gutter inside the subgrid, and its children still start on the parent's track edges. Paint. Grid has none, so a subgridded card puts its surface on the Box parts inside it.
Form label and field columns
Each section is a column subgrid spanning every parent column, so the labels in both sections share the parent's FitStartMain leading track and every input starts on the same edge. The parent's column gap of 8 is the label-to-control gap.
Card rows
Each Card is a row subgrid spanning three parent rows, one per slot, so headers, content and footers share rows across the cards and each card keeps its surface, radius and padding. A taller header or longer content moves that row for every card. AutoFillMinItem adds and drops columns with the available width, so the cards reflow at high zoom.
Flex item vs Grid
PatternUse
Column ratios (2:1, 3:1, ten equal tracks)Grid + GridTemplate
Fixed metric column + two flexible peers on queue boardsQueueMetricsStandard / QueueMetricsEct
Flex row with one scrollable childFlexBox + item={FlexItem.FillScroll}
Cross-axis override on one flex childalignSelf on Box / FlexBox
Before and after
The previews below mirror Grid stories in Storybook.
Default
Columns
Rows
Grid flow
Alignment
Masonry layout
Previous
Grid / Usage
Next
Grid / Accessibility
On this page
Key props
GridTemplate
Width-responsive spans
Item alignment
Area layouts
Subgrid
Form label and field columns
Card rows
Flex item vs Grid
Before and after
Default
Columns
Rows
Grid flow
Alignment
Masonry layout