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 accessibilityLabelaccessibilityLabelstring
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 accessibilityRoleaccessibilityRoleAccessibilityRole
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 accessibilityVisibilityaccessibilityVisibility"visible" | "hidden" | "exclusive"
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 alignContentalignContentAlignContentKeyword
Aligns the Stack along the cross axis.
- Anchor to alignItemsalignItemsAlignItemsKeyword
Aligns the Stack's children along the cross axis.
- Anchor to backgroundbackgroundBackgroundColorKeyword
Adjust the background of the element.
- Anchor to blockSizeblockSizeSizeUnitsOrAuto
Adjust the block size.
- Anchor to borderborderBorderShorthand
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 borderColorborderColor"" | ColorKeyword
Set the color of the border.
If set, it takes precedence over the
border
property's color.- Anchor to borderRadiusborderRadiusMaybeAllValuesShorthandProperty<BoxBorderRadii>
Set the radius of the border.
1-to-4-value syntax is supported. Note that, contrary to the CSS, it uses flow-relative values and the order is:
- 4 values:
start-start start-end end-end end-start
- 3 values:
start-start (start-end & end-start) start-end
- 2 values:
(start-start & end-end) (start-end & end-start)
For example:
small-100
means start-start, start-end, end-end and end-start border radii aresmall-100
.small-100 none
means start-start and end-end border radii aresmall-100
, start-end and end-start border radii arenone
.small-100 none large-100
means start-start border radius issmall-100
, start-end border radius isnone
, end-end border radius islarge-100
and end-start border radius isnone
.small-100 none large-100 small-100
means start-start border radius issmall-100
, start-end border radius isnone
, end-end border radius islarge-100
and end-start border radius issmall-100
.
- 4 values:
- Anchor to borderStyleborderStyle"" | MaybeAllValuesShorthandProperty<BoxBorderStyles>
Set the style of the border.
If set, it takes precedence over the
border
property's style.Like CSS, up to 4 values can be specified.
If one value is specified, it applies to all sides.
If two values are specified, they apply to the block sides and inline sides respectively.
If three values are specified, they apply to the block-start, both inline sides, and block-end respectively.
If four values are specified, they apply to the block-start, block-end, inline-start, and inline-end sides respectively.
- Anchor to borderWidthborderWidth"" | MaybeAllValuesShorthandProperty<"small" | "small-100" | "base" | "large" | "large-100" | "none">
Set the width of the border.
If set, it takes precedence over the
border
property's width.Like CSS, up to 4 values can be specified.
If one value is specified, it applies to all sides.
If two values are specified, they apply to the block sides and inline sides respectively.
If three values are specified, they apply to the block-start, both inline sides, and block-end respectively.
If four values are specified, they apply to the block-start, block-end, inline-start, and inline-end sides respectively.
- Anchor to columnGapcolumnGapMakeResponsive<"" | SpacingKeyword>
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 directiondirectionMakeResponsive<"inline" | "block">
Sets how the Stack's children are placed within the Stack.
direction
either accepts:- a single value either
inline
orblock
- OR a responsive value string with the supported SpacingKeyword as a query value.
- a single value either
- Anchor to displaydisplayMakeResponsive<"auto" | "none">
Sets the outer display type of the component. The outer type sets a component's participation in flow layout.
auto
the component's initial value. The actual value depends on the component and context.none
hides the component from display and removes it from the accessibility tree, making it invisible to screen readers.
- MakeResponsive<MaybeTwoValuesShorthandProperty<SpacingKeyword>>
Adjust spacing between elements.
gap
can 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 inlineSizeinlineSizeSizeUnitsOrAuto
Adjust the inline size.
- Anchor to justifyContentjustifyContentJustifyContentKeyword
Aligns the Stack along the main axis.
- Anchor to maxBlockSizemaxBlockSizeSizeUnitsOrNone
Adjust the maximum block size.
- Anchor to maxInlineSizemaxInlineSizeSizeUnitsOrNone
Adjust the maximum inline size.
- Anchor to minBlockSizeminBlockSizeSizeUnits
Adjust the minimum block size.
- Anchor to minInlineSizeminInlineSizeSizeUnits
Adjust the minimum inline size.
- Anchor to overflowoverflow"visible" | "hidden"
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 paddingpaddingMakeResponsive<MaybeAllValuesShorthandProperty<PaddingKeyword>>
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:
large
means block-start, inline-end, block-end and inline-start paddings arelarge
.large none
means block-start and block-end paddings arelarge
, inline-start and inline-end paddings arenone
.large none large
means block-start padding islarge
, inline-end padding isnone
, block-end padding islarge
and inline-start padding isnone
.large none large small
means block-start padding islarge
, inline-end padding isnone
, block-end padding islarge
and inline-start padding issmall
.
A padding value of
auto
will use the default padding for the closest container that has had its usual padding removed.padding
also accepts a responsive value string with the supported PaddingKeyword as a query value.- 4 values:
- Anchor to paddingBlockpaddingBlockMakeResponsive<"" | MaybeTwoValuesShorthandProperty<PaddingKeyword>>
Adjust the block-padding.
large none
means 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 paddingBlockEndpaddingBlockEndMakeResponsive<"" | PaddingKeyword>
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 paddingBlockStartpaddingBlockStartMakeResponsive<"" | PaddingKeyword>
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 paddingInlinepaddingInlineMakeResponsive<"" | MaybeTwoValuesShorthandProperty<PaddingKeyword>>
Adjust the inline padding.
large none
means 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 paddingInlineEndpaddingInlineEndMakeResponsive<"" | PaddingKeyword>
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 paddingInlineStartpaddingInlineStartMakeResponsive<"" | PaddingKeyword>
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 rowGaprowGapMakeResponsive<"" | SpacingKeyword>
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' | '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 | ContentPosition
BaselinePosition
'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 | ContentPosition
BackgroundColorKeyword
'transparent' | ColorKeyword
ColorKeyword
'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'
MakeResponsive
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 | ContentPosition
SizeUnitsOrNone
SizeUnits | 'none'
PaddingKeyword
SizeKeyword | 'none'
Code
Examples
Code
Default
<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>
Preview
Anchor to useful-forUseful for
- Placing items in rows or columns when sections don't work for your layout.
- Controlling the spacing between elements.
Anchor to considerationsConsiderations
- Stack doesn't add any padding by default. If you want padding around your stacked elements, use
base
to 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.