Skip to main content

Configure the following properties on the Stack component.

Anchor to alignContent
alignContent

Controls the distribution of space between and around lines of wrapped content along the cross axis.

Anchor to alignItems
alignItems

Controls the alignment of individual children along the cross axis (perpendicular to the main axis).

Anchor to blockSize
blockSize
Default: 'auto'

The block size of the container. Auto automatically sizes based on the container's children.

Anchor to columnGap
columnGap
'' |
Default: '' - meaning no override

The spacing between elements in the inline axis. This overrides the column value of gap.

Anchor to direction
direction
'block' | 'inline'
Default: 'block'

The direction in which children are laid out using logical properties:

  • 'block': Vertical arrangement along the block axis (typically top to bottom) without wrapping
  • 'inline': Horizontal arrangement along the inline axis (typically left to right) with automatic wrapping when space is insufficient
<>
Default: 'none'

The spacing between elements. A single value applies to both axes. A pair of values (eg large-100 large-500) can be used to set the inline and block axes respectively.

string

A unique identifier for the element used for targeting with CSS, JavaScript, or accessibility features.

Anchor to inlineSize
inlineSize
Default: 'auto'

The inline size (width in horizontal writing modes) of the element.

Learn more about inline-size on MDN.

Anchor to justifyContent
justifyContent
Default: 'normal'

Controls the distribution and alignment of children along the main axis (the axis defined by the direction property).

Learn more about justify-content on MDN.

Anchor to maxBlockSize
maxBlockSize
Default: 'none'

The maximum block size constraint for the container.

Anchor to maxInlineSize
maxInlineSize
Default: 'none'

The maximum inline size constraint for the container.

Anchor to minBlockSize
minBlockSize
Default: '0'

The minimum block size constraint for the container.

Anchor to minInlineSize
minInlineSize
Default: '0'

The minimum inline size constraint for the container.

Anchor to padding
padding
<>
Default: 'none'

The padding applied to all edges of the container. Supports 1-to-4-value syntax using flow-relative values in the order:

  • 4 values: block-start inline-end block-end inline-start
  • 3 values: block-start inline block-end
  • 2 values: block inline

For example:

  • large means block-start, inline-end, block-end and inline-start paddings are large.
  • large none means block-start and block-end paddings are large, inline-start and inline-end paddings are none.
  • large none large means block-start padding is large, inline-end padding is none, block-end padding is large and inline-start padding is none.
  • large none large small means block-start padding is large, inline-end padding is none, block-end padding is large and inline-start padding is small.

An auto value inherits the default padding from the closest container that has removed its usual padding.

Anchor to paddingBlock
paddingBlock
<'' | >
Default: '' - meaning no override

The block-axis padding for the container. Overrides the block value of the padding property.

Anchor to paddingBlockEnd
paddingBlockEnd
'' |
Default: '' - meaning no override

The block-end padding for the container. Overrides the block-end value of the paddingBlock property.

Anchor to paddingBlockStart
paddingBlockStart
'' |
Default: '' - meaning no override

The block-start padding for the container. Overrides the block-start value of the paddingBlock property.

Anchor to paddingInline
paddingInline
<'' | >
Default: '' - meaning no override

The inline-axis padding for the container. Supports two-value syntax where large none sets inline-start to large and inline-end to none. Overrides the inline value of the padding property.

Anchor to paddingInlineEnd
paddingInlineEnd
'' |
Default: '' - meaning no override

The inline-end padding for the container. Overrides the inline-end value of the paddingInline property.

Anchor to paddingInlineStart
paddingInlineStart
'' |
Default: '' - meaning no override

The inline-start padding for the container. Overrides the inline-start value of the paddingInline property.

Anchor to rowGap
rowGap
'' |
Default: '' - meaning no override

The spacing between elements in the block axis. This overrides the row value of gap.


Anchor to Organize elements with a stackOrganize elements with a stack

Organize elements using a stack component. This example shows a basic stack with spacing between child elements.

Organize elements with a stack

Organize elements using a stack component. This example shows a basic stack with spacing between child elements.

Organize elements with a stack

<s-stack gap="small" direction="inline" justifyContent="center">
<s-badge tone="neutral">Paid</s-badge>
<s-badge tone="success">Active</s-badge>
</s-stack>

  • Choose appropriate direction: Use block for vertical arrangements like forms. Use inline for horizontal arrangements like button groups. Note that inline wraps while block doesn't.
  • Use design system spacing: Use SpacingKeyword values for consistency. Start with base and adjust as needed.
  • Apply alignment properties: Use justifyContent for main axis distribution, alignItems for cross axis positioning, alignContent for extra space distribution.
  • Avoid percentages on mobile: Don't use percentage-based sizing within scrollable containers on mobile surfaces.
  • Use gap for spacing control: Use gap for uniform spacing, rowGap for block axis, columnGap for inline axis.

Was this page helpful?