Mantle Tabs Owned Behavior Migration Guide
@ngrok/mantle's Tabs and the CodeBlock tab parts no longer use @radix-ui/react-tabs. Mantle owns the WAI-ARIA tabs behavior. The parts, their props, and their data-* attributes stay the same. A Radix Tabs part that you render inside a mantle Tabs.Root no longer finds a Radix context, so it throws on render.
TL;DR: Find each Trigger, List, or Content from @radix-ui/react-tabs (or a local wrapper around one) that renders inside a mantle Tabs.Root or CodeBlock.Root. Replace it with the mantle part of that root: Tabs.Trigger, Tabs.List, or Tabs.Content under Tabs.Root, and CodeBlock.TabTrigger, CodeBlock.TabList, or CodeBlock.TabContent under CodeBlock.Root. Keep your classes. Then remove @radix-ui/react-tabs from your dependencies if nothing else imports it.
Codemod
Codemod: manual: the Radix part usually sits in a local wrapper component, and a rule cannot see that the wrapper renders inside a mantle Tabs.Root.
You are an agent migrating a codebase. Do this:
- Find every import from
@radix-ui/react-tabs. Include a namespace import (import * as Tabs from "@radix-ui/react-tabs") and a local wrapper that renders a Radix part, such as aTabsTriggerin~/components/tabs-trigger. - Keep only the parts that render inside a mantle
Tabs.Root(from@ngrok/mantle/tabs) orCodeBlock.Root(from@ngrok/mantle/code-block). A Radix part inside a RadixRootstill works. Leave it alone. - Under
Tabs.Root, replace each RadixTriggerwithTabs.Trigger. Keepvalue,disabled,id,className, and the children.Tabs.Triggeralready focuses a pressed tab without the focus ring, so delete a wrapper'sonMouseDownthat callsfocus({ focusVisible: false }). - Under
CodeBlock.Root, useCodeBlock.TabList,CodeBlock.TabTrigger, andCodeBlock.TabContentinstead. ATabspart there throws, becauseCodeBlock.Rootprovides noTabs.Rootcontext. Tabs.Triggeradds mantle's trigger classes and an underline decoration for theclassicappearance. YourclassNamemerges after them, so a conflicting class of yours wins. To drop the underline, setappearance="pill"on the root and give each trigger its own classes.data-state="active"anddata-state="inactive"stay on the trigger, sodata-state-active:anddata-[state=active]:classes keep working.- Replace a Radix
ListorContentthe same way, withTabs.ListorTabs.Content. - Delete the wrapper file when nothing imports it. Remove
@radix-ui/react-tabsfrompackage.jsonwhen nothing imports it. - After editing, run the project's formatter, linter, type checker, and tests.
Why own the behavior? Radix Tabs shipped its own roving focus, collection, and presence code for a pattern that needs one key handler and two ids per tab. On its own, the
Tabsentry now ships 6 KB (gzip) less. The mantle version also puts the active tab in the Tab order in the server HTML, follows a right-to-left page's arrow keys, and addshiddenUntilFoundfor find-in-page.
Before → after
A Radix trigger wrapper inside mantle Tabs
Edge cases & gotchas
- Right-to-left pages. Radix set
dir="ltr"on the root, so the arrow keys moved left to right in a right-to-left page. The root now setsdironly when you pass it, and in a right-to-left page ArrowLeft moves to the next tab. - Tab order before hydration. The server HTML now puts the active tab in the Tab order. After hydration, the tab list is the entry point for a forward Tab, as in Radix, and moves focus to the active tab.
- Exit animations. An inactive panel hides at once. Radix kept a panel mounted while a CSS exit animation on it ran. No ngrok app animates a tab panel's exit. Animate the entering panel instead.
- Force-mounted panels for crawlers. A page that force-mounts every panel and hides the inactive ones with
data-[state=inactive]:hiddencan use<Tabs.Content hiddenUntilFound>instead. The text stays in the HTML, and find-in-page reveals it. Delete thehiddenclass:display: noneblocks the search.
How to verify
- The page renders with no "must be used within
Tabs" error. getAllByRole("tab")finds every trigger, and the arrow keys move between them.- Nothing imports
@radix-ui/react-tabs, or only code inside a RadixRootdoes.