Cluster
ExperimentalA row of items that wraps to the next line when it runs out of room.
Also known as hstack, inline, wrap, flex row
Install with npm install @tattva/ui (setup), or copy the code from the kit in Downloads.
Tags that wrap
<Cluster gap={2}>
<Badge>Draft</Badge>
<Badge>Shared</Badge>
<Badge>Reviewed</Badge>
</Cluster>When to use it
A row of small things that wraps onto the next line instead of running off the edge. Nothing is hidden or squeezed, so tags and buttons stay readable at any width.
Made of: Outer box · Items · Push apart
Do and avoid
Do
- Use it for groups that can wrap, such as tags and filters.
- Keep the space smaller than the space between groups.
- Use a real list for a set of related links or tags.
- Line up the text bottoms when text sizes differ.
Avoid
- Do not use it for form columns. Use Grid.
- Do not force one line and hide what does not fit.
- Do not count on the order changing when items wrap.
- Do not put long paragraphs inside as items.
On a phone
- Items wrap onto the next line when they do not fit, so a row of chips or actions never runs off a phone screen.
- The gap stays the same, and buttons inside a wrapped row keep their size and have a 44px tap area on a touch screen.
Seen in products
- NN/g notes that items close together read as a group and that stacking on a phone can break groups.
- Accessibility guidelines ask that text can grow to 200% without sideways scrolling.
Properties
| Prop | Type | Default | Description |
|---|---|---|---|
| gap | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 2 | Gap step on the 4px grid, scaled by --density. |
| align | "start" | "center" | "end" | "baseline" | "center" | Cross-axis alignment. |
| justify | "start" | "center" | "end" | "between" | "start" | Main-axis distribution. |
| as | "div" | "ul" | "ol" | "nav" | "section" | "header" | "footer" | "div" | Element to render. |
"Show code under the preview gives the code for the example on the stage."
In Figma
In Figma, one Cluster switches all of this from its properties panel, across 4 variants. Each property sets the React prop beside it, so design and code use the same names.
| Figma property | React | Values |
|---|---|---|
| Justify | justify | Start, Center, End, Between |
Tokens
Change one of these and every part that uses it follows.
--density
Built in
- It adds no meaning of its own: it renders the element you choose.
- As a ul or ol it is still announced as a list, even though the bullets are removed.
- Items wrap to the next line instead of overflowing, so nothing needs sideways scrolling when text is zoomed.
- Wrapping keeps the order of your code, so screen readers and the keyboard follow the same order.
What you need to do
- Set as to ul or ol when the items are a list, and wrap each item in li.
- Set as to nav when the row is a set of links for moving around.
Built toward WCAG 2.2 AA and checked automatically; no independent audit yet. Read the accessibility guide