Mantle Data Attribute Contract Migration Guide
@ngrok/mantle no longer emits the data-* names it took from Radix, Ariakit, and Headless UI. Each part emits one mantle-owned set of attributes:
- Native and ARIA state first. A trigger has
aria-expanded, a tab and a listbox option havearia-selected, a checkable item hasaria-checked, and a disabled control hasdisabledoraria-disabled. None of them carries adata-stateordata-disabled. - A boolean state is a presence attribute. It is
""when true and absent when false:data-open,data-expanded,data-highlighted,data-selected,data-placeholder,data-loading,data-indeterminate,data-engaged. No attribute is ever"true"or"false". - A value with several options stays an enum:
data-side="top",data-validation="error",data-orientation="vertical"(on a root only),data-appearance. mantle.cssregisters nodata-*variants.data-state-open:,data-side-top:,data-validation-error:,data-orientation-vertical:, anddata-active-item:are gone. Use Tailwind's built-in forms.
TL;DR: Run the codemod. It rewrites the old class variants and the data-state test assertions. Then search for data-state, data-disabled, data-align, data-current, and data-active in your code, and fix what is left by hand with the table in step 2.
Codemod
From a mantle checkout:
In a project that installs @ngrok/mantle:
The rules apply steps 2 and 4. They rewrite class strings in JSX, cx and cva calls, template strings, and constants:
data-state-open:becomesaria-expanded:in theclassNameof a part whose name ends inTriggerand of theasChildelement inside it.group-data-state-open:becomesgroup-aria-expanded:inside that part's children. Everywhere else,data-state-open:becomesdata-open:anddata-state-closed:becomesnot-data-open:.data-state-checked:becomesaria-checked:(aria-selected:on aSelect.Item),data-state-active:becomesaria-selected:, anddata-state-selected:becomesdata-selected:. On a trigger,data-state-inactive:becomesnot-aria-selected:.data-state-indeterminate:becomesdata-indeterminate:, oraria-[checked=mixed]:on aCheckboxItem.data-side-*:,data-orientation-*:, anddata-validation-*:become the bracket form, such asdata-[side=top]:. On aTabs.List,data-orientation-*:becomesaria-[orientation=*]:.data-active-item:becomesdata-highlighted:.- In a file that imports
@radix-ui/*, everydata-state-*:becomesdata-[state~=*]:, so classes on your own Radix parts keep their match. The test rules skip that file. expect(el).toHaveAttribute("data-state", "open")becomestoHaveAttribute("data-open"), and"closed"becomes.not.toHaveAttribute("data-open")."expanded"and"collapsed"map todata-expandedthe same way.
The rules read text, not the part a class lands on. A class string that one file builds and another file applies, a group- variant whose group is not the nearest Trigger, and selectors in CSS files stay manual: step 3 lists them. The codemod is safe to run again. Pass --dry-run to print the rewrites first, and run your formatter after the rewrite.
You are an agent migrating a codebase. Do this:
-
Run the codemod over the whole project, including tests and docs.
-
Search for what is left:
rg -n 'data-state|data-\[state|data-disabled|data-align|data-current|data-active\b|data-side-|data-validation-|data-orientation-'. Fix each match that reads a mantle part with this table:Leave
data-statealone on an element that you or a third-party library renders, such as your own Radix component. -
Fix the shapes the codemod cannot place:
- A
group-data-open:orgroup-not-data-open:whosegroupclass is on a trigger. Usegroup-aria-expanded:andgroup-not-aria-expanded:. - A class constant in one file that another file passes to a trigger. Use
aria-expanded:, notdata-open:. - An exit on a
Dialog,AlertDialog, orSheetpart keyed onnot-data-open:. These parts adddata-closingwhile the exit plays, so key the exit ondata-closing:. A dialog that an invoker command opens before hydration has nodata-open, andnot-data-open:plays the exit on it. - Selectors in
.cssfiles andquerySelectorstrings.
- A
-
Update tests that read the old attributes:
- Assert a trigger with
toHaveAttribute("aria-expanded", "true"). - Assert a tab or an option with
aria-selected, a menu checkbox item or a switch witharia-checked, and a disabled item witharia-disabled. - Assert a presence attribute with
toHaveAttribute("data-open"), nottoHaveAttribute("data-open", "true").data-drag-over,data-x-overflow,data-x-scroll-end,data-sticky-active,data-disabled, anddata-engagedare now""when true and absent when false. - A Progress part drops
data-value,data-min, anddata-max. Readaria-valuenow,aria-valuemin, andaria-valuemax.data-indeterminatereplacesdata-state="indeterminate". CodeBlock.Codehasdata-syntax-highlightedin place ofdata-highlighted="true".
- Assert a trigger with
-
After editing, run the project's formatter, linter, type checker, and tests.
Why one contract? Each library brought its own names, so the same state had three spellings and a reader could not tell a Tailwind built-in from a mantle extension. ARIA state is already on the element for assistive tech, so styling from it costs nothing and cannot drift from what a screen reader hears. A presence attribute matches Tailwind's built-in
data-*:variant directly, so mantle needs no custom variants.
Before → after
A trigger and its icon
Overlay content
Validation
Tabs
Tests
Edge cases & gotchas
data-slotdoes not change. Selectors such as[data-slot~="dialog-content"]keep working.data-opengoes away when the exit starts, sonot-data-open:styles the exit frame of a floating part. The part unmounts after its exit animation.Sidebar.Navin the mobile sheet always hasdata-expanded, because the sheet is always at full width. The sheet also hasdata-openanddata-closing.- A Tooltip or HoverCard trigger carries no state attribute: it does not expand anything.
- A
Tabs.ContentwithhiddenUntilFoundgetshidden="until-found"while inactive, so find-in-page can reach it. Ahiddenclass (display: none) on that panel blocks the search. Combobox.Itemkeepsaria-selectedon the highlighted row, as the ARIA combobox pattern requires. The chosen row hasdata-selected.
How to verify
The first search finds nothing. Each match of the second search reads an element that mantle does not render. Then run the type checker and the tests.