Headless UI's Approach: Components Without Styles
What you'll learn: How Headless UI delivers fully-functional, accessible components while leaving all styling decisions in your hands.
The Philosophy: Behavior, Not Appearance
Headless UI takes a radical approach to component libraries: it provides zero styling. Instead of giving you pre-designed buttons or dropdowns with opinionated colors and layouts, it handles only the complex parts—state management, keyboard navigation, accessibility attributes, and focus management—while you provide 100% of the CSS.
Think of it like buying a car engine without the body. You get all the mechanical complexity (shifting gears, fuel injection, timing) working perfectly, but you design the exterior exactly how you want.
How It Works
Headless UI components use the compound component pattern you've learned, but they render unstyled HTML elements:
<Menu>
<Menu.Button className="your-custom-button-class">
Options
</Menu.Button>
<Menu.Items className="your-custom-dropdown">
<Menu.Item>
{({ active }) => (
<a className={active ? 'bg-blue-500' : ''}>
Edit
</a>
)}
</Menu.Item>
</Menu.Items>
</Menu>
The Menu manages open/close state, ARIA attributes, escape-key handling, and focus trapping. You apply Tailwind (or any CSS) to make it look however you want.
Why This Matters
Traditional UI libraries lock you into their design system. Headless UI gives you accessible, battle-tested behavior without forcing visual opinions. You get professional-grade accessibility without wrestling with CSS overrides or !important hacks.
Key Takeaway: Headless UI separates behavior from presentation—you get the hard parts (accessibility, state, interactions) while maintaining complete styling freedom.