components / Structure

Stack

The Stack component is built off CSS flex properties. The usage examples here reflect many of these properties.


Vertical Alignment

A stack can be vertically aligned via the alignItems properties via CSS flex. Individual stack items can also be vertically aligned.

Top (Flex Start)

Center

Bottom (Flex End)


Horizontal Alignment

A stack can be horizontally aligned via the justifyContent properties via CSS flex.

Left (Flex Start)

Center

Right (Flex End)

Space Between

Space Around

Space Evenly


Stack Direction

The direction of a stack can be in a row or column. Items can also be reversed.

Row

Row Reverse

Column

Column Reverse


Item Spacing

Stack Items can be evenly spaced out, based on our spacing scale. This is the spacing property in Stack, ranging from 0 to 5.

Horizontal Spacing

When the Stack's direction is row (the default behavior), the spacing property is applied horizontally.

Vertical Spacing

When the Stack's direction is column, the spacing property is applied vertically.


Stack Wrapping

Stack items can utilize flex's wrap functionality to wrap Stack items, prevent wrapping, or wrap reverse items.

Nowrap Stack Items

Wrapped Stack Items

Reverse Wrapped Stack Items


Stack Items

Individual items in a stack can be altered. An optional <Stack.Item> can be wrapped around an item, and properties applied to it as needed.

Fill (Grow)

An individual item can be given the fill value (or use grow for more nuanced control) to occupy any free space in a container.

Item Vertical Alignment

Order

Individual items can be reordered.


Using Stack in other Components

One of the powerful features of Stack is its ability to work with other Anvil components. It can be useful in creating more complex layouts within other UI elements

Card Row Example

Tabs


Best Practices

Stack should:

  • Be used for small-scale layout tasks when you want a row of components that should wrap on small screen widths
  • Be used to vertically center two elements
  • Not be used for complex or unique arrangements of components
  • Not be used for large-scale page layout

Importing

import { Stack } from '@servicetitan/design-system';