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

Radix UI Primitives: Unstyled Building Blocks

Radix provides components like Dialog, Dropdown, Tooltip with zero styles, exposing data attributes and state for your CSS.

Radix UI Primitives: Unstyled Building Blocks

What you'll learn: How Radix UI provides complete component logic and accessibility without imposing any visual styling.

The Building Block Philosophy

Radix UI Primitives are headless components with a twist: they're not just hooks returning props — they're actual JSX components that render real DOM elements. The difference? They come with zero styles. No CSS, no inline styles, not even basic layout rules.

When you use <Dialog.Root>, <Dropdown.Menu>, or <Tooltip.Provider>, you get:

  • Full keyboard navigation
  • ARIA attributes automatically applied
  • Focus management
  • State management (open/closed, active/inactive)
  • All the behavioral logic

What you don't get: any visual appearance whatsoever.

How Radix Exposes Control

Instead of styling components for you, Radix exposes data through attributes and state. Each primitive adds data-* attributes to the DOM that reflect the component's current state:

  • data-state="open" or data-state="closed"
  • data-disabled
  • data-highlighted

You target these in your CSS to style each state. Want a red background when a dropdown item is highlighted? Write [data-highlighted] { background: red; }. Need different animations for open vs closed? Use [data-state="open"] as your selector.

This approach gives you complete styling freedom while handling all the complex accessibility and interaction logic you'd otherwise spend weeks implementing.

The Design Intent

Think of Radix primitives as unstyled LEGO bricks with perfect joints. The connections (accessibility, state management, keyboard handling) are engineered perfectly. The appearance? That's your creative decision.

Key Takeaway: Radix UI Primitives provide fully functional, accessible components as unstyled DOM elements, exposing their internal state through data attributes so you control 100% of the styling with your own CSS.