Stack
Organizes elements horizontally or vertically along the block or inline axis. Use to structure layouts, group related components, or control spacing between elements.
Anchor to propertiesProperties
- Anchor to accessibilityLabelaccessibilityLabelaccessibilityLabelstringstring
A label that describes the purpose or contents of the element. When set, it will be announced to users using assistive technologies and will provide them with more context.
Only use this when the element's content is not enough context for users using assistive technologies.
- Anchor to accessibilityRoleaccessibilityRoleaccessibilityRoleAccessibilityRoleAccessibilityRoleDefault: 'generic'Default: 'generic'
Sets the semantic meaning of the component’s content. When set, the role will be used by assistive technologies to help users navigate the page.
- Anchor to accessibilityVisibilityaccessibilityVisibilityaccessibilityVisibility"visible" | "hidden" | "exclusive""visible" | "hidden" | "exclusive"Default: 'visible'Default: 'visible'
Changes the visibility of the element.
visible: the element is visible to all users.hidden: the element is removed from the accessibility tree but remains visible.exclusive: the element is visually hidden but remains in the accessibility tree.
- Anchor to alignContentalignContentalignContentAlignContentKeywordAlignContentKeywordDefault: 'normal'Default: 'normal'
Aligns the Stack's children along the block axis.
This overrides the block value of
.- Anchor to alignItemsalignItemsalignItemsAlignItemsKeywordAlignItemsKeywordDefault: 'normal'Default: 'normal'
Aligns the Stack's children along the block axis.
- Anchor to backgroundbackgroundbackgroundBackgroundColorKeywordBackgroundColorKeywordDefault: 'transparent'Default: 'transparent'
Adjust the background of the component.
- Anchor to blockSizeblockSizeblockSizeSizeUnitsOrAutoSizeUnitsOrAutoDefault: 'auto'Default: 'auto'
Adjust the block size.
- Anchor to borderborderborderBorderShorthandBorderShorthandDefault: 'none' - equivalent to `none base auto`.Default: 'none' - equivalent to `none base auto`.
Set the border via the shorthand property.
This can be a size, optionally followed by a color, optionally followed by a style.
If the color is not specified, it will be
base.If the style is not specified, it will be
auto.Values can be overridden by
,, and.- Anchor to borderColorborderColorborderColor"" | ColorKeyword"" | ColorKeywordDefault: '' - meaning no overrideDefault: '' - meaning no override
Adjust the color of the border.
- Anchor to borderRadiusborderRadiusborderRadiusMaybeAllValuesShorthandProperty<BoxBorderRadii>MaybeAllValuesShorthandProperty<BoxBorderRadii>Default: 'none'Default: 'none'
Adjust the radius of the border.
- Anchor to borderStyleborderStyleborderStyle"" | MaybeAllValuesShorthandProperty<BoxBorderStyles>"" | MaybeAllValuesShorthandProperty<BoxBorderStyles>Default: '' - meaning no overrideDefault: '' - meaning no override
Adjust the style of the border.
- Anchor to borderWidthborderWidthborderWidth"" | MaybeAllValuesShorthandProperty<"small" | "small-100" | "base" | "large" | "large-100" | "none">"" | MaybeAllValuesShorthandProperty<"small" | "small-100" | "base" | "large" | "large-100" | "none">Default: '' - meaning no overrideDefault: '' - meaning no override
Adjust the width of the border.
- Anchor to columnGapcolumnGapcolumnGapMaybeResponsive<"" | SpacingKeyword>MaybeResponsive<"" | SpacingKeyword>Default: '' - meaning no overrideDefault: '' - meaning no override
Adjust spacing between elements in the inline axis.
This overrides the column value of
gap.either accepts:- a single SpacingKeyword value (e.g.
large-100) - OR a responsive value string with the supported SpacingKeyword as a query value.
- a single SpacingKeyword value (e.g.
- Anchor to directiondirectiondirectionMaybeResponsive<"inline" | "block">MaybeResponsive<"inline" | "block">Default: 'block'Default: 'block'
Sets how the Stack's children are placed within the Stack.
directioneither accepts:- a single value either
inlineorblock - OR a responsive value string with the supported SpacingKeyword as a query value.
- a single value either
- Anchor to displaydisplaydisplayMaybeResponsive<"auto" | "none">MaybeResponsive<"auto" | "none">Default: 'auto'Default: 'auto'
Sets the outer display type of the component. The outer type sets a component's participation in flow layout.
autothe component's initial value. The actual value depends on the component and context.nonehides the component from display and removes it from the accessibility tree, making it invisible to screen readers.
- Anchor to gapgapgapMaybeResponsive<MaybeTwoValuesShorthandProperty<SpacingKeyword>>MaybeResponsive<MaybeTwoValuesShorthandProperty<SpacingKeyword>>Default: 'none'Default: 'none'
Adjust spacing between elements.
gapcan either accept:- a single SpacingKeyword value applied to both axes (e.g.
large-100) - OR a pair of values (eg
large-100 large-500) can be used to set the inline and block axes respectively - OR a responsive value string with the supported SpacingKeyword as a query value.
- a single SpacingKeyword value applied to both axes (e.g.
- Anchor to inlineSizeinlineSizeinlineSizeSizeUnitsOrAutoSizeUnitsOrAutoDefault: 'auto'Default: 'auto'
Adjust the inline size.
- Anchor to justifyContentjustifyContentjustifyContentJustifyContentKeywordJustifyContentKeywordDefault: 'normal'Default: 'normal'
Aligns the Stack's children along the inline axis.
- Anchor to maxBlockSizemaxBlockSizemaxBlockSizeSizeUnitsOrNoneSizeUnitsOrNoneDefault: 'none'Default: 'none'
Adjust the maximum block size.
- Anchor to maxInlineSizemaxInlineSizemaxInlineSizeSizeUnitsOrNoneSizeUnitsOrNoneDefault: 'none'Default: 'none'
Adjust the maximum inline size.
- Anchor to minBlockSizeminBlockSizeminBlockSizeSizeUnitsSizeUnitsDefault: '0'Default: '0'
Adjust the minimum block size.
- Anchor to minInlineSizeminInlineSizeminInlineSizeSizeUnitsSizeUnitsDefault: '0'Default: '0'
Adjust the minimum inline size.
- Anchor to overflowoverflowoverflow"visible" | "hidden""visible" | "hidden"Default: 'visible'Default: 'visible'
Sets the overflow behavior of the element.
hidden: clips the content when it is larger than the element’s container. The element will not be scrollable and the users will not be able to access the clipped content by dragging or using a scroll wheel on a mouse.visible: the content that extends beyond the element’s container is visible.
- Anchor to paddingpaddingpaddingMaybeResponsive<MaybeAllValuesShorthandProperty<PaddingKeyword>>MaybeResponsive<MaybeAllValuesShorthandProperty<PaddingKeyword>>Default: 'none'Default: 'none'
Adjust the padding of all edges.
1-to-4-value syntax is supported. Note that, contrary to the CSS, it uses flow-relative values and the order is:
- 4 values:
block-start inline-end block-end inline-start - 3 values:
block-start inline block-end - 2 values:
block inline
For example:
largemeans block-start, inline-end, block-end and inline-start paddings arelarge.large nonemeans block-start and block-end paddings arelarge, inline-start and inline-end paddings arenone.large none largemeans block-start padding islarge, inline-end padding isnone, block-end padding islargeand inline-start padding isnone.large none large smallmeans block-start padding islarge, inline-end padding isnone, block-end padding islargeand inline-start padding issmall.
A padding value of
autowill use the default padding for the closest container that has had its usual padding removed.paddingalso accepts a responsive value string with the supported PaddingKeyword as a query value.- 4 values:
- Anchor to paddingBlockpaddingBlockpaddingBlockMaybeResponsive<"" | MaybeTwoValuesShorthandProperty<PaddingKeyword>>MaybeResponsive<"" | MaybeTwoValuesShorthandProperty<PaddingKeyword>>Default: '' - meaning no overrideDefault: '' - meaning no override
Adjust the block-padding.
large nonemeans block-start padding islarge, block-end padding isnone.
This overrides the block value of
padding.also accepts a responsive value string with the supported PaddingKeyword as a query value.- Anchor to paddingBlockEndpaddingBlockEndpaddingBlockEndMaybeResponsive<"" | PaddingKeyword>MaybeResponsive<"" | PaddingKeyword>Default: '' - meaning no overrideDefault: '' - meaning no override
Adjust the block-end padding.
This overrides the block-end value of
.also accepts a responsive value string with the supported PaddingKeyword as a query value.- Anchor to paddingBlockStartpaddingBlockStartpaddingBlockStartMaybeResponsive<"" | PaddingKeyword>MaybeResponsive<"" | PaddingKeyword>Default: '' - meaning no overrideDefault: '' - meaning no override
Adjust the block-start padding.
This overrides the block-start value of
.also accepts a responsive value string with the supported PaddingKeyword as a query value.- Anchor to paddingInlinepaddingInlinepaddingInlineMaybeResponsive<"" | MaybeTwoValuesShorthandProperty<PaddingKeyword>>MaybeResponsive<"" | MaybeTwoValuesShorthandProperty<PaddingKeyword>>Default: '' - meaning no overrideDefault: '' - meaning no override
Adjust the inline padding.
large nonemeans inline-start padding islarge, inline-end padding isnone.
This overrides the inline value of
padding.also accepts a responsive value string with the supported PaddingKeyword as a query value.- Anchor to paddingInlineEndpaddingInlineEndpaddingInlineEndMaybeResponsive<"" | PaddingKeyword>MaybeResponsive<"" | PaddingKeyword>Default: '' - meaning no overrideDefault: '' - meaning no override
Adjust the inline-end padding.
This overrides the inline-end value of
.also accepts a responsive value string with the supported PaddingKeyword as a query value.- Anchor to paddingInlineStartpaddingInlineStartpaddingInlineStartMaybeResponsive<"" | PaddingKeyword>MaybeResponsive<"" | PaddingKeyword>Default: '' - meaning no overrideDefault: '' - meaning no override
Adjust the inline-start padding.
This overrides the inline-start value of
.also accepts a responsive value string with the supported PaddingKeyword as a query value.- Anchor to rowGaprowGaprowGapMaybeResponsive<"" | SpacingKeyword>MaybeResponsive<"" | SpacingKeyword>Default: '' - meaning no overrideDefault: '' - meaning no override
Adjust spacing between elements in the block axis.
This overrides the row value of
gap.either accepts:- a single SpacingKeyword value (e.g.
large-100) - OR a responsive value string with the supported SpacingKeyword as a query value.
- a single SpacingKeyword value (e.g.
AccessibilityRole
'main' | 'header' | 'footer' | 'section' | 'region' | 'aside' | 'navigation' | 'ordered-list' | 'list-item' | 'list-item-separator' | 'unordered-list' | 'separator' | 'status' | 'alert' | 'generic' | 'presentation' | 'none'AlignContentKeyword
Align content sets the distribution of space between and around content items along a flexbox's cross axis, or a grid or block-level element's block axis.
'normal' | BaselinePosition | ContentDistribution | OverflowPosition | ContentPositionBaselinePosition
'baseline' | 'first baseline' | 'last baseline'ContentDistribution
'space-between' | 'space-around' | 'space-evenly' | 'stretch'OverflowPosition
`unsafe ${ContentPosition}` | `safe ${ContentPosition}`ContentPosition
'center' | 'start' | 'end'AlignItemsKeyword
Align items sets the align-self value on all direct children as a group.
'normal' | 'stretch' | BaselinePosition | OverflowPosition | ContentPositionBackgroundColorKeyword
'transparent' | ColorKeywordColorKeyword
'subdued' | 'base' | 'strong'SizeUnitsOrAuto
SizeUnits | 'auto'SizeUnits
`${number}px` | `${number}%` | `0`BorderShorthand
Represents a shorthand for defining a border. It can be a combination of size, optionally followed by color, optionally followed by style.
BorderSizeKeyword | `${BorderSizeKeyword} ${ColorKeyword}` | `${BorderSizeKeyword} ${ColorKeyword} ${BorderStyleKeyword}`BorderSizeKeyword
SizeKeyword | 'none'SizeKeyword
'small-500' | 'small-400' | 'small-300' | 'small-200' | 'small-100' | 'small' | 'base' | 'large' | 'large-100' | 'large-200' | 'large-300' | 'large-400' | 'large-500'BorderStyleKeyword
'none' | 'solid' | 'dashed' | 'dotted' | 'auto'MaybeAllValuesShorthandProperty
T | `${T} ${T}` | `${T} ${T} ${T}` | `${T} ${T} ${T} ${T}`BoxBorderRadii
'small' | 'small-200' | 'small-100' | 'base' | 'large' | 'large-100' | 'large-200' | 'none'BoxBorderStyles
'auto' | 'none' | 'solid' | 'dashed'MaybeResponsive
T | `@container${string}`SpacingKeyword
SizeKeyword | 'none'MaybeTwoValuesShorthandProperty
T | `${T} ${T}`JustifyContentKeyword
Justify content defines how the browser distributes space between and around content items along the main-axis of a flex container, and the inline axis of a grid container.
'normal' | ContentDistribution | OverflowPosition | ContentPositionSizeUnitsOrNone
SizeUnits | 'none'PaddingKeyword
SizeKeyword | 'none'Anchor to slotsSlots
- Anchor to childrenchildrenchildrenHTMLElementHTMLElement
The content of the Stack.
Preview
Examples
Code
jsx
<s-stack gap="base"> <s-badge>Paid</s-badge> <s-badge>Processing</s-badge> <s-badge>Filled</s-badge> <s-badge>Completed</s-badge> </s-stack>html
<s-stack gap="base"> <s-badge>Paid</s-badge> <s-badge>Processing</s-badge> <s-badge>Filled</s-badge> <s-badge>Completed</s-badge> </s-stack>Basic block stack (vertical)
Description
Default vertical stacking layout with consistent spacing between text elements.
jsx
<s-stack gap="base"> <s-text>First item</s-text> <s-text>Second item</s-text> <s-text>Third item</s-text> </s-stack>html
<s-stack gap="base"> <s-text>First item</s-text> <s-text>Second item</s-text> <s-text>Third item</s-text> </s-stack>Inline stack (horizontal)
Description
Horizontal layout for arranging badges or similar elements side by side.
jsx
<s-stack direction="inline" gap="large-100"> <s-badge>Item 1</s-badge> <s-badge>Item 2</s-badge> <s-badge>Item 3</s-badge> </s-stack>html
<s-stack direction="inline" gap="large-100"> <s-badge>Item 1</s-badge> <s-badge>Item 2</s-badge> <s-badge>Item 3</s-badge> </s-stack>Responsive stack with container queries
Description
Advanced responsive layout that changes direction and spacing based on container size.
jsx
<s-query-container> <s-stack direction="@container (inline-size > 500px) inline, block" gap="@container (inline-size > 500px) base, small-300" > <s-box padding="large-100" borderColor="base" borderWidth="small" borderRadius="large-100" > Content 1 </s-box> <s-box padding="large-100" borderColor="base" borderWidth="small" borderRadius="large-100" > Content 2 </s-box> </s-stack> </s-query-container>html
<s-query-container> <s-stack direction="@container (inline-size > 500px) inline, block" gap="@container (inline-size > 500px) base, small-300" > <s-box padding="large-100" borderColor="base" borderWidth="small" borderRadius="large-100" > Content 1 </s-box> <s-box padding="large-100" borderColor="base" borderWidth="small" borderRadius="large-100" > Content 2 </s-box> </s-stack> </s-query-container>Custom alignment
Description
Horizontal stack with space-between justification and center alignment for balanced layouts.
jsx
<s-stack direction="inline" justifyContent="space-between" alignItems="center"> <s-text>Left aligned</s-text> <s-text>Centered text</s-text> <s-text>Right aligned</s-text> </s-stack>html
<s-stack direction="inline" justifyContent="space-between" alignItems="center"> <s-text>Left aligned</s-text> <s-text>Centered text</s-text> <s-text>Right aligned</s-text> </s-stack>Custom spacing
Description
Stack with custom gap values and separate row/column gap controls for precise spacing.
jsx
<s-stack gap="large-100 large-500" rowGap="large-300" columnGap="large-200"> <s-box padding="large-100" borderColor="base" borderWidth="small" borderRadius="large-100" > Box with custom spacing </s-box> <s-box padding="large-100" borderColor="base" borderWidth="small" borderRadius="large-100" > Another box </s-box> </s-stack>html
<s-stack gap="large-100 large-500" rowGap="large-300" columnGap="large-200"> <s-box padding="large-100" borderColor="base" borderWidth="small" borderRadius="large-100" > Box with custom spacing </s-box> <s-box padding="large-100" borderColor="base" borderWidth="small" borderRadius="large-100" > Another box </s-box> </s-stack>
Anchor to useful-forUseful for
- Placing non-form items in rows or columns when sections don't work for your layout.
- Controlling the spacing between elements.
- For form layouts where you need multiple input fields on the same row, use
s-gridinstead.
Anchor to considerationsConsiderations
- Stack doesn't add any padding by default. If you want padding around your stacked elements, use
baseto apply the default padding. - When spacing becomes limited, Stack will always wrap children to a new line.
Anchor to best-practicesBest practices
- Use smaller gaps between small elements and larger gaps between big ones.
- Maintain consistent spacing in stacks across all pages of your app.