Components/Navigation

Tabs

Tabs are a row of labels that switch a surface between alternative views of itself, one at a time, without leaving the page. The row doubles as the map: it says what else is there before the reader commits to looking. A label carries all of that, so it has to say what its section holds.

import { Tabs } from '@growth-protocol-ai/alpha';

On this page

overflow
Tabs.tsxtsx
1import { Tabs } from '@growth-protocol-ai/alpha';
2
3const ITEMS: readonly TabItem[] = [
11];
12
13<Tabs
14 overflow="collapse"
15 aria-label="Workspace"
16 items={ITEMS}
17 defaultValue="overview"
18/>

When to use

Reach for tabs when one surface holds several alternative views of the same subject and a reader wants one of them at a time — a report’s sections, a record’s detail beside its history. They come into their own once the set is long enough that it will not always fit: the row measures itself and keeps the selection on screen at any width, which is the thing no other switcher in this system does.

When not to use

A row of Buttons is this system’s default sub-navigation, and a short, fixed set of views should stay one — reach for tabs when that row reads too heavy beside the content it sits over, or holds more options than fit it cleanly. Tabs are also not navigation: they change what a surface shows and never the address, so anything that moves the reader to another page belongs in the nav, and a set they can hold several of at once is not a tab row at all.

overflow2 values

What the row does when its container is narrower than its tabs. Collapsing is most of the reason to reach for tabs over a row of buttons once there are more than a handful of options, so it is the default; the alternative is for a short, fixed set, where measuring would be watching something that cannot change.

collapse
none
overflowWhen to use
collapseTabs that no longer fit leave the row and collect behind a trigger in the last slot. Tabs that no longer fit leave the row and collect behind the trigger in declaration order, and the row keeps itself full — so a wide tab can drop out while a narrower one after it stays, and the rest shift into the space it left. Widen the container and they return in order. Widen it again and they come back in order.
noneNothing is measured and there is no trigger. A row too narrow for its tabs scrolls sideways instead, which is only worth having when you already know the set is short.