Grid
Grid is the Rust-only column system: a CSS grid of columns equal tracks whose children are Cols, each claiming a span (and optionally an offset). Row is the flex counterpart in the same family — a wrapping flex row with gap, justification and alignment — and the two are documented together here because Col is meaningless without its grid.
This page documents a legacy migration surface. The family settled in the Rust crate before the component pages existed, and packages/vue/src ships no HkGrid / HkRow / HkCol, so there is no Vue twin and no shared stylesheet mirror. For new work, plain CSS Grid or flexbox on the host's own markup replaces it — the component's only real surface is one inline grid-template-columns plus an inline grid-column per column, which CSS does directly — or a Container when the need is a responsive max-width wrapper rather than columns.
- A whole page skeleton is a host concern; the legacy frame is Layout.
- Vertical rhythm and gaps between blocks are Space; a rule between blocks is Divider.
- A titled content block that happens to contain a grid is Section.
Import
use *; // Grid, Row, Col
use *; // rsx!, VNode
Each is a plain function: Grid(GridProps { … }), Col(ColProps { … }), Row(RowProps { … }). All three have children as a required field, and none of the three props structs is re-exported by the prelude — a host that needs to name one takes it from hikari_components itself. Inside rsx! every prop may be omitted except the required slot field — and that field has to be named in this family (see below), so every example passes it explicitly.
Grid and Col
Grid writes grid-template-columns: repeat({columns}, minmax(0, 1fr)) inline, with columns defaulting to 12; gap picks a step from a closed set — sm (0.5rem), md (1rem, the default) and lg (1.5rem) — and anything else falls back to md. Long content cannot blow the track out, because minmax(0, 1fr) lets the tracks shrink below their content width.
Col writes grid-column: span N inline from span, and grid-column: {offset + 1} / span N when offset is set — the offset is the number of tracks to skip, and the sheet's .hk-col only adds min-width: 0. span defaults to 12 when omitted, so a bare Col takes the whole row.
Naming the children slot
In this family the children arrive through a field literally named children, spelled children: Some(rsx! { … }) on all three components — the same shape on Grid, Col and Row. A bare Grid { Col { … } } does not compile: the macro hands the block's nodes to the slot as a plain node while the slot expects Option<VNode> (E0308: expected Option<VNode>, found VNode). Omitting the field entirely panics at render time with ` children is required but was not provided `.
Four of twelve
Eight of twelve
Six of twelve
Six of twelve
Offset and Row
offset skips tracks before the column starts, which is how a column is pushed to the trailing edge without an empty filler column: span: 4, offset: 4 in a twelve-track grid starts at track five and spans four.
Row is the flex sibling: gap reads the same sm / md / lg steps (default md), wrap defaults to true, justify takes start (the default), center, end, between or around, and align takes start, end, stretch or center (the default). rtl overrides the theme's layout direction for the instance, flipping the row to row-reverse. Inline styles written by the component come first and the style prop is appended last, so a host can override a declaration it did not like.
Four columns
Pushed right
Left
Right
Responsive spans
span_md and span_lg fill the md:col-span-* / lg:col-span-* utility classes, and the breakpoints are the sheet's own: md from 768px, lg from 1024px. span_sm is declared but has no stylesheet counterpart — there is no sm:col-span-* rule and nothing reads it, so leaving it out changes nothing on screen. There is no breakpoint behind the base class — .col-responsive is grid-column: span 12 and the component also writes grid-column: span N inline, so on a viewport under 768px a column still spans its base span, not twelve. A host that needs a true mobile-first stack sets the inline declaration itself or uses its own classes.
Responsive
Responsive
API
Rust
Props — Grid
| Prop | Type | Default | Description |
|---|---|---|---|
| children | Element | — | — |
| columns | u8 | 12 | — |
| gap | String | "md".to_string() | — |
| class | String | "" | — |
Props — Row
| Prop | Type | Default | Description |
|---|---|---|---|
| children | Element | — | — |
| gap | String | "md".to_string() | — |
| wrap | bool | true | — |
| justify | String | "start".to_string() | — |
| align | String | "center".to_string() | — |
| rtl | Option<bool> | None | — |
| class | String | "" | — |
| style | String | "" | — |
Props — Col
| Prop | Type | Default | Description |
|---|---|---|---|
| children | Element | — | — |
| span | Option<u8> | None | — |
| span_sm | Option<u8> | None | — |
| span_md | Option<u8> | None | — |
| span_lg | Option<u8> | None | — |
| offset | Option<u8> | None | — |
| class | String | "" | — |
Accessibility
- Grid, Col and Row render plain divs with no roles, no landmarks and no names; the reading and tab order is the DOM order the host wrote, and visual reordering through offset or a reversed Row does not change it — keep the DOM order meaningful for keyboard and screen-reader users.
- Wrapping (Row.wrap, the default) can reorder items visually on narrow viewports; nothing announces the reflow, so avoid splitting a label from its control across the wrap.
- No focus management or keyboard handling lives here; focus stops come from the content.
- Grid writes the track list inline, so a host stylesheet cannot add a breakpoint to it without overriding the inline declaration.