Breaking: Tabs removed — use TabBar and useTabs
@trackunit/react-components 10.0.0 removes Tabs, TabList, Tab and TabContent, with no compatibility shim. If your app imports any of them, bumping to 10.0.0 is a compile failure until you migrate. Their replacement is useTabs with TabBar and TabPanels, and useRouterTabs from @trackunit/react-router-components for tabs whose selection lives in the URL.
A migration rewrites the usages it can prove equivalent and logs the rest for manual review. Run these two commands in the consuming repo:
npx nx g @trackunit/migrations:migrate
npx nx g @trackunit/migrations:run-migrations
Why this changed
The new tabs are driven by data and use no React context. Each tab's value is written once, in items, and every other use is typed from it, so a misspelled value or a missing panel is a compile error instead of a panel that silently renders nothing. The bar is also quieter: tabs size to their content, and one underline slides to the selected tab.
When it affects you
Nothing changes until you bump the package. From @trackunit/react-components 10.0.0:
// before
<Tabs onValueChange={setTab} value={tab}>
<TabList aria-label="Asset">
<Tab value="overview">Overview</Tab>
<Tab suffix={<Badge color="danger" count={count} />} value="alerts">Alerts</Tab>
<Tab disabled value="settings">Settings</Tab>
</TabList>
<TabContent value="overview"><Overview /></TabContent>
<TabContent value="alerts"><Alerts /></TabContent>
<TabContent value="settings">{settings}</TabContent>
</Tabs>
// after
const tabs = useTabs({
items: [
{ value: "overview", label: "Overview" },
{ value: "alerts", label: <>Alerts<Badge color="danger" count={count} /></> },
{ value: "settings", label: "Settings", disabled: true },
],
value: tab,
onValueChange: setTab,
});
<TabBar aria-label="Asset" tabs={tabs} {...tabs.keyboardProps} />
<TabPanels panels={{ overview: <Overview />, alerts: <Alerts />, settings }} tabs={tabs} />
Router-linked tabs (<Tab asChild> around a TanStack Router Link) become useRouterTabs:
const tabs = useRouterTabs({
items: [
{ value: "connected", label: "Connected", route: "/fleet/connected" },
{ value: "pending", label: "Pending", route: "/fleet/pending" },
],
});
<TabBar aria-label="Fleet" tabs={tabs} {...tabs.keyboardProps} />
Behaviour that changes with the new components:
- Every
TabBarneeds a name,aria-labeloraria-labelledby. It is a compile error without one. - Tab values are typed from
items. Astringstate, prop or URL parameter that feedsvaluehas to be narrowed to the tab values.tabs.parse(raw)narrows a raw string. - "No tab selected" is
undefined, not"". fullWidthis gone. Tabs size to their content.- Inactive panels unmount unless listed in
keepMountedonTabPanels, which replacesforceMount. onValueChangefires for keyboard moves too, and not when the selected tab is clicked again or opened in a new tab. Move analytics fromonClicktoonValueChange.- Tabs never take DOM focus. The tab list is the single tab stop and points at the selected tab with
aria-activedescendant, so tests should assert focus on thetablist. - Disabled tabs use
aria-disabled, not thedisabledattribute, so tests should assertaria-disabledinstead oftoBeDisabled(). useRouterTabsselects the tab that owns the deepest matched route, and the first tab when no tab's route matches. Clicks push a history entry and arrow keys replace it.
What the migration does
The package includes the @trackunit/react-components:v10-0-0-tabs-to-tabbar migration:
- It turns each
Tabinto an item ofuseTabs({ items }), with the children aslabeland asuffixfolded in after them, and movesvalue/onValueChangeordefaultValuetouseTabs.TabListbecomesTabBar, and theTabContents become thepanelsof oneTabPanels. - It narrows a
useState<string>that feedsvalueto the tab values, and turns an empty-string "no selection" intoundefined. - It rewrites router-linked tabs to
useRouterTabsonly when the old selection provably picks the same tab. When it can't prove that, it leaves the file as it was and logs a suggesteduseRouterTabsblock for you to apply. - It adds
@trackunit/react-router-componentsto yourpackage.jsonwhen a file now usesuseRouterTabs.
It leaves these untouched and logs the reason for manual review:
- a
TabBarit can't name: it only derivesaria-labelfrom a single translated heading next to the tabs values typed asstringfrom props or URL parametersonClickon aTabor itsLinkLinkprops other thantoanddata-testid, such assearch,paramsset by hand,activePropsor a spread- router tabs selected by
pathname,location,matchRoute, props or helpers forceMount, nestedTabs, mapped or conditional router tabs, and aTabssplit from itsTabList
The migration doesn't format what it writes: run Prettier on the changed files afterwards. A second run changes nothing.
See the TabBar docs and the useRouterTabs docs for the full API. For the complete update process, see Maintaining Your Application.