When to use
Section titled “When to use”Use Stack to lay children out in a vertical flow with a fixed, token-based gap: form fields, card content, settings lists, page sections.
When not to use
Section titled “When not to use”- To lay out horizontally: Use Inline for items side by side.
- For columns: Use Grid for a layout with rows and columns.
- To reverse the visual order: Stack has no reverse direction. Reading order is DOM order; write the items in the order you want.
- For a box look: If you need padding, a surface or a border, use Box; you can put a Stack inside a Box.
Anatomy
Section titled “Anatomy”Stack has two parts:
- Container: a vertical
flexcontainer (flex-col).gapandalignapply to this element. - Children:
children, in DOM order. Withseparatoron, every child after the first gets a 1 px rule above it.
Behaviour
Section titled “Behaviour”- Stack is static: it does not change on hover, click or focus, and it is not in the tab order.
- Defaults:
gapmd,alignstretch,separatorfalse. - With
separatoron, the gap becomes padding on both sides of the rule; the rule sits in the middle of the gap. - Visual order is always DOM order; there is no reverse direction or
ordersetting.
Guidelines
Section titled “Guidelines”Choose the gap to fit the group
Section titled “Choose the gap to fit the group”Give related items a small gap; with no gap at all, items read as one block of text.
First itemSecond item
First itemSecond item
Use the separator for several rows
Section titled “Use the separator for several rows”separator helps in settings and description lists. With a single child no rule shows.
First itemSecond item
First item
Content
Section titled “Content”- Stack carries no text of its own.
- When you pass
render={<ul />}to Stack, write every child as an<li>; do not put non-list children in it. - Keep example text neutral: “First item”, “Second item”.