Stack
Lay children out in a column or row with one gap from the spacing scale.
SourceStyles source@monoline/react 0.5.0Markdown for AI toolsstable
- 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
| Prop | Type | Default | Description |
|---|---|---|---|
direction | "row" | "column" | 'column' | `column` (default) stacks children vertically; `row` lays them out horizontally. |
gap | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 3 | Step 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`. |
wrap | boolean | – | 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.
| Attribute | Stylesheet |
|---|---|
[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
| Class | Stylesheet |
|---|---|
.stack | stack.css |
.stack-row | stack.css |
.stack-wrap | stack.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.