Row

Slant / Primitives

A horizontal, wrapping row with a gap and alignment.

Demo

Usage

@tuttn/slant
import { Avatar, Badge, Button, Row, Text } from '@tuttn/slant'

// Side by side, 8px apart, centred on the cross axis, wrapping when out of room.
<Row><Badge tone="success">Live</Badge><Text muted>Deployed 2 minutes ago</Text></Row>

// A header: the title at the start, the actions at the end.
<Row justify="between">
  <Text as="h2" variant="title">Checkpoints</Text>
  <Row gap={6}><Button size="sm" variant="ghost">Export</Button><Button size="sm" variant="primary">New</Button></Row>
</Row>

// One line that never wraps, its children lined up at the top.
<Row wrap={false} align="start" gap={12}>
  <Avatar initials="AK" name="Ada K." />
  <Text>A message that wraps inside its own box instead of under the avatar.</Text>
</Row>

// A bar of links.
<Row as="nav" aria-label="Task" gap={16}>
  <a href="#files">Files</a><a href="#checks">Checks</a>
</Row>

Props

PropTypeDefaultDescription
gapnumber8Space between children, in pixels.
align'start' | 'center' | 'end' | 'stretch''center'Cross-axis alignment of the children.
justify'start' | 'center' | 'between' | 'end''start'How the children spread along the row.
wrapbooleantrueWraps onto more lines when the row runs out of room; `false` keeps one line.
as'div' | 'section' | 'form' | 'nav' | 'header' | 'footer' | 'ul' | 'li''div'The element to render.
…restHTMLAttributes<HTMLElement>—className, style, id, aria-* and handlers go on the root element, and so does the ref. A gap in style wins over the gap prop.

Accessibility

  • Row adds no role. Use as="nav" with an aria-label for a bar of links, as="header" or as="footer" for a page region, and as="ul" (with role="list") when the children are a list.
  • justify and align move children but never reorder them, so the reading order and the Tab order follow the DOM. Under dir="rtl" the row mirrors: start is on the right.
  • Keep wrap on for anything that has to fit a 320px screen or 400% zoom. A row that can't wrap pushes its content past the edge instead of reflowing.

Row is a flex row. Children keep their own width and shrink when space runs out; a child holding text can shrink until its longest word, and with wrap on, whole children move to the next line first. For a column use Stack; for a row spread to both ends with a hairline above it, use a List item.