Styling

A guide to styling Base UI components with your preferred styling engine.

Base UI components are unstyled, don’t bundle CSS, and are compatible with Tailwind, CSS Modules, CSS-in-JS, or any other styling solution you prefer. You retain total control of your styling layer.

Style hooks

CSS classes

Every component accepts a className prop which you can use to pass CSS classes to its DOM element. The className prop, in addition to accepting a string, can be defined as a function that takes a component state as an argument:

switch.tsx

CSS variables

Some components expose CSS custom properties to aid with styling, such as --accordion-panel-height, --transform-origin, or --active-tab-width.

Data attributes

Base UI components provide data attributes designed for styling their states. For example, a Switch may be styled using its [data-checked] and [data-unchecked] attributes, among others.

Check out each component’s API reference for a complete list of available data attributes.

Tailwind

Apply Tailwind classes to each part via the className prop.

menu.tsx

CSS Modules

Apply custom CSS classes to each part via the className prop. Then style those classes in a CSS Modules file.

menu.tsx

CSS-in-JS

Wrap each component part and apply styles, then assemble your styled components.

menu.tsx