Mantle Native Floats Migration Guide
@ngrok/mantle's Popover, Tooltip, and HoverCard no longer use Radix. Each content part is a native popover in the browser's top layer, and CSS anchor positioning places it next to its trigger. Where the browser has no anchor positioning, a small script places it. The Radix positioning props, Popover.Root's modal prop, HoverCard.Portal, and the --radix-popover-* CSS variables are gone. Popover.Content and HoverCard.Content no longer take asChild, and Tooltip.Content no longer takes id. The part names and the other props stay the same.
TL;DR: Delete collisionPadding, collisionBoundary, sticky, avoidCollisions, alignOffset, hideWhenDetached, forceMount, updatePositionStrategy, and arrowPadding from Popover.Content, Tooltip.Content, and HoverCard.Content. Delete modal from Popover.Root. Unwrap HoverCard.Portal. Replace --radix-popover-trigger-width with --anchor-width and --radix-popover-content-available-height with --available-height. TooltipProvider is now optional.
Codemod
From a mantle checkout:
In a project that installs @ngrok/mantle:
The rules apply steps 2 to 5. They delete the Radix positioning props from the three content parts, delete modal from Popover.Root, replace HoverCard.Portal with a fragment, and rename the two CSS variables in each string of a file that imports @ngrok/mantle/popover. The rules read a part through its import from @ngrok/mantle/<subpath>, under its own name or an alias. A function that binds the part's name to a parameter or a local shadows the import, so the rules leave that function alone. A variable in a file that does not import Popover, such as a shared class constant or a stylesheet, stays manual. Steps 6 and 7 stay manual, because they are choices for each call site and test queries, not syntax. 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:
- Find every
Popover,Tooltip, andHoverCardpart from@ngrok/mantle. Search forPopover.,Tooltip., andHoverCard., and for a renamed import of the same parts (import { Popover as MantlePopover }). - On
Popover.Content,Tooltip.Content, andHoverCard.Content, deletecollisionPadding,collisionBoundary,sticky,avoidCollisions,alignOffset,hideWhenDetached,forceMount,updatePositionStrategy, andarrowPadding. Keepside,align, andsideOffset. The content flips to the opposite side when only that side fits, and shifts to stay 8px inside the viewport. - On
Popover.Root, deletemodal. When the popover must block the page, trap focus, and lock scroll, useDialoginstead. - Replace
<HoverCard.Portal>…</HoverCard.Portal>with its children.HoverCard.Contentportals by itself, into the content of the open overlay or popover that holds it, else intodocument.body. - Replace
--radix-popover-trigger-widthwith--anchor-width, and--radix-popover-content-available-heightwith--available-height, in class strings and stylesheets.Popover.Contentsets both variables. The codemod changes only the props ofPopover.Contentitself; change shared strings,cvavariants, and stylesheets by hand, and leave the variables of a RadixPopoverthat you import yourself. - Remove
asChildfromPopover.ContentandHoverCard.Content. Move the child element's props, such asclassName, onto the content, and render the child's own content aschildren. - Remove
idfromTooltip.Content. The trigger'saria-describedbypoints at the id thatTooltip.Rootowns. Select the tooltip with[data-slot="tooltip-content"]instead. - Delete a
TooltipProviderthat you mounted only becauseTooltip.Rootthrew without one. Keep a provider that setsdelayDuration,skipDelayDuration, ordisableHoverableContent. - Update tests that read the old shape:
- A float no longer carries
z-50in browsers with the popover API. Assertpopoveron the content instead. - A float inside a
Popoverportals intoPopover.Content, not next to it. Tooltip.Trigger asChildandHoverCard.Trigger asChildjointooltip-triggerorhover-card-triggerahead of the child'sdata-slot, asPopover.Triggerdoes.- A closed float stays in the DOM for its 150ms exit transition. Wait for it to go.
- A float no longer carries
- After editing, run the project's formatter, linter, type checker, and tests.
Why native popovers? The top layer paints a float above every
z-indexwith no stacking rules to learn, and CSS anchor positioning lets the browser keep it next to its trigger. The three components ship less JavaScript and no Radix dependency. A browser with no popover API (Safari before 17, Chrome before 114, Firefox before 125) shows the float as a fixed box atz-50, as before.
Before → after
Radix positioning props
A modal popover
HoverCard.Portal
The Radix CSS variables
Edge cases & gotchas
- A float does not show while an overlay that does not hold it is open, because the top layer would paint it over that overlay. A tooltip or hover card closes. A popover hides, and shows again when the overlay closes.
Popover.Contentis a layer container. ASelect,DropdownMenu, or other float inside it portals into it, so it paints above the popover.- A press or a focus move outside a popover closes it and leaves focus where the user put it.
onPointerDownOutside,onFocusOutside, andonInteractOutsidestill get a cancelable event withevent.detail.originalEvent. - A
DropdownMenuis still a Radix menu, and a modal one keeps focus inside the menu. A popover opened from a menu item takes clicks but not keyboard focus. Setmodal={false}on thatDropdownMenu.Root. - A float in the top layer paints above toasts, which stay at
z-index: 999999999in the page. Do not open a popover over the toast corner. HoverCard.Triggerrenders an<a>. It opens on hover and on keyboard focus, and not on touch.
How to verify
The search finds nothing in code that uses the three components. Run the type checker, which flags each removed prop the codemod could not reach, then the tests.