Available in Uniwind 1.3.0+Documentation Index
Fetch the complete documentation index at: https://docs.uniwind.dev/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Data selectors let you conditionally apply styles based on a component’s props using Tailwind-style variants. This mirrors the familiardata-[state=open]:... pattern from Tailwind v4 and allows React Native components to react to their own prop values.
Basic Usage
Use thedata-[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.,statetargets thedata-stateprop) - The utility applies only when the prop equals the given value
Boolean Props
For boolean props, compare totrue or false:
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]anddata-[prop=false] - Multiple different data selectors can be used on the same className string
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
Related
Supported Class Names
Learn which utilities and variants are supported
Platform Selectors
Combine data selectors with platform variants