Repository navigation
ui v0.15.0
Minor Changes
-
BREAKING CHANGE: Popovers, menus, selects, and comboboxes now render ordinary DOM elements instead of native top-layer popovers. Use the matching Portal component to escape clipping ancestors, and wrap each popup surface in its matching context component, as shown below. The context is required for inline rendering too. (#12170)
Replace
:popover-openstyles with[data-state="open"]. Use[data-open]for styles that should remain during exit animations. Nativebeforetoggleandtoggleevents no longer fire.Place the surface context inside the Portal. Omit the Portal when the surface can remain inline.
Popovers:
import * as popover from '@remix-run/ui/popover' <popover.Context> <button mix={popover.anchor({ placement: 'bottom-start' })}>Open popover</button> - <div mix={popover.surface({ open, onHide })}>Content</div> + <popover.Portal> + <popover.SurfaceContext> + <div mix={popover.surface({ open, onHide })}>Content</div> + </popover.SurfaceContext> + </popover.Portal> </popover.Context> const surfaceStyle = css({ - '&:popover-open': { opacity: 1 }, + '&[data-state="open"]': { opacity: 1 }, })Menus:
import * as menu from '@remix-run/ui/menu' <menu.Context label="Menu"> <button mix={menu.trigger()}>Open menu</button> - <div mix={menu.popover()}> - <div mix={menu.list()}>{/* Items */}</div> - </div> + <menu.Portal> + <menu.PopoverContext> + <div mix={menu.popover()}> + <div mix={menu.list()}>{/* Items */}</div> + </div> + </menu.PopoverContext> + </menu.Portal> </menu.Context>Selects no longer need a separate
popover.Context. Replace it withselect.PopoverContextaround the popup surface:-import * as popover from '@remix-run/ui/popover' import * as select from '@remix-run/ui/select' <select.Context defaultLabel="Choose"> <button mix={select.trigger()} /> - <popover.Context> - <div mix={select.popover()}> - <div mix={select.list()}>{/* Options */}</div> - </div> - </popover.Context> + <select.Portal> + <select.PopoverContext> + <div mix={select.popover()}> + <div mix={select.list()}>{/* Options */}</div> + </div> + </select.PopoverContext> + </select.Portal> </select.Context>
Comboboxes:
import * as combobox from '@remix-run/ui/combobox' <combobox.Context> <input aria-label="Combobox" mix={combobox.input()} /> - <div mix={combobox.popover()}> - <div mix={combobox.list()}>{/* Options */}</div> - </div> + <combobox.Portal> + <combobox.PopoverContext> + <div mix={combobox.popover()}> + <div mix={combobox.list()}>{/* Options */}</div> + </div> + </combobox.PopoverContext> + </combobox.Portal> </combobox.Context>DOM events, form ownership, and inherited styles follow the Portal destination.
Popups no longer use the browser's top layer. Wrap your app content in an element with
css({ isolation: 'isolate' })so popups portaled todocument.bodyappear above the app's z-index layers. For other layering setups,--rmx-layer-basecan optionally raise the dialog and popup stack. It defaults to0. -
BREAKING CHANGE: Removed the selection flash from
select,comboboxandlistbox, along with APIs for delaying selection feedback. (#12262)Select and Combobox
selectandcomboboxnow show the chosen label while the popup starts closing, without waiting for a selection flash or label delay. Their change events fire after the displayed label and hidden form value update, so handlers can read the new value fromFormDatabefore closing finishes.comboboxalso selects the input text immediately.select.Contextno longer acceptslabelSwapDelayMs, since the selected label now updates immediately. Remove the prop when upgrading:-<select.Context defaultLabel="Select a type" labelSwapDelayMs={100} name="issueType"> +<select.Context defaultLabel="Select a type" name="issueType">
The
data-select-flashanddata-combobox-flashattributes are no longer set. Remove their CSS rules; existing selected and highlighted styles continue to apply:css({ '&[aria-selected="true"]': { background: 'var(--selected-background)' }, - '&[data-select-flash]': { background: 'var(--flash-background)' }, - '&[data-combobox-flash]': { background: 'var(--flash-background)' }, })Custom Listboxes
listbox.Contextno longer acceptsflashSelection,selectionFlashAttributeoronSelectSettled. Move work fromonSelectSettledintoonSelect, which runs synchronously:<listbox.Context value={value} activeValue={activeValue} - flashSelection - onSelect={onSelect} - onSelectSettled={(value, option) => saveSelection(value, option?.label)} + onSelect={(value, option) => { + onSelect(value, option) + saveSelection(value, option?.label) + }} onHighlight={onHighlight} >onSelectreceives the new selection before your component renders the updated value. Use itsvalueandoptionarguments for selection-dependent work, as above. If your oldonSelectSettledcallback read rendered DOM or form fields, wait for your component's update before reading them:<listbox.Context value={value} activeValue={activeValue} - onSelect={(nextValue) => { + onSelect={async (nextValue) => { value = nextValue - handle.update() + await handle.update() + saveForm(new FormData(form)) }} - onSelectSettled={() => saveForm(new FormData(form))} onHighlight={onHighlight} >ListboxRef.select()andListboxRef.selectActive()now returnvoidinstead of a promise. Listbox continues accepting selection and highlight requests while async callbacks run. If selecting closes your custom popup, use its open state to ignore further selection and highlight requests until it reopens. Setopen = falsebefore any awaited work:<listbox.Context value={value} activeValue={activeValue} onSelect={(nextValue) => { + if (!open) return + open = false value = nextValue void handle.update() }} onHighlight={(nextActiveValue) => { + if (!open) return activeValue = nextActiveValue void handle.update() }} >selectandcomboboxalready handle this themselves.The
data-listbox-flashattribute is no longer set. Remove its CSS rule; existing selected and highlighted styles continue to apply:css({ '&[aria-selected="true"]': { background: 'var(--selected-background)' }, - '&[data-listbox-flash]': { background: 'var(--flash-background)' }, }) -
animateExit()from@remix-run/ui/animationnow accepts a callback(node) => configevaluated lazily when removal begins. This lets an exiting keyed element read updated parent state or measure the DOM at exit time instead of using potentially stale values from its last render, or returnfalse,null, orundefinedto skip the exit animation. (#12481)import { animateExit } from '@remix-run/ui/animation' function TabPanel() { return () => ( <div key={activeTab} mix={animateExit((node) => { if (!shouldAnimate) return false return { opacity: 0, translate: `${direction * node.offsetWidth}px 0`, duration: 200, easing: 'ease-in', } })} /> ) }
-
Added
@remix-run/ui/dialogwith providers and mixins for accessible dialogs. (#12170)
Patch Changes
-
Keep IME candidate navigation and confirmation from selecting combobox options, dismissing the popup, or moving the active option. This includes Safari's confirming Enter key after composition ends. (#12415)
-
Fix
anchor()positioning and scroll tracking for fixed-position floating surfaces inside positioned or transformed ancestors. (#12396) -
Keep page scrolling locked across top-frame reloads while popovers, menus, selects or comboboxes are open. (#12260)
-
Escape and outside clicks now dismiss only the topmost popup in nested menus and dialogs. Keyboard input inside a nested popup no longer activates the parent menu, and closing a parent also closes its nested popups. (#12170)
-
Popovers no longer move focus back to the
focusOnHide()target when another control outside the popover and its nested surfaces already holds focus, including when focus moves during exit animations. (#12470) -
Pressing tab or shift+tab in an open Select now closes the popup and moves focus through the form instead of keeping it in the list. (#12170)
-
Timed toasts with
countdown: trueno longer report errors in browsers withoutCSS.registerProperty(), including Firefox 125–127. The countdown animation is skipped while timers, pausing, and dismissal continue normally. (#12370) -
Bumped
@remix-run/*dependencies: