Releases: tailwindlabs/headlessui
Releases · tailwindlabs/headlessui
@headlessui/react@v2.0.0
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
Checkbox
component to complement our existingRadioGroup
component, making it easy to build totally custom checkbox controls. - HTML form components — we've added
Input
,Select
,Textarea
,Label
,Description
,Fieldset
, andLegend
components 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-hover
anddata-focus
attributes to your controls that behave more consistently across different devices than the native pseudo-classes. - Combobox list virtualization — the
Combobox
component can now handle giant lists of options with no performance issues.
Changelog
Added
- Add new
Checkbox
component (#2887, #2962) - Add new
Button
component (#2887) - Add new
Input
component (#2887, #2902, #2940) - Add new
Textarea
component (#2887, #2902, #2940) - Add new
Select
component (#2887, #2902) - Add new
Fieldset
andLegend
components (#2887) - Add new
Field
,Label
,Description
components (#2887, #2941) - Add new
MenuSection
,MenuHeading
, andMenuSeparator
components (#2887) - Add new
ListboxSelectedOption
component (#2887) - Add new
DataInteractive
component (#2887) - Add new
CloseButton
component anduseClose
hook (#3096) - Add new
anchor
,modal
, andportal
props toCombobox
,Listbox
,Menu
andPopover
components (#2887, #3075, #3097, #3111, #3115, #3121, #3124, #3133, #3138, #3148, #3152, #3154, #3157) - Add new
autoFocus
prop to focusable components (#2887) - Add new
virtual
prop toCombobox
component (#2779, #3128, #3160, #3161, #3163) - Add new
onClose
prop toCombobox
component (#3122) - Add new
immediate
prop toCombobox
for immediately opening the Combobox when theinput
receives focus (#2686) - Add new
--button-width
CSS variable on theListboxOptions
,MenuItems
, andPopoverPanel
components (#2887, #3058) - Add new
--input-width
and--button-width
CSS variables on theComboboxOptions
component (#3057) - Add new
data-*
attributes as an alternative to the existingdata-headlessui-state
attribute (#2887, #3035, #3061)
Fixed
- Fix scroll-locking on iOS (#2891)
- Fix cancellation of events when using
disabled
oraria-disabled
attributes (#2890) - Fix unnecessary execution of the
displayValue
callback inComboboxInput
component (#3048) - Fix types for
multiple
prop inCombobox
component (#3099) - Fix focus handling in
ComboboxInput
component (#3065, #3073) - Fix enter transitions in
Transition
component (#3074) - Fix focus handling in
ListboxOptions
andMenuItems
components (#3112) - Fix horizontal scrolling inside the
Dialog
component (#2889)
Changed
- Require React 18 (#2887, #3092, #3131)
- Always render hidden form input fields for
Checkbox
,Switch
andRadioGroup
components (#3095) - Deprecate the
RadioGroup.Option
component in favor of newRadio
component (#2887) - Deprecate the
active
prop in favor of newfocus
prop (#2887) - Dialog is now focused by default instead of the first focusable element (#2887)
- Change default tags for
ListboxOptions
,ListboxOption
,ComboboxOptions
,ComboboxOption
, andTabGroup
components (#3109) - Change default tag from
div
toFragment
onTransition
components (#3110, #3147) - Allow
Combobox
component to havenull
value (#3064, #3100) - Attempt form submission when pressing enter on the
ListboxButton
component (#2972) - Deprecate the
entered
prop on theTransition
component (#3089) - Add frozen value to
ComboboxOptions
component (#3126)
Upgrading from v1
Update dependencies
Install the latest version of the package via npm:
npm install @headlessui/react@latest
Default 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 |
TransitionRoot |
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)}
...
@headlessui/vue@v1.7.21
@headlessui/vue@v1.7.20
Fixed
- Expose
disabled
state onTab
component (#2918) - Prevent default behaviour when clicking outside of a
DialogPanel
(#2919) - Don’t override explicit
disabled
prop for components insideMenuItem
(#2929) - Add
hidden
attribute to internalHidden
component when theFeatures.Hidden
feature is used (#2955) - Allow setting custom
tabIndex
on theSwitch
component (#2966) - Forward
disabled
state to hidden inputs in form-like components (#3004) - Respect
selectedIndex
for controlledTab
components (#3037)
@headlessui/react@v1.7.19
Fixed
- Make sure panels re-register when IDs are calculated in React < 18 (#2883)
- Expose
disabled
state onTab
component (#2918) - Prevent default behaviour when clicking outside of a
Dialog.Panel
(#2919) - Add
hidden
attribute to internalHidden
component when theFeatures.Hidden
feature is used (#2955) - Allow setting custom
tabIndex
on theSwitch
component (#2966) - Forward
disabled
state to hidden inputs in form-like components (#3004) - Respect
selectedIndex
for controlledTab
components (#3037)
@headlessui/vue@v1.7.19
- Fix Combobox
activeOption
render prop (#2973)
@headlessui/vue@v1.7.18
Added
- Allow users customize ID generation (#2959)
@headlessui/vue@v1.7.17
Fixed
- Don't call
<Dialog>
'sonClose
twice on mobile devices (#2690) - Fix Portal SSR hydration mismatches (#2700)
- Ensure hidden
TabPanel
components are hidden from the accessibility tree (#2708) - Add support for
role="alertdialog"
to<Dialog>
component (#2709) - Ensure blurring the
ComboboxInput
component closes theCombobox
(#2712) - Allow
<button>
to be in nested components in<PopoverButton>
(#2715) - Don't overwrite user-defined template refs when rendering (#2720)
- Fix missing
data-headlessui-state
attribute whenas="template"
(#2787) - Fix VoiceOver bug for
Listbox
component in Chrome (#2824) - Fix outside click detection when component is mounted in the Shadow DOM (6846231)
- Fix CJS types (#2880)
- Fix error when transition classes contain new lines (#2871)
@headlessui/react@v1.7.18
Fixed
- Don't call
<Dialog>
'sonClose
twice on mobile devices (#2690) - Lazily resolve default containers in
<Dialog>
(#2697) - Ensure hidden
Tab.Panel
components are hidden from the accessibility tree (#2708) - Add support for
role="alertdialog"
to<Dialog>
component (#2709) - Ensure blurring the
Combobox.Input
component closes theCombobox
(#2712) - Allow changes to the
className
prop when the<Transition />
component is currently not transitioning (#2722) - Export (internal-only) component interfaces for TypeScript compiler (#2313)
- Fix infinite render-loop for
<Disclosure.Panel>
and<Popover.Panel>
whenas={Fragment}
(#2760) - Fix VoiceOver bug for
Listbox
component in Chrome (#2824) - Fix outside click detection when component is mounted in the Shadow DOM (#2866)
- Fix CJS types (#2880)
- Fix error when transition classes contain new lines (#2871)
- Improve iOS locking (7721aca)
@headlessui/react@v2.0.0-alpha.4
Fixed
- Ensure
Input
,Select
andTextarea
exposeRef
related types (#2902)
@headlessui/react@v2.0.0-alpha.3
Fixed
- Further fine tune scroll locking on iOS (#2891)