Skip to main content
Version: v4

Hover, Focus and Other States

Please refer to the documentation on the Tailwind CSS website for more information.

Pseudo-classes ​

tip

If a <View /> has a class which requires an event listener, it will be automatically upgraded to <Pressable />.

Hover, focus, and active ​

NativeWind implements a subset of the Tailwind pseudo-classes by adding event listeners on your components, hence they will only work on components that can accept the listener.

The supported pseudo-classes and their related listeners are:

VariantEvent Listeners
hoveronHoverIn, onHoverOut
focusonBlur, onFocus
activeonPressIn, onPressOut,

Opt in Pointer Events​

React Native 0.71 supports opt-in Pointer Events. If enabled NativeWind will use these instead, allowing for hover support on native when used with a pointer device.

VariantEvent Listeners
hoveronPointerOver, onPointerOut
focusonBlur, onFocus
activeonPressIn, onPressOut,

First, last, odd, and even ​

ClassSupport
first:🌐 Web only
last:🌐 Web only
odd:🌐 Web only
even:🌐 Web only

Form States ​

ClassSupport
disabled:βœ”οΈ Partial Support
required:🌐 Web only
invalid:🌐 Web only
caution

On native, "disabled:" is only available for components with a disabled prop.

Unfortunately <TextInput> uses enabled={false} instead of disabled={true}, so it will not work with "disabled:".

info

We are looking for contributors to add more support for "disabled:".

Styling based on parent state ​

Styling based on parent state (group-{modifier})

NativeWind supports the group class name and it can be used with any supported modifier.

Differentiating nested groups

NativeWind supports the group/{name} class name and it can be used with any supported modifier

Arbitrary groups

ClassSupport
Class selectorsβœ… Full Support
Attribute selectorsβœ… Full Support
Pseudo-classes selectors🌐 Web only
Pseudo-elements selectors🌐 Web only
Elements selectors🌐 Web only
Moving group via `&`🌐 Web only
tip

Native supports multiple selectors, e.g group-[.classOne.classTwo[attribute=value]]

Styling based on sibling state ​

Styling based on parent state (peer-{modifier})

ClassSupport
peer🌐 Web only
peer-*🌐 Web only
peer-invalid🌐 Web only

Styling direct children ​

Styling based on parent state (*-)

ClassSupport
*-🌐 Web only

Styling based on descendants ​

Styling based on descendants (has-{modifier})

ClassSupport
has-🌐 Web only
info

We are looking for contributors to add more support for has-.

Pseudo-elements​

Placeholder text​

tip

On native, placeholder: only supports the text-* or color-* classes. It will map to the placeholderTextColor on native.

We are looking for contributors to add more support for placeholder:.

ClassSupport
placeholder:βœ”οΈ Partial Support

Media and feature queries​

Responsive breakpoints​

To style an element at a specific breakpoint, use responsive modifiers like md and lg.

Check out the Responsive Design documentation for an in-depth look at how these features work.

Prefers color scheme​

Please read the Dark Mode documentation for an in-depth look at how this feature works.

ClassSupport
dark:βœ… Full Support

Prefers reduced motion​

ClassSupport
motion-reduce:βœ… Full Support

Viewport orientation​

Use the portrait and landscape modifiers to conditionally add styles when the viewport is in a specific orientation.

ClassSupport
portrait:βœ… Full Support
landscape:βœ… Full Support

Use the print modifier to conditionally add styles that only apply when the document is being printed:

ClassSupport
print:🌐 Web only

Supports rules​

Use the supports-[...] modifier to style things based on whether a certain feature is supported in the user’s browser.

ClassSupport
supports-[n]:🌐 Web only

Attribute selectors​

Use the aria-* modifier to conditionally style things based on ARIA attributes.

ClassSupport
aria-[n]:🌐 Web only

Data selectors​

Use the data-* modifier to conditionally style things based on data attributes.

ClassSupport
data-[n]:🌐 Web only

RTL support​

Use the rtl and ltr modifiers to conditionally add styles in right-to-left and left-to-right modes respectively when building multi-directional layouts:

ClassSupport
ltr:βœ… Full Support
rtl:βœ… Full Support

Open/closed state​

Use the open modifier to conditionally add styles when a <details/> or <dialog/> element is in an open state:

ClassSupport
open:🌐 Web only

Custom modifiers​

Custom modifiers are possible, but are not yet documented. More information to come.