Blocks Design System

Stack

Lays out its children in a column or a row with a token gap between them. It is a Box with display="flex", so it takes every Box prop, renders on the server, and keeps as for semantics.

tsx
import { Stack } from '@blocks/design-system'

Usage

A Stack is a column with a md gap unless you say otherwise.

  1. Freeze the branch
  2. Run verification
  3. Pack the tarball
Source · stack/vertical.tsx
stack/vertical.tsx
import { Box, Stack } from '@blocks/design-system'

export default function Vertical() {
  return (
    <Stack as="ol" gap="sm" margin="none" padding="none" aria-label="Release steps">
      {['Freeze the branch', 'Run verification', 'Pack the tarball'].map((step) => (
        <Box as="li" key={step} padding="sm" border="default" dangerouslySetStyle={{ listStyle: 'none' }}>
          {step}
        </Box>
      ))}
    </Stack>
  )
}
Release steps

Rows that wrap

direction="row" with wrap="wrap" lets a list of actions flow onto more lines on a narrow screen. Use native links for navigation and native buttons for actions; the reading and Tab order stay the source order.

Source · stack/item-actions.tsx
stack/item-actions.tsx
import { Box, Stack } from '@blocks/design-system'

const actions = ['Edit item', 'Duplicate', 'Move to another board', 'Copy link', 'Archive']

export default function ItemActions() {
  return (
    <Stack as="nav" aria-label="Item actions" direction="row" wrap="wrap" gap="sm">
      {actions.map((action) => (
        <Box as="a" key={action} href={`#${action.toLowerCase().replaceAll(' ', '-')}`} paddingX="md" paddingY="xs" border="default">
          {action}
        </Box>
      ))}
      <Box as="button" type="button" paddingX="md" paddingY="xs" border="danger">
        Delete
      </Box>
    </Stack>
  )
}
Wrapping item actions

Spreading items

justify distributes children along the main axis and align places them on the cross axis.

Launch checklist

Settings
Source · stack/spread.tsx
stack/spread.tsx
import { Box, Stack } from '@blocks/design-system'

export default function Spread() {
  return (
    <Stack as="header" direction="row" justify="space-between" align="center" padding="md" border="default">
      <Box as="h3" margin="none">
        Launch checklist
      </Box>
      <Box as="a" href="#checklist-settings">
        Settings
      </Box>
    </Stack>
  )
}
Header with a trailing link

Responsive

Every prop takes a breakpoint object. These actions stack full-width below md and sit side by side above it.

Source · stack/responsive-actions.tsx
stack/responsive-actions.tsx
import { Box, Stack } from '@blocks/design-system'

export default function ResponsiveActions() {
  return (
    <Stack direction={{ base: 'column', md: 'row' }} gap={{ base: 'sm', md: 'md' }} align={{ base: 'stretch', md: 'center' }}>
      <Box as="button" type="button" paddingX="md" paddingY="xs" border="accent">
        Approve changes
      </Box>
      <Box as="button" type="button" paddingX="md" paddingY="xs" border="default">
        Request changes
      </Box>
    </Stack>
  )
}
Responsive actions

Props

Stack props
PropTypeDefaultDescription
alignResponsiveValue<Align>—Cross axis alignment. Responsive.
asElementType—The element or component to render, e.g. `as={NextLink}`.
directionResponsiveValue<Direction>columnMain axis. Defaults to `"column"`. Responsive.
justifyResponsiveValue<Justify>—Main axis distribution. Responsive.
wrapResponsiveValue<"nowrap" | "wrap" | "wrap-reverse">—Whether children wrap onto new lines. Responsive.

Also accepts Box layout props, styling escape hatches, margin props and padding props, and the native attributes of the element it renders.

Accessibility

  • Avoid row-reverse and column-reverse for content people read or tab through: the visual order would no longer match the order screen readers and the keyboard follow.
  • Give a Stack rendered as="nav" a name with aria-label.