Overview
Tailwind v4 lets you extend and override utilities directly inglobal.css using the @utility and @theme directives, with no config file required. This guide covers three common scenarios:
- Variable-driven utilities: create a utility whose value is injected at runtime via a CSS variable
- Brand-new utilities: add a class that has no Tailwind equivalent
- Overriding existing utilities: change what a built-in Tailwind class does
Variable-Driven Utilities
Sometimes you need a utility class whose value isn’t known until runtime. A common example is padding that accounts for a navigation header height, which is only available after the layout renders.Example: p-safe-header
Step 1: Declare the variable in global.css
Use @theme static so the variable is always available in JavaScript even before it is updated, and define the utility with @utility:
global.css
@theme static ensures --header-height is registered with Uniwind even if it is never used directly in a className. This is required for updateCSSVariables to pick it up.Uniwind.updateCSSVariables:
Brand-New Custom Utilities
Use@utility to define a class that doesn’t exist in Tailwind at all. The CSS you write inside it maps directly to React Native style properties.
Example: card-shadow
global.css
Custom utility names must be kebab-case. Tailwind scans your source files for them at build time, so the same dynamic class name rules apply. Always write the full class name in source.
Overriding Existing Tailwind Utilities
Override via @theme: change values only
The most common approach: keep the utility name but change what value it resolves to. This works for any design token in Tailwind’s scale.
global.css
p-4, px-4, py-4, rounded-lg, etc.) update automatically, with no need to touch individual class definitions.
Override via @utility: replace the generated CSS
Use @utility when you want to completely change what a class does, not just adjust its value.
Example: make border always use --color-primary
By default, border only sets border-width and border-style. Override it to also lock in the border color:
global.css
border always renders with the primary color instead of default value (black).
Real-World Example: Border Curve Utilities
iOS supports aborderCurve property that controls how border corners are rendered. continuous produces Apple’s signature “squircle” shape, while circular is the standard round corner.
border-continuous and border-circular are built into Uniwind since 1.6.0 / 1.0.0-rc.6 (Pro):
On versions before This is a good example of how you can use
1.6.0 / 1.0.0-rc.6 (Pro), you need to add these utilities manually in your global.css:global.css
@utility to expose any React Native style property as a Tailwind class.Best Practices
background-image works on native only with linear-gradient() values, which Uniwind maps to React Native’s gradient background. Other values, such as radial-gradient() and conic-gradient(), have no effect on native.Related
Global CSS
Full reference for @theme, @utility, and global.css structure
updateCSSVariables
Inject CSS variable values at runtime
useCSSVariable
Read CSS variable values in JavaScript