Styling

Radix Primitives are unstyled—and compatible with any styling solution—giving you complete control over styling.

You are in control of all aspects of styling, including functional styles. For example—by default—a Dialog Overlay won't cover the entire viewport. You're responsible for adding those styles, plus any presentation styles.

Each component has a data-radix-* attribute, matching its name. For example, the Separator component includes a data-radix-separator attribute.

When components are stateful, their state will be exposed in a data-state attribute. For example, when an Accordion Item is opened, it includes a data-state="open" attribute.

All components accept a className prop. This class will be passed through to the DOM element. You can use it in CSS as expected.

You can style a component part by targeting its data-radix-* attribute.

You can style a component state by targeting its data-state attribute.

The examples below are using Stitches, but you an use any CSS-in-JS library of your choice.

You can style a component part by wrapping it in a styled function (or equivalent).

You can style a component state by targeting its data-state attribute.

Here's an example of how you can style the Accordion component with CSS-in-JS.

Radix Primitives were designed to encapsulate accessibility concerns and other complex functionalities, while ensuring you retain complete control over styling.

To ensure compatibility with global CSS solutions, components include a data-radix-* attribute. Stateful components include a data-state attribute.

Every component that renders an HTML element will contain these attributes, so feel free to inspect them and look around.