Foundational layout primitive for elements along a vertical or horizontal axis, with consistent spacing and alignment.

Preview

Direction

Column

direction="column" will flow child items vertically, i.e. top to bottom. It is the default direction and doesn't need to be explictily set.

Row

direction="row" will flow child items horizontally, i.e. left to right.

Row Reverse

Column Reverse

As

The as prop controls which HTML element the Stack component renders as. Defaults to <div>, but can be declared as any valid HTML element to ensure semantic and accessible markup.

Declaring as an appropriate HTML element improves accessibility by helping screen readers better understand document structure, and maintainability with clear code intent.

Common as values: span, ul, ol, li, section, nav, article, main, aside, header, footer.

Example: section

Use as="section" to create a thematic grouping of content.

Example: span

Use as="span" when you need an inline container.

Gap

Available gaps

Size
Design Token
REM
PX
0 var(--dt-space-0) 0.0rem 0px
50 var(--dt-space-50) 0.05rem .5px
100 var(--dt-space-100) 0.1rem 1px
200 var(--dt-space-200) 0.2rem 2px
300 var(--dt-space-300) 0.4rem 4px
350 var(--dt-space-350) 0.6rem 6px
400 var(--dt-space-400) 0.8rem 8px
450 var(--dt-space-450) 1.2rem 12px
500 var(--dt-space-500) 1.6rem 16px
525 var(--dt-space-525) 2.0rem 20px
550 var(--dt-space-550) 2.4rem 24px
600 var(--dt-space-600) 3.2rem 32px
625 var(--dt-space-625) 4.2rem 42px
650 var(--dt-space-650) 4.8rem 48px
700 var(--dt-space-700) 6.4rem 64px

Align

The align prop controls how items are aligned along the cross-axis (perpendicular to the stack direction). For row stacks, this controls vertical alignment. For column stacks, this controls horizontal alignment.

Available align values: start, center, end, stretch, baseline.

Default

The align prop is optional. Unless specified, it will default vertical stacks to align-items="stretch" and horizontal stacks to align-items="center".

Start

Align items to the start of the cross-axis.

Center

Center items along the cross-axis.

End

Align items to the end of the cross-axis.

Stretch

Stretch items to fill the container height.

Baseline

Align items along their text baselines.

Justify

The justify prop controls how items are distributed along the main axis (the direction of the stack). For row stacks, this controls horizontal distribution. For column stacks, this controls vertical distribution.

Available justify values: start (default), center, end, space-around, space-between, space-evenly.

Start

Align items to the start of the main axis (default).

Center

Center items along the main axis.

End

Align items to the end of the main axis.

Space Around

Distribute items with equal space around each item.

Space Between

Distribute items with space between them, edges flush to container.

Space Evenly

Distribute items with equal space between all items, including edges.

Responsive

Example

Stacks column at small screen size and column reverse at large screen

Set 200 as the default gap, 300 for small and larger, 400 for medium, 500 for large, and 600 for extra large. Learn more about how our breakpoints work in the Responsive Breakpoints documentation.

Nested Example

Stacks row with gap 500 and stacks in row reverse the nested stack with gap 500.

Example: Align and Justify

Like direction and gap, the align and justify props support responsive object syntax to change alignment at different breakpoints.

Resize your browser to see the alignment change at different breakpoints.

Resize your browser to see the justification change at different breakpoints.

Migrating from Flex CSS Utilities

View the Migrating from Flex CSS Utilities to DtStack for more details.

Vue API

Slots

Name
Description
default

Slot for main content

Props

Name
Description
Default
align

The align property controls the alignment of items along the cross axis. The align can be set to a string, or object with breakpoints. All the undefined breakpoints will have the 'default' value. You can override the default align with 'default' key. In case of string, it will be applied to all the breakpoints. If not specified, alignment uses CSS defaults: stretch for column direction, center for row/row-reverse directions (set by CSS). Valid values are 'start', 'center', 'end', 'stretch', 'baseline'.

Type: string|object
as

Set this prop to render stack as a specific HTML element.

Type: string
'div'
direction

Set this prop to the direction to stack the items. You can override the default direction with 'default' key. All the undefined breakpoints will have 'default' value. By default, for the column direction it will have justify-content: flex-start and for the row direction align-items: center. This can be overridden using the align and justify props.

Type: string|object
'column'
gap

The gap property controls the spacing between items in the stack. The gap can be set to a string, or object with breakpoints. All the undefined breakpoints will have the 'default' value. You can override the default gap with 'default' key. In case of string, it will be applied to all the breakpoints. Valid values are '0', '50', '100', '200', '300', '350', '400', '450', '500', '525', '550', '600', '625', '650', '700'.

Type: string|object
'0'
justify

The justify property controls the justification of items along the main axis. The justify can be set to a string, or object with breakpoints. All the undefined breakpoints will have the 'default' value. You can override the default justify with 'default' key. In case of string, it will be applied to all the breakpoints. Valid values are 'start', 'center', 'end', 'space-around', 'space-between', 'space-evenly'.

Type: string|object
'start'

Classes

Class
Applies to
Description
Stack documentation last updated Thursday, June 11, 2026