Search results
Completely unstyled, fully accessible UI components, designed to integrate beautifully with Tailwind CSS.
- ComboBox
Headless UI also composes well with other animation...
- Transition
Completely unstyled, fully accessible UI components,...
- ListBox
ListBox - Headless UI - Unstyled, fully accessible UI...
- Menu (Dropdown)
If you're interested in predesigned Tailwind CSS dropdown...
- Switch (Toggle)
If you omit the checked prop, Headless UI will track its...
- Disclosure
Disclosure - Headless UI - Unstyled, fully accessible UI...
- Dialog (Modal)
Headless UI also composes well with other animation...
- Popover
Popover - Headless UI - Unstyled, fully accessible UI...
- Radio Group
If you're interested in predesigned Tailwind CSS radio group...
- Tabs
Tabs - Headless UI - Unstyled, fully accessible UI...
- ComboBox
May 7, 2024 · Learn about the new features and improvements of Headless UI v2.0 for React, a collection of headless UI components for web applications. See how to use anchor positioning, checkbox, form, and combobox components with Tailwind CSS.
Apr 14, 2021 · Learn about the new features and components of Headless UI v1.0, a library of unstyled, accessible UI components for React and Vue. See examples of dialog, disclosure, radio group, popover, and transition components.
- Basic Example
- Styling Different States
- Showing/Hiding The Menu
- Closing Menus Manually
- Disabling An Item
- Transitions
- Rendering Additional Content
- Rendering as Different Elements
- Integrating with Next.Js
- Accessibility Notes
Menu Buttons are built using the Menu, Menu.Button, Menu.Items, and Menu.Itemcomponents. The Menu.Button will automatically open/close the Menu.Itemswhen clicked, and when the menu is open, the list of items receives focus and is automatically navigable via the keyboard.
Headless UI keeps track of a lot of state about each component, like which listbox option is currently selected, whether a popover is open or closed, or which item in a menu is currently active via the keyboard. But because the components are headless and completely unstyled out of the box, you can't seethis information in your UI until you provide...
By default, your Menu.Items instance will be shown/hidden automatically based on the internal open state tracked within the Menucomponent itself. If you'd rather handle this yourself (perhaps because you need to add an extra wrapper element for one reason or another), you can add a static prop to the Menu.Items instance to tell it to always render,...
The menu will already close by default, however it can happen that 3rd party Link components use event.preventDefault(), which prevents the default behaviour and therefore won't close the menu. The Menu and Menu.Item expose a close()render prop which you can use to imperatively close the menu:
Use the disabled prop to disable a Menu.Item. This will make it unselectable via keyboard navigation, and it will be skipped when pressing the up/down arrows.
To animate the opening/closing of the menu panel, use the provided Transition component. All you need to do is wrap the Menu.Items in a , and the transition will be applied automatically. By default our built-in Transition component automatically communicates withthe Menucomponents to handle the open/closed states. However, if you requi...
The accessibility semantics of role="menu" are fairly strict and any children of a Menu that are not Menu.Itemcomponents will be automatically hidden from assistive technology to make sure the menu works the way screen reader users expect. For this reason, rendering any children other than Menu.Itemcomponents is discouraged as that content will be ...
By default, the Menuand its subcomponents each render a default element that is sensible for that component. For example, Menu.Button renders a button by default, and Menu.Itemsrenders a div. By contrast, Menu and Menu.Item do not render anelement, and instead render their children directly by default. Use the as prop to render a component as a dif...
Prior to Next.js v13, the Link component did not forward unknown props to the underlying a element, preventing the menu from closing on click when used inside a Menu.Item. If you're using Next.js v12 or older, you can work around this issue by creating your own component that wraps Link and forwards unknown props to the child aelement: This will en...
Focus management
Clicking the Menu.Button toggles the menu and focuses the Menu.Items component. Focus is trapped within the open menu until Escape is pressed or the user clicks outside the menu. Closing the menu returns focus to the Menu.Button.
Mouse interaction
Clicking a Menu.Buttontoggles the menu. Clicking anywhere outside of an open menu will close that menu.
Headless UI is a set of React and Vue components that are designed to integrate with Tailwind CSS. It offers full accessibility, customizability, and documentation for building beautiful and responsive user interfaces.
Headless UI is a library of custom components for React and Vue that are easy to style with Tailwind CSS and fully accessible. Learn how to build dropdowns, listboxes, switches, and more with Headless UI.
Completely unstyled, fully accessible UI components, designed to integrate beautifully with Tailwind CSS.