Playground

Stack

Lay children out in a column or row with one gap from the spacing scale.

  • Built on native elements
  • A plain div; adds no roles.
  • Styles in one file: stack.css

Import

import '@monoline/css';
import {Stack} from '@monoline/react';

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add stack

Usage

import {Badge, Stack} from '@monoline/react';

<Stack gap={2}>
  <Badge>one</Badge>
  <Badge>two</Badge>
  <Badge>three</Badge>
</Stack>

Examples

Column

Row, wrapped

Props

StackProps

PropTypeDefaultDescription
direction"row" | "column"'column'`column` (default) stacks children vertically; `row` lays them out horizontally.
gap1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 93Step on the spacing scale: 1 = --s1 (4px) up to 9.
align"center" | "start" | "end" | "stretch"–Cross-axis alignment (`align-items`): `start`, `center`, `end` or `stretch`.
justify"center" | "start" | "end" | "between"–Main-axis distribution (`justify-content`): `start`, `center`, `end` or `between`.
wrapboolean–Lets children wrap onto new lines. Useful with `direction="row"`. Default false.

Data Attributes

State is exposed through attributes. Style it with these selectors, not with class toggles.

AttributeStylesheet
[data-align="center"]stack.css
[data-align="end"]stack.css
[data-align="start"]stack.css
[data-align="stretch"]stack.css
[data-justify="between"]stack.css
[data-justify="center"]stack.css
[data-justify="end"]stack.css
[data-justify="start"]stack.css

CSS classes

ClassStylesheet
.stackstack.css
.stack-rowstack.css
.stack-wrapstack.css

Customization

Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.

app.css
.stack {
  border-color: var(--accent);
}
.stack[data-align="center"] {
  background: var(--wash);
}

Accessibility

  • A plain div; adds no roles.