Colors
Color palette and theming system for HeroUI Native
HeroUI Native uses CSS variables for colors that automatically switch between light and dark themes. All colors use the oklch color space for better color transitions.
How It Works
HeroUI Native's color system is built on top of Tailwind CSS v4's theme via Uniwind. When you import heroui-native/styles, it uses Tailwind's built-in color palettes and maps them to semantic variables.
Naming pattern:
- Colors without a suffix are backgrounds (e.g.,
--accent) - Colors with
-foregroundare for text on that background (e.g.,--accent-foreground)
Usage:
import { View, Text } from 'react-native';
// This gives you the right background and text colors
<View className="bg-background flex-1">
<View className="bg-accent p-4 rounded-lg">
<Text className="text-accent-foreground">Hello</Text>
</View>
</View>Base Colors
These four colors stay the same in all themes:
Background & Surface
Primary Colors
Accent — Your main brand color (used for primary actions) Accent Soft — A lighter version for secondary actions
Status Colors
For alerts, validation, and status messages:
Form Field Colors
For consistent form field styling across input components:
Other Colors
How to Use Colors
In your components:
import { View, Text } from 'react-native';
import { Button } from 'heroui-native';
<View className="bg-background flex-1 p-4">
<Text className="text-foreground mb-4">Content</Text>
<Button variant="primary" className="bg-accent">
<Button.Label className="text-accent-foreground">Click me</Button.Label>
</Button>
</View>In CSS files:
/* Direct CSS variables */
.container {
flex: 1;
background-color: var(--accent);
width: 50px;
height: 50px;
border-radius: var(--radius);
}Default Theme
The complete theme definition can be found in (variables.css). This theme automatically switches between light and dark modes through Uniwind's theming system, which supports system preferences and programmatic theme switching.
@theme {
/* Primitive Colors (Do not change between light and dark) */
--white: oklch(100% 0 0);
--black: oklch(0% 0 0);
--snow: oklch(0.9911 0 0);Customizing Colors
Override existing colors:
@layer theme {
@variant light {
/* Override default colors */
--accent: oklch(0.65 0.25 270); /* Custom indigo accent */
--success: oklch(0.65 0.15 155);
}
@variant dark {
/* Override dark theme colors */
--accent: oklch(0.65 0.25 270);
--success: oklch(0.75 0.12 155);
}
}Tip: Convert colors at oklch.com
Add your own colors:
@layer theme {
@variant light {
--info: oklch(0.6 0.15 210);
--info-foreground: oklch(0.98 0 0);
}
@variant dark {
--info: oklch(0.7 0.12 210);
--info-foreground: oklch(0.15 0 0);
}
}
@theme inline {
--color-info: var(--info);
--color-info-foreground: var(--info-foreground);
}Now you can use it:
import { View, Text } from 'react-native';
<View className="bg-info p-4 rounded-lg">
<Text className="text-info-foreground">Info message</Text>
</View>Note: To learn more about theme variables and how they work in Tailwind CSS v4, see the Tailwind CSS Theme documentation.
Quick Tips
- Always use color variables, not hard-coded values
- Use foreground/background pairs for good contrast
- Test in both light and dark modes
- The system respects user's theme preference automatically
Related
- Theming - Learn about the theming system
- Styling - Styling components with CSS
- Design Principles - Understanding HeroUI's design philosophy