Releases: tailwindlabs/headlessui
@headlessui/[email protected]
Fixed
- Fix prematurely added anchoring styles on
ListboxOptions(#3337) - Ensure
unmountonDialogworks in combination with thetransitionprop onDialogBackdropandDialogPanelcomponents (#3352) - Fix crash in
Comboboxcomponent when invirtualmode when options are empty (#3356) - Fix hanging tests when using
anchorprop (#3357) - Fix
transitionandfocusprop combination forPopoverPanelcomponent (#3361) - Fix outside click in nested portalled
Popovercomponents (#3362) - Fix restoring focus to correct element when closing
Dialogcomponent (#3365) - Fix
flushSyncwarning forComboboxcomponent withimmediateprop enabled (#3366)
@headlessui/[email protected]
@headlessui/[email protected]
We just released Headless UI v2.1 for React, which dramatically simplifies our transition APIs and adds support for rendering multiple dialogs as siblings. See our announcement blog to learn more.
Changelog
Added
- Add ability to render multiple
Dialogcomponents at once (without nesting them) (#3242) - Add new data-attribute-based transition API (#3273, #3285, #3307, #3309, #3312)
- Add
DialogBackdropcomponent (#3307, #3310) - Add
PopoverBackdropcomponent to replacePopoverOverlay(#3308)
Fixed
- Keep
Comboboxopen when clicking scrollbar inComboboxOptions(#3249) - Ensure
ComboboxInputdoes not sync with current value while typing (#3259) - Fix visual jitter in
Comboboxcomponent when using native scrollbar (#3190) - Improve UX by freezing
ComboboxOptionswhile closing (#3304) - Merge incoming
styleprop onComboboxOptions,ListboxOptions,MenuItems, andPopoverPanelcomponents (#3250) - Prevent focus on
Checkboxwhen it isdisabled(#3251) - Use
useIdinstead of React internals (for React 19 compatibility) (#3254) - Cancel outside click behavior on touch devices when scrolling (#3266)
- Correctly apply conditional classes when using
TransitionandTransitionChildcomponents (#3303)
Changed
- Allow using the
TabandShift+Tabkeys when theListboxcomponent is open (#3284)
@headlessui/[email protected]
@headlessui/[email protected]
Fixed
- [internal] Don’t set a focus fallback for Dialog’s in demo mode (#3194)
- Ensure page doesn't scroll down when pressing
Escapeto close theDialogcomponent (#3218) - Fix crash when toggling between
virtualand non-virtual mode inComboboxcomponent (#3236) - Ensure tabbing to a portalled
PopoverPanelcomponent moves focus inside (without usingPortalGroup) (#3239) - Only handle form reset when
defaultValueis used (#3240)
Deprecated
- Mark
SwitchGroupas deprecated, preferFieldinstead (#3232)
Changed
- Use native
fieldsetinstead ofdivby default forFieldsetcomponent (#3237)
@headlessui/[email protected]
@headlessui/[email protected]
Fixed
- Make sure disabling demo mode on
Comboboxworks (#3182)
@headlessui/[email protected]
Fixed
- Improve performance of internal
useInertOthershook (#3181)
@headlessui/[email protected]
Fixed
- Remove accidental deprecation comments on
DialogPanelandDialogTitle(#3176)
@headlessui/[email protected]
We just released Headless UI v2.0 for React which includes a ton of new stuff:
- Built-in anchor positioning — using Floating UI, components like
Menu,Listbox, and more can now automatically position their popovers to be anchored to their trigger, adapting as needed to changes in the viewport. - Headless checkbox component — we've added a headless
Checkboxcomponent to complement our existingRadioGroupcomponent, making it easy to build totally custom checkbox controls. - HTML form components — we've added
Input,Select,Textarea,Label,Description,Fieldset, andLegendcomponents that handle all of the ID generation andaria-*attribute mapping you need to do to connect form fields together. - Improved hover and focus-visible detection — using hooks from the awesome React Aria library under the hood, Headless UI now adds smarter
data-hoveranddata-focusattributes to your controls that behave more consistently across different devices than the native pseudo-classes. - Combobox list virtualization — the
Comboboxcomponent can now handle giant lists of options with no performance issues.
Changelog
Added
- Add new
Checkboxcomponent (#2887, #2962) - Add new
Buttoncomponent (#2887) - Add new
Inputcomponent (#2887, #2902, #2940) - Add new
Textareacomponent (#2887, #2902, #2940) - Add new
Selectcomponent (#2887, #2902) - Add new
FieldsetandLegendcomponents (#2887) - Add new
Field,Label,Descriptioncomponents (#2887, #2941) - Add new
MenuSection,MenuHeading, andMenuSeparatorcomponents (#2887) - Add new
ListboxSelectedOptioncomponent (#2887) - Add new
DataInteractivecomponent (#2887) - Add new
CloseButtoncomponent anduseClosehook (#3096) - Add new
anchor,modal, andportalprops toCombobox,Listbox,MenuandPopovercomponents (#2887, #3075, #3097, #3111, #3115, #3121, #3124, #3133, #3138, #3148, #3152, #3154, #3157) - Add new
autoFocusprop to focusable components (#2887) - Add new
virtualprop toComboboxcomponent (#2779, #3128, #3160, #3161, #3163) - Add new
onCloseprop toComboboxcomponent (#3122) - Add new
immediateprop toComboboxfor immediately opening the Combobox when theinputreceives focus (#2686) - Add new
--button-widthCSS variable on theListboxOptions,MenuItems, andPopoverPanelcomponents (#2887, #3058) - Add new
--input-widthand--button-widthCSS variables on theComboboxOptionscomponent (#3057) - Add new
data-*attributes as an alternative to the existingdata-headlessui-stateattribute (#2887, #3035, #3061)
Fixed
- Fix scroll-locking on iOS (#2891)
- Fix cancellation of events when using
disabledoraria-disabledattributes (#2890) - Fix unnecessary execution of the
displayValuecallback inComboboxInputcomponent (#3048) - Fix types for
multipleprop inComboboxcomponent (#3099) - Fix focus handling in
ComboboxInputcomponent (#3065, #3073) - Fix enter transitions in
Transitioncomponent (#3074) - Fix focus handling in
ListboxOptionsandMenuItemscomponents (#3112) - Fix horizontal scrolling inside the
Dialogcomponent (#2889)
Changed
- Require React 18 (#2887, #3092, #3131)
- Always render hidden form input fields for
Checkbox,SwitchandRadioGroupcomponents (#3095) - Deprecate the
RadioGroup.Optioncomponent in favor of newRadiocomponent (#2887) - Deprecate the
activeprop in favor of newfocusprop (#2887) - Dialog is now focused by default instead of the first focusable element (#2887)
- Change default tags for
ListboxOptions,ListboxOption,ComboboxOptions,ComboboxOption, andTabGroupcomponents (#3109) - Change default tag from
divtoFragmentonTransitioncomponents (#3110, #3147) - Allow
Comboboxcomponent to havenullvalue (#3064, #3100) - Attempt form submission when pressing enter on the
ListboxButtoncomponent (#2972) - Deprecate the
enteredprop on theTransitioncomponent (#3089) - Add frozen value to
ComboboxOptionscomponent (#3126)
Upgrading from v1
Update dependencies
Install the latest version of the package via npm:
npm install @headlessui/react@latestDefault element changes
The default rendered element has changed for a number of components in v2.0:
| Component | v1.x element | v2.0 element |
|---|---|---|
Transition |
div |
Fragment |
TransitionChild |
div |
Fragment |
ListboxOptions |
ul |
div |
ListboxOption |
li |
div |
ComboboxOptions |
ul |
div |
ComboboxOption |
li |
div |
TabGroup |
Fragment |
div |
If you are using any of these components without the as prop, you'll need to add the as prop and render the component with the element you need:
- <Transition ...>
+ <Transition as="div" ...>Comboboxes now always support empty values
Previously the Combobox component required an option to always be set, and you could opt out of this behavior using the nullable prop. In v2.0 comboboxes support empty values by default so you can remove this prop:
- <Combobox value={selected} onChange={setSelected} nullable>
+ <Combobox value={selected} onChange={setSelected}>If you'd like to keep the previous behavior, update your onChange callback to only set the selected value if an option has actually been selected:
<Combobox
value={selected}
- onChange={setSelected}
+ onChange={(newValue) => setSelected((oldValue) => newValue ?? oldValue)}
onClose={() => setQuery('')}
>
