Skip to content
Slotted

Stack

Arranges children in one column and separates them by a step of the space scale.

Order SO-10482

Placed by Maria Chen on March 4 for the Harbor Street store.
ShippedWholesale
Estimated delivery on March 9.

Installation

The packages are a 0.x beta on npm, and their public API changes between beta releases without deprecation. One line installs the binding and the default theme.

bash
pnpm add @slotted/react @slotted/theme @slotted/themes

Gap

gap sets the separation between children as a step on the space scale, from 0 for none to 12. The default is 6. Each column below holds the same three badges at one step. A stack lays out one column; use Inline for a row.

Gap 0
PackedLateHeld
Gap 1
PackedLateHeld
Gap 2
PackedLateHeld
Gap 3
PackedLateHeld
Gap 4
PackedLateHeld
Gap 5
PackedLateHeld
Gap 6
PackedLateHeld
Gap 7
PackedLateHeld
Gap 8
PackedLateHeld
Gap 9
PackedLateHeld
Gap 10
PackedLateHeld
Gap 11
PackedLateHeld
Gap 12
PackedLateHeld

Alignment

align positions children across the column, along the inline axis: start, center or end give each child its own width and place it on that edge. Without align, children stretch to the width of the column, as the last card shows. A button directly inside a stack stretches the same way, so a row of actions belongs in an Inline.

align start

WholesalePriority shippingFragile

align center

WholesalePriority shippingFragile

align end

WholesalePriority shippingFragile

align stretch

WholesalePriority shippingFragile

Justification

justify positions children along the column and distributes the free space between them: start, center, end, between, around or evenly. It moves nothing until the stack is taller than its content, so each stack here has a block size of 12rem. In a page shell the stack takes that height from its container.

justify start

PackedShippedDelivered

justify center

PackedShippedDelivered

justify end

PackedShippedDelivered

justify between

PackedShippedDelivered

justify around

PackedShippedDelivered

justify evenly

PackedShippedDelivered

Sections and lines

A stack inside a stack gives each level its own gap: a wide gap separates the sections and a narrow gap separates the lines inside one. The outer stack here uses 8 and each inner stack uses 2.

Order SO-10482

Payment methodVisa ending 4242
Billing address200 Harbor Street, Portland
Shipping methodPriority shipping, 2 days

Another element

A stack paints nothing and claims no semantics, so you choose the element. In React, render replaces the root element. In Angular, the slStack attribute goes on the element itself. Fields that are sent together stand in a form, so Enter in a field submits them. A ul keeps the bullets and the indentation the browser gives it: a stack does not reset them.

Accessibility

  • Stack has no role and no ARIA. It arranges what you write inside it, and the children keep whatever semantics they already had.
  • There is no axis that reverses the children. Visual order stays DOM order, which is what WCAG 2.2 SC 1.3.2 asks for (technique C27, failure F1) and what keeps the Tab order matching the page.
  • The element is yours to choose. Render a ul when the children are list items and a form when they are fields, so the document says what it means.
  • Separation is a step on the space scale, stated in rem, so it grows with the browser zoom WCAG 1.4.4 requires.
  • Alignment uses the logical keywords, so a right-to-left document is the same column mirrored.

API

stack

Props

gap0 | 1 | … | 12Default 6
Sets the separation between children as a step on the space scale.
align'start' | 'center' | 'end' | 'stretch'
Positions children across the column, along the inline axis. Without it, children stretch to the width of the column.
justify'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'
Positions children along the column and distributes the free space. It moves nothing until the stack is taller than its content.
render(props) => ReactNode
Renders a different root element from the props it receives.

Theming

Each token is a CSS custom property: set it in a theme, or on any element to retune every stack inside it.

Theme tokens it reads

TokenDefault
--slotted-space-10.125rem
--slotted-space-102.5rem
--slotted-space-113rem
--slotted-space-124rem
--slotted-space-20.25rem
--slotted-space-30.375rem
--slotted-space-40.5rem
--slotted-space-50.75rem
--slotted-space-61rem
--slotted-space-71.25rem
--slotted-space-81.5rem
--slotted-space-92rem