Skip to main content
Available in Uniwind 1.3.0+

Overview

Data selectors let you conditionally apply styles based on a component’s props using Tailwind-style variants. This mirrors the familiar data-[state=open]:... pattern from Tailwind v4 and allows React Native components to react to their own prop values.

Basic Usage

Use the data-[prop=value] variant with your classes. The name inside the brackets maps to a data-<prop> prop on the same component.
  • Inside brackets, use the name without the data- prefix (e.g., state targets the data-state prop)
  • The utility applies only when the prop equals the given value

Boolean Props

For boolean props, compare to true or false:
Booleans match both the boolean and string forms. For example, data-[selected=true] matches data-selected={true} and data-selected="true".

String Props

You can match arbitrary string values:

Multiple Variants

Chain multiple data selectors to target different prop states:

How It Works

  • During build, Uniwind recognizes attribute selectors generated by variants like data-[prop=value]:... and records them as data constraints for the corresponding class
  • At runtime, when resolving a component’s className, Uniwind compares the component’s props against those constraints and only applies the matching styles
  • Styles that depend on data selectors are evaluated against props and are not cached across prop changes

Supported Syntax

  • Equality checks: data-[prop=value]:utility
  • Boolean checks: data-[prop=true] and data-[prop=false]
  • Multiple different data selectors can be used on the same className string
Only equality selectors are supported (e.g., data-[prop=value]). Presence-only selectors like data-[prop] or other operators are not supported.

Best Practices

  • Prefer semantic prop names (e.g., state, status, variant, disabled) to keep selectors readable
  • Keep variant logic close to the component whose props drive the state
  • Use data selectors for prop-driven state; use interactive variants for interaction states when available

Examples

Tabs

Toggle

Supported Class Names

Learn which utilities and variants are supported

Platform Selectors

Combine data selectors with platform variants