Skip to content

Stack

A layout component for consistent spacing between child elements. Available in vertical and horizontal orientations.

Preview

Vertical stack

Item 1
Item 2
Item 3

Horizontal stack

Tag A
Tag B
Tag C
Tag D
Tag E

With different spacing

gap: --space-1 (4px)

A
B
C

gap: --space-4 (16px)

A
B
C

gap: --space-8 (32px)

A
B
C

Props

PropTypeDefaultDescription
direction'vertical' | 'horizontal''vertical'Stack direction
gapstring--space-4Spacing between items
align'start' | 'center' | 'end' | 'stretch''stretch'Cross-axis alignment
wrapbooleanfalseAllow items to wrap
childrenReact.ReactNode--Stack items

Code example

React

tsx
import { Stack, Button } from '@thepace/lexicon/components';

<Stack direction="horizontal" gap="var(--space-3)">
  <Button variant="primary">Save</Button>
  <Button variant="secondary">Cancel</Button>
</Stack>

<Stack gap="var(--space-6)">
  <Card>Section 1</Card>
  <Card>Section 2</Card>
  <Card>Section 3</Card>
</Stack>

CSS utility

css
.my-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

CSS class reference

ClassPurpose
.lex-stackFlex container
.lex-stack--verticalColumn direction
.lex-stack--horizontalRow direction
.lex-stack--wrapAllow wrapping

Guidelines

Do

  • Use Stack for consistent spacing between sibling elements.
  • Use spacing tokens for the gap value.
  • Combine with Grid for complex page layouts.

Don't

  • Don't set margins on Stack children — use the gap prop instead.
  • Don't nest Stacks excessively — a single Grid often works better.

Released under the MIT License. A product by the pace.