Colors
The color system is designed to provide a consistent and scalable palette for your design system. It uses the Radix UI Colors tool to generate a range of shades (from light to dark) for each base color. These colors are then integrated into your project using CSS variables, prefixed with color- for easy usage.
Key Features
- Custom Color Palette: The Radix UI Colors tool generates a scale of shades for each base color, ensuring a harmonious range from light to dark.
- CSS Variables: Colors are defined as CSS variables, prefixed with color- for easy reference and usage.
- Tailwind CSS v4 Integration: Colors are initialized in your CSS file, making them available for use in your Tailwind CSS v4 project.
To create a custom color palette, follow these steps:
- Visit the Radix UI Colors tool.
- Input your Accent color (e.g., #3B82F6 for blue).
- Input your Gray color (e.g., #E6E6F2 for gray).
- Input your Background color (e.g., #FFFFFF for white).
- Copy the generated CSS variables.
Example Output:
For a base color of #3B82F6 (blue), the tool might generate:
:root, .light, .light-theme {
--blue-1: #fcfdff;
--blue-2: #f5f9ff;
--blue-3: #eaf2ff;
--blue-4: #dcebff;
--blue-5: #cbe1ff;
--blue-6: #b8d4ff;
--blue-7: #9fc2fb;
--blue-8: #7baaf6;
--blue-9: #3b82f6;
--blue-10: #2c74e9;
--blue-11: #256cde;
--blue-12: #123164;
--blue-a1: #0055ff03;
--blue-a2: #0066ff0a;
--blue-a3: #0062ff15;
--blue-a4: #006eff23;
--blue-a5: #006cff34;
--blue-a6: #0065ff47;
--blue-a7: #005df560;
--blue-a8: #005bee84;
--blue-a9: #005df3c4;
--blue-a10: #0057e5d3;
--blue-a11: #0053d8da;
--blue-a12: #002158ed;
--blue-contrast: #fff;
--blue-surface: #f3f8ffcc;
--blue-indicator: #3b82f6;
--blue-track: #3b82f6;
}
@supports (color: color(display-p3 1 1 1)) {
@media (color-gamut: p3) {
:root, .light, .light-theme {
--blue-1: oklch(99.3% 0.0032 259.8);
--blue-2: oklch(98.2% 0.0096 259.8);
--blue-3: oklch(96% 0.0199 259.8);
--blue-4: oklch(93.7% 0.0373 259.8);
--blue-5: oklch(90.6% 0.054 259.8);
--blue-6: oklch(86.4% 0.0697 259.8);
--blue-7: oklch(80.9% 0.0894 259.8);
--blue-8: oklch(73.4% 0.1221 259.8);
--blue-9: oklch(62.3% 0.188 259.8);
--blue-10: oklch(58.2% 0.1913 259.8);
--blue-11: oklch(55.4% 0.188 259.8);
--blue-12: oklch(32.3% 0.0976 259.8);
--blue-a1: color(display-p3 0.0235 0.349 1 / 0.012);
--blue-a2: color(display-p3 0.0235 0.349 0.8941 / 0.036);
--blue-a3: color(display-p3 0.0078 0.3569 0.9529 / 0.079);
--blue-a4: color(display-p3 0.0078 0.3804 0.9412 / 0.126);
--blue-a5: color(display-p3 0.0078 0.3569 0.9412 / 0.189);
--blue-a6: color(display-p3 0.0039 0.3373 0.9412 / 0.259);
--blue-a7: color(display-p3 0.0039 0.3059 0.898 / 0.35);
--blue-a8: color(display-p3 0.0039 0.298 0.8784 / 0.479);
--blue-a9: color(display-p3 0 0.2824 0.902 / 0.695);
--blue-a10: color(display-p3 0 0.2627 0.8431 / 0.75);
--blue-a11: color(display-p3 0 0.251 0.7961 / 0.773);
--blue-a12: color(display-p3 0 0.098 0.3098 / 0.899);
--blue-contrast: #fff;
--blue-surface: color(display-p3 0.9569 0.9725 1 / 0.8);
--blue-indicator: oklch(62.3% 0.188 259.8);
--blue-track: oklch(62.3% 0.188 259.8);
}
}
}
Integrating Colors into Your CSS File
Once you have your color scales, integrate them into your CSS file. Define the colors as CSS variables under the @theme inline layer, prefixed with color-accent.
Color System Setup
Two Scales:
- Solid colors (--accent-1 to --accent-12)
- Transparent versions (--accent-a1 to --accent-a12)
Naming Logic
color-{purpose}-{value} (e.g., color-accent-9 for primary brand color)
@theme inline {
...
--color-accent-track: var(--accent-track);
--color-accent-indicator: var(--accent-indicator);
--color-accent-surface: var(--accent-surface);
--color-accent-contrast: var(--accent-contrast);
--color-accent-a12: var(--accent-a12);
--color-accent-a11: var(--accent-a11);
--color-accent-a10: var(--accent-a10);
--color-accent-a9: var(--accent-a9);
--color-accent-a8: var(--accent-a8);
--color-accent-a7: var(--accent-a7);
--color-accent-a6: var(--accent-a6);
--color-accent-a5: var(--accent-a5);
--color-accent-a4: var(--accent-a4);
--color-accent-a3: var(--accent-a3);
--color-accent-a2: var(--accent-a2);
--color-accent-a1: var(--accent-a1);
--color-accent-12: var(--accent-12);
--color-accent-11: var(--accent-11);
--color-accent-10: var(--accent-10);
--color-accent-9: var(--accent-9);
--color-accent-8: var(--accent-8);
--color-accent-7: var(--accent-7);
--color-accent-6: var(--accent-6);
--color-accent-5: var(--accent-5);
--color-accent-4: var(--accent-4);
--color-accent-3: var(--accent-3);
--color-accent-2: var(--accent-2);
--color-accent-1: var(--accent-1);
...
}
:root {
...
--accent-1: #fcfdff;
--accent-2: #f3f9ff;
--accent-3: #e8f3ff;
--accent-4: #d8eaff;
--accent-5: #c9e0ff;
--accent-6: #b5d3ff;
--accent-7: #9abfff;
--accent-8: #73a3ff;
--accent-9: #007;
--accent-10: #042692;
--accent-11: #2458de;
--accent-12: #011d8a;
--accent-a1: #0055ff03;
--accent-a2: #0080ff0c;
--accent-a3: #007aff17;
--accent-a4: #0076ff27;
--accent-a5: #006dff36;
--accent-a6: #0168ff4a;
--accent-a7: #005eff65;
--accent-a8: #0058ff8c;
--accent-a9: #000077;
--accent-a10: #002390fb;
--accent-a11: #003dd9db;
--accent-a12: #001c8afe;
--accent-contrast: #fff;
--accent-surface: #f0f8ffcc;
--accent-indicator: #007;
--accent-track: #007;
...
}
Using Colors in Your Project
Once the colors are defined as CSS variables, you can use them in your HTML or JSX by referencing the variables.