Skip to content

Stack

Lays children out in a vertical column with consistent spacing between items. Stack arranges content; pair it with a Container when the column also needs a max-width or page gutters.

Import

import { Stack } from "@hyzer-labs/ui"

Demo

gap is the space between items; its values map to the --hz-space-* tokens (xs 0.5rem → xl 8rem). The tinted zone is the Stack; the space between its edge and the items is the padding. padding applies on both axes; paddingInline and paddingBlock override one axis and win where set. Both stay correct in RTL and vertical writing modes. near and away are the density distances: context-aware values that tighten inside data-density-shift regions (see the Density tab).

gap
padding
padding="md"
gap="md" between items
paddingInline="md"
gap="md" between items
paddingBlock="md"
gap="md" between items
<Stack gap="md" padding="md">…</Stack>
<Stack gap="md" paddingInline="md">…</Stack>
<Stack gap="md" paddingBlock="md">…</Stack>

Props

NameTypeDefaultNote
gap'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'near' | 'away''md'near/away are the density distances — they tighten inside data-density-shift regions.
align'start' | 'center' | 'end' | 'stretch' | 'baseline''stretch'Shared LayoutAlign scale (Stack/Cluster/Grid).
padding'none' | 'sm' | 'md' | 'lg' | 'near' | 'away''none'Both axes. Shared LayoutPadding scale — near/away tighten inside data-density-shift regions.
paddingInline'none' | 'sm' | 'md' | 'lg' | 'near' | 'away'—Per-axis override — wins over padding on the inline axis. Same LayoutPadding scale.
paddingBlock'none' | 'sm' | 'md' | 'lg' | 'near' | 'away'—Per-axis override — wins over padding on the block axis. Same LayoutPadding scale.
asstring'div'
classstring—Merged after the hz-stack class.
childrenSnippet—

Anything not listed above is forwarded as an attribute to the root element (or the native control in form components). So id, data-*, aria-*, and event handlers just work.

Theme hooks

What this component promises your CSS. The reference theme styles exactly these — from @layer hz-theme, so your unlayered rules win. See Styling Components for the how.

Root class: .hz-stack

Data attributes

HookValuesStyles
data-gap'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'near' | 'away'Row gap. Default md. The only layout gap scale with an xl rung.
data-align'start' | 'center' | 'end' | 'stretch' | 'baseline'align-items. Default stretch.
data-padding'none' | 'sm' | 'md' | 'lg' | 'near' | 'away'Padding on both axes. Default none.

Accessibility

Stack is a layout primitive with no ARIA semantics. The reading and focus order follow the DOM order of children.