Course contentsShow
← React
Lesson 1183 of 2,39630. Composition: Inversion of ControlFree lesson

What 'Headless' Means: Logic Without Styling

Headless components provide accessibility, keyboard navigation, and state management while letting you control all markup and styling.

What 'Headless' Means: Logic Without Styling

You'll learn what "headless" components are and why they separate behavior from presentation.

The Core Concept

A headless component (or headless UI library) provides all the complex logic—accessibility, keyboard navigation, focus management, state transitions—but leaves the visual presentation entirely up to you. It's like getting a fully functional car engine without the body, so you can build whatever exterior design you want.

Traditional UI libraries (like Material-UI or Ant Design) give you pre-styled buttons, menus, and dialogs. Headless libraries give you the behavior of those components without any CSS or markup opinions.

How It Works

Headless components typically use patterns like:

  • Render props or children as functions to let you control markup
  • Prop getters to pass correct ARIA attributes and event handlers
  • State reducers to let you customize behavior
  • Context for compound component architectures

You get the hard stuff (ARIA roles, keyboard handling, screen reader support) for free, while maintaining 100% control over HTML structure and styling.

Why This Matters

Building accessible dropdowns, modals, or comboboxes from scratch is incredibly difficult. Headless libraries like Radix UI, Headless UI, and Downshift give you production-ready accessibility without forcing Tailwind, CSS-in-JS, or any particular styling approach on you.

You've already seen pieces of this: prop getters return attributes you spread onto your elements, state reducers let you override transitions, and compound components let you arrange markup freely. Headless is the philosophy that ties these patterns together—maximum logic reuse, zero style opinions.

Key Takeaway: Headless components provide the invisible complexity (accessibility, state, keyboard nav) while giving you complete control over what users actually see.