Searching Puzzle Pieces

Type to search Puzzle Pieces.

Tabs

A tablist and its panels. It is a compound family that wraps the @magic-spells/tab-group web component, so the roving tabindex, the arrow/Home/End keyboard model, the disabled-tab skipping, panel visibility and every role, id and aria attribute come from the component rather than from a hand-rolled copy in this file.

AccountPasswordTeamUpdate your display name and the address we send receipts to. The body is real markup — this paragraph, a form, or any other piece.Change your password. We will sign every other session out when you do.Invite teammates and choose what each of them can see.

Installation

Copy the family into your app:

puzzle add piece tabs

It has one runtime dependency — the web component it wraps:

npm install @magic-spells/tab-group

Then merge its stylesheet into your app's style entry. It is required, and for one rule above all: tab-panel[hidden] is what actually hides an inactive panel. Without it every panel renders at once.

/* app/styles/styles.css */
@import "tailwindcss";
@import "@magic-spells/tab-group/css" layer(components); /* required */

Requires the pieces.css tokens merged into your app styles (see Introduction).

Usage

import Tabs from '@/components/ui/Tabs';
<Tabs value={ tab } @change={ setTab }>
  <Tabs.List>
    <Tabs.Tab value="account">Account</Tabs.Tab>
    <Tabs.Tab value="password">Password</Tabs.Tab>
  </Tabs.List>
  <Tabs.Panel value="account">…real markup…</Tabs.Panel>
  <Tabs.Panel value="password">…real markup…</Tabs.Panel>
</Tabs>

Tabs and panels pair by position, not by value: upstream matches the nth tab-button to the nth tab-panel. Render one panel per tab in the same order — the root warns in the console if the two sequences diverge. If both come from a loop, drive both from the same array so the counts can never disagree mid-patch.

Pill variant

DayWeekMonth1,284 sessions today.9,120 sessions this week.38,447 sessions this month.

Disabled tab

GeneralBillingAdvancedArrow keys skip Billing entirely — it is not clickable and not reachable.Unreachable.Danger zone. Nothing here is reversible.

Controlled value

OneTwoThreeFirst panel.Second panel.Third panel.
value = one

Focus this input first, then press the button: activating a tab programmatically never moves focus, so the caret stays here.

Tabs from a loop

BriefSpecsThe one-page summary everyone actually reads.Numbers, tolerances and the things that break.

Nested tabs

OverviewDetailsInner oneInner twoThe inner group's tabchange is filtered out of the outer root by target.And the outer group's lookup is scoped, so it never sees these buttons.Nothing nested here.

Reference

Tabs

valueControlled: the active tab’s value string. Edge-triggered, and re-applied when the tab set changes.
defaultValueUncontrolled seed, applied once at mount — before the upgrade, so the first paint has no flash.
variant'underline' (default) | 'pills' | 'buttons'. Stamped as data-variant for the members to read.
classMerged onto the tab-group host. A gap-* here replaces the default 16px list-to-panel gap.
@change(value)Value-first, once per activation. A nested group’s bubbling tabchange is filtered out by target.

Tabs.List

classMerged onto tab-list, after the chrome. Must be a direct child of Tabs, with the tabs as its direct children.

Tabs.Tab

valueRequired. Carried as data-value; the root maps it to the index upstream works in.
disabledNot clickable and skipped by arrow-key roving. Driving `value` to a disabled tab is refused, with a console warning.
classMerged onto tab-button, after the chrome. The selected look hangs off the component’s own aria-selected.

Tabs.Panel

valueRequired, and must match the Tabs.Tab at the same position — upstream pairs them positionally.
classRendered on tab-panel. Never a display utility: it would outrank tab-panel[hidden] and leave every panel visible.

The variant is stamped as data-variant on the root and read by the members through a descendant selector, because Puzzle has no cross-component context to pass it down as a prop. One consequence: a nested Tabs with a different variant collides, since the match has equal specificity at both depths. Give the inner members their own class with the ! suffix (gap-4!) to escape it.