Skip to content

Grid

Last updated 6 Nov 2026

Overview ​

NbGrid is a flexible layout primitive built on CSS flexbox. A dir="row" grid arranges children horizontally; a dir="col" grid arranges them vertically. Nest them freely to build any layout.

The grid is configured at compile time via src/styles/variables/_grid.scss.

Visual demo ​

Direction ​

The dir prop controls the main axis: row lays children side by side; col stacks them top to bottom.

Gaps ​

The gap prop controls spacing between children using named size tokens.

Gap scale ​

TokenValue
xxs2px
xs4px
sm8px
md16px
lg24px
xl32px
xxl48px

Each gap reads the matching --nb-spacing-* token. A grid without a gap has no gutter unless it takes a mode: wide (32px), narrow (16px) or condensed (1px), Carbon's gutter modes, which a gap overrides. The Code tab covers modes, hang, subgrid, the page container and ratio.

Column gaps ​

Order ​

Use first and last boolean props to reorder items visually without changing DOM order. Use reverse to flip the entire row or column.

Last ​

Visibility ​

Use the visible prop to show or hide grid items. It accepts a boolean or a breakpoint map for responsive control.