Mantle Select Owned Behavior Migration Guide
Select no longer uses @radix-ui/react-select. Mantle's own behavior hooks drive it, and they follow the WAI-ARIA select-only combobox pattern. The parts, the value and open props, the keyboard, and the data attributes stay the same. Three things change:
Select.Contenttakes no positioning props. The list opens below the trigger, or above it when the space below is too small.- The list stays modal, as it was with Radix: the page does not scroll and the rest of the page is inert while it is open. Tab no longer moves focus out of an open list. Pick with Enter, or close with Escape.
- The
--radix-select-*CSS variables are gone.--anchor-width,--anchor-height, and--available-heightreplace them.
Select costs 18.5 KB gzip in place of 43.2 KB (React external).
TL;DR: Delete the positioning props from Select.Content (position, side, sideOffset, align, and the other Radix Popper props). Delete onEscapeKeyDown, onPointerDownOutside, and onCloseAutoFocus from Select.Content, and move what they did to onOpenChange on Select.Root. Replace --radix-select-trigger-width with --anchor-width and --radix-select-content-available-height with --available-height. In tests, drop { hidden: true } from queries that it only added for an open select.
Codemod
From a mantle checkout:
In a project that installs @ngrok/mantle:
The rules apply step 2. They delete each positioning prop from Select.Content, for a Select import from @ngrok/mantle/select under its own name or an alias. A function that binds Select to a parameter or a local shadows the import, so the rules leave that function alone. Steps 3 to 5 stay manual: an event handler's job must move to a new place, and a CSS variable or a test query is a string, not syntax. The codemod is safe to run more than once. Pass --dry-run to print the rewrites first, and run your formatter after the rewrite.
You are an agent migrating a codebase. Do this:
- Find every
Select.Content(a part of@ngrok/mantle'sSelect). Search for the name, and for a renamed import (import { Select as MantleSelect }). - Delete these props from
Select.Content:position,side,sideOffset,align,alignOffset,avoidCollisions,collisionBoundary,collisionPadding,arrowPadding,sticky,hideWhenDetached, andupdatePositionStrategy. KeepwidthandclassName. - Find
onEscapeKeyDown,onPointerDownOutside,onInteractOutside,onFocusOutside,onCloseAutoFocus, andforceMountonSelect.Content. The type checker names each one. Delete each prop. When the handler ran code on close, move that code toonOpenChangeonSelect.Rootand run it whenopenisfalse. When the handler calledevent.preventDefault()to keep the list open, controlopeninstead. - Search class strings and CSS for
--radix-select-. Replace--radix-select-trigger-widthwith--anchor-width,--radix-select-trigger-heightwith--anchor-height, and--radix-select-content-available-heightwith--available-height. Delete a--radix-select-content-transform-originread: no variable replaces it. - In tests, find queries that pass
{ hidden: true }only because Radix hid the trigger while the list was open, such asgetByRole("combobox", { hidden: true }). Delete the option. Also check adata-sideassertion: it is now only"top"or"bottom". - After editing, run the project's formatter, linter, type checker, and tests.
Why own the behavior? Radix Select and Ariakit's combobox each shipped their own selection state, focus, dismissal, and positioning, so a page with both paid for two copies. Mantle's
useListboxhook now holds that behavior once forSelect, andComboboxandMultiSelectmove to it next. The list stays modal, and the page behind it isinert, so the trigger that keeps focus stays exposed to screen readers.
Before → after
Positioning props
A close handler
A CSS variable
Edge cases & gotchas
- DOM focus stays on the trigger while the list is open.
aria-activedescendanton the trigger names the highlighted option. A test that readdocument.activeElementas the highlighted option now reads the trigger: usearia-activedescendantor the option'sdata-highlightedinstead. - A server-rendered page now shows the selected item's text in its first paint.
Select.Valuereads it from theSelect.Itemelements. When a component of your own renders the item, pass the text aschildrenofSelect.Value. Select.Value asChildnow merges the value's props onto your element.- Inside a
Dialog, the first Escape closes the list and the second closes the dialog, as before.
How to verify
Run rg "radix-select" and rg "Select.Content[^>]*(position|side|align)=" in the app. Both must find nothing. Run the type checker, which names each prop that Select.Content no longer takes. Open a page with a select near the bottom of the window: the list opens above the trigger.