The global.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.
Important: Variables in @theme only customize Tailwind utility classes. They do not apply globally to unstyled components. If you want to change the default font size for all Text components, you need to use className="text-base" on each component.
import { Text } from 'react-native'// ❌ This will NOT use --text-base (uses React Native's default ~14px)<Text>Unstyled text</Text>// ✅ This WILL use --text-base (15px from your @theme)<Text className="text-base">Styled text</Text>
Uniwind supports modern OKLCH color space, which provides more perceptually uniform colors and better color manipulation compared to traditional RGB/HSL:
Once defined, reference your CSS variables directly as Tailwind utilities:
import { View, Text } from 'react-native'export const ThemedCard = () => ( <View className="bg-card border border-border p-4 rounded-lg"> <Text className="text-foreground text-lg font-bold"> Card Title </Text> <Text className="text-foreground-secondary mt-2"> This card automatically adapts to the current theme </Text> </View>)
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.
If you need to define CSS variables that should always be available in JavaScript (via useCSSVariable) but aren’t used in any className, use the @theme static directive:
Use semantic variable names: Name variables based on their purpose (e.g., --color-background, --color-primary) rather than their value (e.g., --color-blue-500).
Keep theme variables consistent: Ensure all themes define the same set of variables. If you miss a variable in one theme, we will warn you about it in __DEV__ mode.
Avoid hard-coded colors in components: Use CSS variables for colors that should adapt to themes. This ensures your UI remains consistent across theme changes.