Hone UI
Components

Stack

Lay out children in one direction with a gap.

Stack arranges its children in a row or a column with even spacing. Use it instead of a flex Box. It is a Server Component and always uses the CSS gap property.

import Stack from '@hone-ui/react/Stack';

Examples

<Stack direction="row" spacing={2} sx={{ alignItems: 'center' }}>
  <Button variant="outlined">One</Button>
  <Button variant="outlined">Two</Button>
</Stack>

Spacing and direction take a value per breakpoint, and divider goes between items:

<Stack direction={{ xs: 'column', sm: 'row' }} spacing={{ xs: 1, sm: 3 }}>
  ...
</Stack>

<Stack divider={<Box component="hr" sx={{ width: '100%', m: 0 }} />} spacing={2}>
  ...
</Stack>

Responsive values use the default breakpoints (sm 600, md 900, lg 1200, xl 1536) and carry up to larger ones. { xs: 'column', md: 'row' } is a column below 900px and a row from 900px.

Props

PropTypeDefaultDescription
direction'row', 'row-reverse', 'column', 'column-reverse', or a breakpoint object or array'column'The main axis.
spacingnumber, CSS length, or a breakpoint object or array0The gap. A number multiplies the theme spacing.
dividerReactNodenoneRendered between each pair of children.
useFlexGapbooleanignoredAccepted for compatibility. Stack always uses gap.
componentElementType'div'The element to render.
sx, className, style, ref, childrenStandard.

Notes

  • System props such as alignItems do not work. Use sx.
  • Stack keeps the default breakpoints (xs to xl), whatever names createTheme and the @hone-ui/sx plugin use.
  • A component that returns a Fragment counts as one child, so divider skips its inner parts.
  • Stack does not read components.Stack.defaultProps.

Accessibility

Stack adds no semantics. Use component="ul" with li children for lists.

On this page