Layout
Stack
A vertical flex layout with token spacing, alignment and optional separators.
Purpose
Stack arranges children in a column with a consistent gap. It is the most common primitive: forms,
card contents, page sections.
Import
import { Stack } from "@neshel-ui/layout";Usage
Preview: stack-basic
First
Second, a little longer
Third
import { Stack } from "@neshel-ui/layout";
import { Tile } from "./_tile";
export default function StackBasic() {
return (
<Stack space={{ base: "2", md: "4" }} alignX="start">
<Tile>First</Tile>
<Tile>Second, a little longer</Tile>
<Tile>Third</Tile>
</Stack>
);
}API
StackProps
| Prop | Type | Default | Description |
|---|---|---|---|
| align | Responsive<MainAxisAlign> | — | — |
| alignX | Responsive<"start" | "center" | "end" | "stretch"> | — | — |
| alignY | Responsive<MainAxisAlign> | — | — |
| as | LayoutElement | — | — |
| asChild | boolean | — | — |
| justify | Responsive<Justify> | — | — |
| ref | Ref<HTMLElement> | — | — |
| separator | SeparatorProp | — | — |
| space | Responsive<SpaceValue> | — | — |
| spaceX | Responsive<SpaceValue> | — | — |
| spaceY | Responsive<SpaceValue> | — | — |
Also accepts the props of: React DOM attributes.
alignXmaps toalign-items(start center end stretch),alignYtojustify-content.justifydistributes the vertical axis when the Stack is taller than its content.
Separators
Preview: stack-separator
- Profile
- Security
- Notifications
import { Inline, Stack } from "@neshel-ui/layout";
import { Text } from "@neshel-ui/typography";
const items = ["Profile", "Security", "Notifications"];
export default function StackSeparator() {
return (
<Stack space="6">
{/* true: a decorative rule between items; inside a <ul> it is rendered as an <li>. */}
<Stack as="ul" space="3" separator>
{items.map((item) => (
<li key={item}>{item}</li>
))}
</Stack>
{/* A custom separator element is inserted unchanged between items. */}
<Inline as="nav" aria-label="Footer" space="3" separator={<Text aria-hidden="true">·</Text>}>
<a href="#privacy">Privacy</a>
<a href="#terms">Terms</a>
<a href="#contact">Contact</a>
</Inline>
</Stack>
);
}SeparatorProp
true renders the default decorative separator; an element renders that element.
type SeparatorProp = boolean | ReactElementseparator(true) renders a decorative rule (aria-hidden, colour--neshel-border) between rendered items — anliinsideul/ol, aspaninsidespan, otherwise adiv.- A custom element is inserted unchanged (only a
keyis added) and keeps its own semantics. null,undefined, booleans and""children are skipped; a Fragment counts as one item.separatortogether withwrapthrows (a wrapped line could start with a separator).
Responsive
Every spacing and alignment prop is responsive: space={{ base: "2", md: "6" }}.
Composition
as="ul" (or ol) makes a list; children should then be li. With asChild, the stack styles go
to your element and separators are inserted inside it (a component child with separator throws).
Common mistakes
- Adding margins to children to space them: let
spacedo it so the rhythm stays consistent. spacewithspaceYtogether: a type error and a runtime error.