Space

Even gaps between a row or column of children, plus the Compact mode that joins adjacent controls into one unit.

Usage

How wide the gap is, which way the run goes, what sits between the items, and whether Space is the right component at all.

When to use

Space puts an even gap between a run of children, and can put a separator between them. It draws nothing of its own. Use it for a row or column of controls.
  • A toolbar, a card footer or a form's action row: two to six controls in a line, each sized by its content.
  • A run of tags, links or metadata with a dot, a slash or a Divider between the items.
  • A container that has to keep its box when every child renders nothing. Flex hides itself in that case, and Space does not.
What to use instead
  • Flex when a child has to grow or the children must be direct flex items. Space puts each child in its own item element, so flex: 1 on a child does nothing.
  • A gap-* utility when you only need the gap. gap-sm on a flex div matches size="small", with no extra element per child.
  • Grid (Row and Col, or CSS grid) for a page layout, with columns that line up across rows and reflow at breakpoints.

Size: three presets, or a number

The default is small, which is tighter than the medium size Button and Input use. Pass medium or large for more room.
  • The presets follow the theme and shrink in compact mode. They match Flex's gap presets, so <Space size="small"> and <Flex gap="small"> always agree.
  • A number is a fixed gap that stays the same in compact mode. Use one only for a one-off.
  • size also takes a [horizontal, vertical] pair, and each half takes a preset or a number.

Orientation

orientation takes horizontal (the default) or vertical.
  • direction is the old name and logs a warning. It was renamed because direction also means left to right or right to left on the provider.
  • vertical is a shorthand, and orientation wins when both are set. Pick one spelling for your codebase.
  • A vertical Space is a column of controls, not a list. If the children are a list, read the Accessibility tab first.

Wrapping

wrap is off by default, so a horizontal Space that runs out of room overflows. Turn it on for runs whose length you do not control, like filter tags or selected values.
  • Once rows wrap, one size sets both the gap along a row and the gap between rows. Pass a pair, like size={[16, 8]}, to keep the rows closer.
  • Space takes its parent's width. Constrain the parent, or the Space, when the run should wrap sooner.

Separator, and the item around every child

separator takes a node, like a vertical Divider, a dot or a slash, and renders it between items, never at the ends. split is the old name and logs a warning.
  • Space puts every child in an item element of its own, which is where the separator goes. A selector like > * on the Space root matches those items, not your components.
  • A null or false child is skipped, so a conditional child never leaves two separators side by side.
  • classNames takes root, item and separator. item styles every child's box at once.

Alignment

align takes start, end, center or baseline. A horizontal Space defaults to center.
  • center suits controls of different heights, like a Button beside a Tag beside a Select.
  • baseline lines up text of mixed sizes, like a heading beside a timestamp.
  • start keeps short children at the top when one child is much taller, like a text block beside a single button.

Space.Compact removes the gap

Space.Compact joins adjacent controls into one, with shared borders and only the outer corners rounded.
  • It works with the kit's buttons, inputs and selects. A plain <div> inside is not joined.
  • block stretches the group to its container's width. A split button, a primary action with a dropdown caret, is the common two-child case.
  • Vertical compact is supported for buttons only.
  • size on Compact sets the size of the controls inside, not a gap.