Last updated on February 21, 2026
Functions & Directives
Overview
Nativewind v5 uses Tailwind CSS v4, which introduces a CSS-first configuration model. Please refer to the Tailwind CSS v4 documentation for the full directive reference.
Tailwind CSS v4 Directives
| Directive | Purpose |
|---|---|
@import | Import Tailwind layers and other CSS files |
@theme | Define design tokens (colors, spacing, fonts, etc.) |
@utility | Define custom utilities |
@custom-variant | Define custom variants |
@source | Specify content sources for class detection |
@plugin | Load a Tailwind plugin |
@apply | Inline utility classes within custom CSS |
Example CSS setup
The nativewind/theme import adds React Native-specific theme values (elevation, platform fonts, safe area utilities) and custom variants (ios:, android:, native:, web:, tv:).
CSS Functions
These CSS functions are polyfilled on native by react-native-css:
var()
var() allows you to use CSS custom properties (variables). Variables can be set in CSS or from JavaScript using the vars() function.
Variables are inherited through the component tree, just like CSS.
calc()
calc() performs arithmetic in CSS values. Supported unit types:
- Numerical (
px):calc(10px + 100px)resolves to110 - Percentage (
%):calc(var(--width) + 20%)resolves correctly remunits:calc(2rem * 5)resolves using the platform rem valueemunits:calc(2em * 2)resolves relative to the element's font size- CSS variables:
calc(var(--variable) + 20px)resolves at runtime - Inside color functions:
hsl(calc(var(--H) + 20), 50%, 50%)works for dynamic colors
Limitation: Mixing unit types
React Native's layout engine does not support mixing numerical and percentage units. calc(100% - 20px) will not work. Ensure all operands use the same unit type.
env()
env() accesses device-specific environment values. Supported values:
See Safe Area Insets for more information.
color-mix()
color-mix() blends two colors together in a given color space:
React Native Functions
Nativewind provides additional functions for React Native-specific values:
hairlineWidth()
Returns the thinnest visible line width on the device (maps to StyleSheet.hairlineWidth):
roundToNearestPixel()
Rounds a value to the nearest pixel boundary:
getPixelSizeForLayoutSize()
Converts a layout size to pixel size:
platformColor()
Access platform-specific named colors: