ClickorAltL

Dragto resize

Nord Design System SearchDeveloperDeveloperGetting startedUsing Web ComponentsWebfontsCDNLocalizationCSS Framework Legacy ESLint PluginWorking with AIFAQDesignDesignGetting startedFoundationsThemesBrand assetsToolsComponentsComponentsAccordion New Aside New Autocomplete New AvatarBadgeBanner Updated ButtonButton GroupCalendar Updated CardCheckbox Updated Collapsible New Combobox New Command MenuDate Picker Updated Date Range Picker New DividerDrawerDropdownEmpty StateField New FieldsetFilter Bar New FooterHeaderIconInput Updated Item New Kbd New LayoutMessageMeter New ModalNavigationNotificationNumber Field New Otp Field New Outline New Pagination New Popout Updated ProgressProgress BarQrcodeRadio Updated Range Updated Scroll Area New Segmented ControlSelect Updated SkeletonSpinnerStackTabTableTagTextarea Updated Time Picker New ToastToggle Updated TooltipTop BarTruncate New Visually HiddenDesign TokensDesign TokensTailwind CSSTailwind CSSBlocksBlocksTemplatesTemplatesIconsIconsPlaygroundPlaygroundLatest UpdatesLatest UpdatesChangelogChangelogMigration guidesMigration guides
GitHub

Stack

Open in Storybook

Stack manages layout of immediate children along the vertical or horizontal axis with optional spacing.

Loading...

Usage

Stack lays out its immediate children along a single axis with consistent spacing. Control the axis with direction, the spacing with gap, and cross-axis and main-axis distribution with align-items and justify-content.

Copy code
import "@nordhealth/components/lib/Stack"

Examples

Horizontal

Set direction="horizontal" to lay children out in a row.

Gap

The gap attribute accepts none, xs, s, m (default), l, xl and xxl from the spacing scale.

Alignment

Use align-items for cross-axis alignment and justify-content for main-axis distribution.

RTL

Stacks follow the document or container direction. Toggle the direction to see the layout mirror.

Accessibility

  • Stack is a layout primitive and applies no implicit ARIA role, so it does not alter the semantics of the content placed inside it.
  • It only spaces and aligns its immediate children; the reading and tab order follow source order, so arrange children in the order you want them announced.
  • When a stack represents a meaningful grouping (such as a list or navigation), add the appropriate role and labelling to the stack or its children rather than relying on the visual layout alone.

API reference

Stack

Stack component manages layout of immediate children along the vertical or horizontal axis with optional spacing between each child.

<nord-stack></nord-stack>

Props

PropertyAttribute Description TypeDefault
gapgapThe space injected between components.'none' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl''m'
directiondirectionThe direction of the stack.'vertical' | 'horizontal''vertical'
alignItemsalign-itemsHow to align the child items inside the stack.| 'center' | 'start' | 'end' | 'baseline' | 'stretch' | undefined'stretch'
wrapwrapDefines whether the Stack items are forced in a single line or can be flowed into multiple lines.booleanfalse
justifyContentjustify-contentHow to justify the child items inside the stack.| 'center' | 'start' | 'end' | 'space-between' | 'space-around' | 'space-evenly' | undefined

Slots

Slot name Description
Default slotThe stack content.

CSS Properties

CSS Custom Properties provide more fine grain control over component presentation. We advise utilizing existing properties on the component before using these.

PropertyDescriptionDefault
--n-stack-gapControls the spacing between items, using our spacing tokens.var(--n-space-m)
Design guidelinesFor designers

Usage

This section includes guidelines for designers and developers about the usage of this component in different contexts.

Do

  • Use when you need to stack multiple components vertically or horizontally.
  • Use when you want to adjust the white space between two or more components.

Don’t

  • Don’t use for building grid based layouts.