Components are built using CSS variables and Tailwind, allowing you to easily customize the colors and styles of your entire application.
How it works
We use a simple convention: each color has a
--background variable for the background and a --foreground variable for the text that goes on that background.For example:
--primarydefines the main background color--primary-foregrounddefines the text color on that background
This automatically ensures good contrast between the background and text.
1<button className="bg-primary text-primary-foreground p-4">My button</button>
Available colors
1:root {2 --background: oklch(99.405% 0.00011 271.152);3 --foreground: oklch(0% 0 0);4 --primary: oklch(53.934% 0.2714 286.753);5 --primary-foreground: oklch(100% 0.00011 271.152);6 --secondary: oklch(95.4% 0.00637 255.746);7 --secondary-foreground: oklch(13.441% 0.00002 271.152);8 --muted: oklch(97.015% 0.00011 271.152);9 --muted-foreground: oklch(43.861% 0.00005 271.152);10 --accent: oklch(93.929% 0.02887 266.393);11 --accent-foreground: oklch(54.456% 0.19041 259.501);12 --destructive: oklch(62.902% 0.19024 23.052);13 --destructive-foreground: oklch(100% 0.00011 271.152);14 --border: oklch(88.09% 0.00941 258.48);15 --input: oklch(93.1% 0.00011 271.152);16 --ring: oklch(0% 0 0);17}
What is OKLCH?
OKLCH is a modern color format that offers better control over brightness and saturation than HSL or RGB. The syntax is:
1oklch(lightness chroma hue)
- Lightness: 0% = black, 100% = white
- Chroma: 0 = gray, ~0.4 = highly saturated
- Hue: 0-360 degrees of color
You can use tools like oklch.com to choose colors visually.
Customizing colors
Changing existing colors
Modify the variables directly in your CSS file:
1:root {2 --primary: oklch(65% 0.25 150); /* Green */3 --primary-foreground: oklch(100% 0 0); /* White */4}
Adding new colors
1. Define the variables:
1:root {2 --success: oklch(75% 0.15 145);3 --success-foreground: oklch(15% 0.01 145);4}56.dark {7 --success: oklch(55% 0.12 145);8 --success-foreground: oklch(95% 0.005 145);9}
2. Extend the
@theme1@theme inline {2 --color-success: var(--success);3 --color-success-foreground: var(--success-foreground);4}
3. Use them in your components:
1<Alert className="bg-success text-success-foreground">Operation successful!</Alert>
Border radius
Control how rounded the corners of all components are:
1:root {2 --radius: 0.625rem; /* 10px by default */3}
Available variants:
rounded-sm→ 6pxrounded-md→ 8pxrounded-lg→ 10px (base value)rounded-xl→ 14pxrounded-2xl→ 18px
For more rounded corners throughout your app:
1:root {2 --radius: 1rem; /* 16px */3}
Custom themes
You can create multiple themes beyond light and dark. Here are some predefined themes you can use:
Ocean
A calm blue theme inspired by the sea:
1:root {2 --background: oklch(98% 0.008 230);3 --foreground: oklch(20% 0.01 230);4 --card: oklch(99% 0.005 230);5 --card-foreground: oklch(20% 0.01 230);6 --primary: oklch(55% 0.18 230);7 --primary-foreground: oklch(100% 0 0);8 --secondary: oklch(87% 0.06 220);9 --secondary-foreground: oklch(25% 0.01 220);10 --muted: oklch(92% 0.025 230);11 --muted-foreground: oklch(45% 0.02 230);12 --accent: oklch(88% 0.09 210);13 --accent-foreground: oklch(25% 0.01 210);14 --destructive: oklch(62% 0.17 25);15 --destructive-foreground: oklch(98% 0 0);16 --border: oklch(87% 0.03 230);17 --input: oklch(91% 0.025 230);18 --ring: oklch(55% 0.18 230);19}2021.dark {22 --background: oklch(20% 0.02 230);23 --foreground: oklch(96% 0.008 230);24 --card: oklch(23% 0.018 230);25 --card-foreground: oklch(96% 0.008 230);26 --primary: oklch(70% 0.18 230);27 --primary-foreground: oklch(15% 0.01 230);28 --secondary: oklch(32% 0.04 230);29 --secondary-foreground: oklch(95% 0.008 230);30 --muted: oklch(28% 0.02 230);31 --muted-foreground: oklch(75% 0.015 230);32 --accent: oklch(40% 0.06 210);33 --accent-foreground: oklch(95% 0.01 210);34 --destructive: oklch(60% 0.18 25);35 --destructive-foreground: oklch(20% 0.01 25);36 --border: oklch(30% 0.02 230);37 --input: oklch(25% 0.018 230);38 --ring: oklch(70% 0.18 230);39}
Forest
A natural green theme:
1:root {2 --background: oklch(98% 0.008 140);3 --foreground: oklch(18% 0.01 140);4 --card: oklch(99% 0.005 140);5 --card-foreground: oklch(18% 0.01 140);6 --primary: oklch(48% 0.16 145);7 --primary-foreground: oklch(100% 0 0);8 --secondary: oklch(88% 0.07 130);9 --secondary-foreground: oklch(25% 0.01 130);10 --muted: oklch(92% 0.025 140);11 --muted-foreground: oklch(45% 0.02 140);12 --accent: oklch(88% 0.085 150);13 --accent-foreground: oklch(25% 0.01 150);14 --destructive: oklch(62% 0.16 25);15 --destructive-foreground: oklch(98% 0 0);16 --border: oklch(87% 0.03 140);17 --input: oklch(91% 0.025 140);18 --ring: oklch(48% 0.16 145);19}2021.dark {22 --background: oklch(18% 0.02 140);23 --foreground: oklch(95% 0.01 140);24 --card: oklch(22% 0.02 140);25 --card-foreground: oklch(95% 0.01 140);26 --primary: oklch(70% 0.16 145);27 --primary-foreground: oklch(15% 0.01 145);28 --secondary: oklch(30% 0.04 130);29 --secondary-foreground: oklch(95% 0.01 130);30 --muted: oklch(27% 0.02 140);31 --muted-foreground: oklch(75% 0.015 140);32 --accent: oklch(38% 0.06 150);33 --accent-foreground: oklch(95% 0.01 150);34 --destructive: oklch(60% 0.18 25);35 --destructive-foreground: oklch(20% 0.01 25);36 --border: oklch(30% 0.02 140);37 --input: oklch(25% 0.018 140);38 --ring: oklch(70% 0.16 145);39}
Sunset
A warm orange and pink theme:
1:root {2 --background: oklch(98% 0.015 40);3 --foreground: oklch(20% 0.01 40);4 --card: oklch(99% 0.01 40);5 --card-foreground: oklch(20% 0.01 40);6 --primary: oklch(60% 0.2 30);7 --primary-foreground: oklch(100% 0 0);8 --secondary: oklch(88% 0.09 50);9 --secondary-foreground: oklch(22% 0.01 50);10 --muted: oklch(92% 0.03 40);11 --muted-foreground: oklch(45% 0.02 40);12 --accent: oklch(88% 0.11 20);13 --accent-foreground: oklch(22% 0.01 20);14 --destructive: oklch(60% 0.18 25);15 --destructive-foreground: oklch(98% 0 0);16 --border: oklch(87% 0.04 40);17 --input: oklch(91% 0.03 40);18 --ring: oklch(60% 0.2 30);19}2021.dark {22 --background: oklch(20% 0.02 40);23 --foreground: oklch(96% 0.015 40);24 --card: oklch(23% 0.02 40);25 --card-foreground: oklch(96% 0.015 40);26 --primary: oklch(70% 0.2 30);27 --primary-foreground: oklch(20% 0.01 30);28 --secondary: oklch(32% 0.05 50);29 --secondary-foreground: oklch(95% 0.01 50);30 --muted: oklch(28% 0.02 40);31 --muted-foreground: oklch(75% 0.015 40);32 --accent: oklch(40% 0.07 20);33 --accent-foreground: oklch(95% 0.01 20);34 --destructive: oklch(60% 0.18 25);35 --destructive-foreground: oklch(20% 0.01 25);36 --border: oklch(30% 0.02 40);37 --input: oklch(25% 0.018 40);38 --ring: oklch(70% 0.2 30);39}
Midnight
A deep purple theme perfect for creative apps:
1:root {2 --background: oklch(97% 0.015 280);3 --foreground: oklch(20% 0.01 280);4 --card: oklch(98% 0.01 280);5 --card-foreground: oklch(20% 0.01 280);6 --primary: oklch(60% 0.22 290);7 --primary-foreground: oklch(100% 0 0);8 --secondary: oklch(88% 0.06 280);9 --secondary-foreground: oklch(22% 0.01 280);10 --muted: oklch(92% 0.025 280);11 --muted-foreground: oklch(45% 0.02 280);12 --accent: oklch(88% 0.09 270);13 --accent-foreground: oklch(22% 0.01 270);14 --destructive: oklch(62% 0.17 25);15 --destructive-foreground: oklch(98% 0 0);16 --border: oklch(87% 0.03 280);17 --input: oklch(91% 0.025 280);18 --ring: oklch(60% 0.22 290);19}2021.dark {22 --background: oklch(15% 0.02 280);23 --foreground: oklch(96% 0.01 280);24 --card: oklch(18% 0.02 280);25 --card-foreground: oklch(96% 0.01 280);26 --primary: oklch(70% 0.22 290);27 --primary-foreground: oklch(20% 0.01 290);28 --secondary: oklch(30% 0.05 280);29 --secondary-foreground: oklch(95% 0.01 280);30 --muted: oklch(25% 0.017 280);31 --muted-foreground: oklch(70% 0.015 280);32 --accent: oklch(35% 0.06 270);33 --accent-foreground: oklch(96% 0.01 270);34 --destructive: oklch(60% 0.18 25);35 --destructive-foreground: oklch(20% 0.01 25);36 --border: oklch(25% 0.018 280);37 --input: oklch(20% 0.015 280);38 --ring: oklch(70% 0.22 290);39}
Rose
A soft pink theme:
1:root {2 --background: oklch(98% 0.02 350);3 --foreground: oklch(20% 0.01 350);4 --card: oklch(99% 0.015 350);5 --card-foreground: oklch(20% 0.01 350);6 --primary: oklch(58% 0.18 340);7 --primary-foreground: oklch(100% 0 0);8 --secondary: oklch(88% 0.07 355);9 --secondary-foreground: oklch(22% 0.01 355);10 --muted: oklch(92% 0.03 350);11 --muted-foreground: oklch(45% 0.02 350);12 --accent: oklch(88% 0.1 345);13 --accent-foreground: oklch(22% 0.01 345);14 --destructive: oklch(60% 0.18 25);15 --destructive-foreground: oklch(98% 0 0);16 --border: oklch(87% 0.04 350);17 --input: oklch(91% 0.03 350);18 --ring: oklch(58% 0.18 340);19}2021.dark {22 --background: oklch(20% 0.02 350);23 --foreground: oklch(96% 0.015 350);24 --card: oklch(23% 0.02 350);25 --card-foreground: oklch(96% 0.015 350);26 --primary: oklch(70% 0.18 340);27 --primary-foreground: oklch(20% 0.01 340);28 --secondary: oklch(32% 0.05 355);29 --secondary-foreground: oklch(95% 0.01 355);30 --muted: oklch(28% 0.02 350);31 --muted-foreground: oklch(75% 0.015 350);32 --accent: oklch(40% 0.07 345);33 --accent-foreground: oklch(95% 0.01 345);34 --destructive: oklch(60% 0.18 25);35 --destructive-foreground: oklch(20% 0.01 25);36 --border: oklch(30% 0.02 350);37 --input: oklch(25% 0.018 350);38 --ring: oklch(70% 0.18 340);39}
Cyber
A vibrant cyan theme for tech products:
1:root {2 --background: oklch(97% 0.015 200);3 --foreground: oklch(18% 0.01 200);4 --card: oklch(98% 0.01 200);5 --card-foreground: oklch(18% 0.01 200);6 --primary: oklch(70% 0.23 195);7 --primary-foreground: oklch(10% 0.01 195);8 --secondary: oklch(88% 0.06 200);9 --secondary-foreground: oklch(22% 0.01 200);10 --muted: oklch(92% 0.025 200);11 --muted-foreground: oklch(45% 0.02 200);12 --accent: oklch(60% 0.18 180);13 --accent-foreground: oklch(10% 0.01 180);14 --destructive: oklch(60% 0.18 25);15 --destructive-foreground: oklch(98% 0 0);16 --border: oklch(87% 0.03 200);17 --input: oklch(91% 0.025 200);18 --ring: oklch(70% 0.23 195);19}2021.dark {22 --background: oklch(10% 0.02 200);23 --foreground: oklch(96% 0.01 200);24 --card: oklch(13% 0.02 200);25 --card-foreground: oklch(96% 0.01 200);26 --primary: oklch(70% 0.23 195);27 --primary-foreground: oklch(15% 0.01 195);28 --secondary: oklch(25% 0.04 200);29 --secondary-foreground: oklch(95% 0.01 200);30 --muted: oklch(20% 0.02 200);31 --muted-foreground: oklch(70% 0.015 200);32 --accent: oklch(55% 0.18 180);33 --accent-foreground: oklch(15% 0.01 180);34 --destructive: oklch(60% 0.18 25);35 --destructive-foreground: oklch(20% 0.01 25);36 --border: oklch(20% 0.018 200);37 --input: oklch(15% 0.015 200);38 --ring: oklch(70% 0.23 195);39}
Tips
- Always maintain the
backgroundandforegroundpair for good contrast - Use oklch.com to choose colors visually
- Test your colors in both light and dark mode
- Check accessibility contrast (minimum 4.5:1 for normal text)