Homecomponentsstructural

Stack

A container that arranges its items in a horizontal or vertical line.


Overview

Creates a single dimension row or column from the items you provide. The items will not wrap on overflow. So use it only to display a limited list of items. You can however flip the orientation on certain breakpoints.

A horizontal Stack is similar to Columns with one major difference - Stack items will not size relatively, e.g., using percentages. For that, prefer to use Columns. Absolute sizes work fine.

The following example lays out three Text elements vertically.

Item 1Item 2Item 3

Orientation

Use the orientation property to select the direction in which the items are laid out. This property accepts responsive values.

By default the items are laid out in a vertical column. Here's an example of a horizontal stack:

Item 1Item 2Item 3

Spacing

Use the spacing property to adjust the spacing between the items. By default, the items have no spacing. This property accepts responsive values.

Here's an example of tags with a $500 spacing:

Tag 1
Tag 2
Tag 3

Alignment

The alignment property allows placing items across the direction of orientation, i.e., for a horizontal stack it controls the vertical alignment of the items, and for a vertical stack it controls the horizontal alignment of the items. This property accepts responsive values.

Here's a few alignment options for a vertical stack.

Mia Sabinus

Dietician

Mia Sabinus

Dietician

Mia Sabinus

Dietician

Here's a few alignment options for a horizontal stack.

Mia Sabinus


Mia Sabinus


Mia Sabinus

Justification

The justification property aligns items along the direction of orientation. For a horizontal stack, it controls the horizontal alignment of the items. For a vertical stack, it controls the vertical alignment of the items. This property accepts responsive values.

Here's a few justification options for a horizontal stack.

Here's a few justification options for a vertical stack.

Mia

Dietician

Mia

Dietician

Mia

Dietician

Mia

Dietician

Reversing Items Order

Add a reverse property to reverse the displaying order of the items. This only affects the ordering visually, not the order in the document. For instance, the tab order is preserved.

Item 3Item 2Item 1

Dividers

Use dividers to add a divider between items in a vertical stack. This property accepts responsive values.

Here's an example of dividers in a vertical stack.

Item 1
Item 2
Item 3

Here's an example of dividers in a horizontal stack.

Item 1
Item 2
Item 3

API

children
Required
The items to lay out in the stack.
ReactNode

as
The element used for the root node.
div
span
ol
ul
main

orientation
The orientation of the stack.
ResponsiveValue<"horizontal" | "vertical">

spacing
Defines the spacing between the items.

alignment
Sets the horizontal alignment of the items.

justification
Sets the vertical alignment of the items.

reverse
Reverse the order of the items.
true
false

dividers
Add separators between the items.
ResponsiveValue<boolean>

data
An object with the data keys and values.
DataAttributeMap

itemID
string

itemProp
string

itemRef
string

itemScope
true
false

itemType
string