Overview
Theglobal.css file is the main entry point for Uniwind’s styling system. It’s where you import Tailwind and Uniwind, define theme-specific CSS variables, customize Tailwind’s configuration, and add global styles for your entire application.
The
global.css file must be imported in your app’s entry point (usually App.tsx) for Uniwind to work correctly.Required Imports
Everyglobal.css file must include these two essential imports:
global.css
- All Tailwind utility classes
- Uniwind’s React Native compatibility layer
- Theme-based variants (
dark:,light) - Platform-specific variants (
ios:,android:,web:)
Customizing Tailwind Configuration
Use the@theme directive to customize Tailwind’s default configuration values:
Modifying Design Tokens
global.css
Extending the Color Palette
global.css
Theme-Specific Variables
Define different CSS variable values for each theme using the@layer theme directive with @variant:
Basic Theme Variables
global.css
Complete Theme System
global.css
OKLCH Color Support
Uniwind supports modern OKLCH color space, which provides more perceptually uniform colors and better color manipulation compared to traditional RGB/HSL:global.css
- Perceptually uniform: Colors that look equally bright to the human eye
- Wider color gamut: Access to more vibrant colors on modern displays
- Better interpolation: Smooth color transitions without muddy intermediate colors
- Consistent lightness: Easier to create accessible color palettes
Using Theme Variables
Once defined, reference your CSS variables directly as Tailwind utilities:No need to use
var() or brackets! Simply use the variable name without the --color- prefix. For example, --color-primary becomes bg-primary or text-primary.Custom Themes
Define variables for custom themes beyond light and dark:global.css
Static Theme Variables
If you need to define CSS variables that should always be available in JavaScript (viauseCSSVariable) but aren’t used in any className, use the @theme static directive:
global.css
When to Use Static Variables
Variables defined in
@theme static are always available via the useCSSVariable hook, even if they’re never used in any className.@theme static for:
- Third-party library configuration: Values needed for chart libraries, maps, or other JavaScript APIs
- Runtime calculations: Design tokens used for JavaScript logic or animations
- Native module values: Configuration passed to native modules
- JavaScript-only values: Any CSS variable that should be accessible in JavaScript but doesn’t need to generate Tailwind utilities
Example: Using Static Variables
Best Practices
Related
useCSSVariable
Access CSS variable values in JavaScript
Theming Basics
Learn the fundamentals of theming in Uniwind
Custom Themes
Create and manage custom themes
CSS Parser
Learn about Uniwind’s CSS parsing capabilities
Style Based on Themes
Advanced theme-based styling techniques