Conditional Styles

Yamada UI provides features to apply styles according to conditions.

Overview

By using conditional styles, you can apply styles for pseudo-elements, pseudo-classes, and selectors.

Pseudo Elements

To apply styles to the ::before pseudo-element, use _before.

Box

Pseudo Classes

To apply styles to the :hover pseudo-class, use _hover.

Hover me

You can also apply multiple values together.

Hover me

You can also combine multiple conditions.

Hover and focus me

Selectors

To apply styles based on the data-orientation attribute, use _horizontal or _vertical.

horizontal

Group Selectors

To apply styles to an element based on the state or attribute of the parent element, add the "group" or "data-group" role to the parent element and use the _group* conditional styles for the child elements.

Hover me

Peer Selectors

To apply styles to an element based on the state or attribute of the peer element, add the data-peer to the peer element and use the _peer* conditional styles.

Focus the peer
Focus me!

Any Selectors

To use any selectors, use css to apply styles.

Closed