343 lines
9.4 KiB
Markdown
343 lines
9.4 KiB
Markdown
# Complete Theming Reference
|
|
|
|
## CSS Variables Structure
|
|
|
|
### Required Variables
|
|
|
|
```css
|
|
:root {
|
|
--radius: 0.625rem;
|
|
--background: oklch(1 0 0);
|
|
--foreground: oklch(0.145 0 0);
|
|
--card: oklch(1 0 0);
|
|
--card-foreground: oklch(0.145 0 0);
|
|
--popover: oklch(1 0 0);
|
|
--popover-foreground: oklch(0.145 0 0);
|
|
--primary: oklch(0.205 0 0);
|
|
--primary-foreground: oklch(0.985 0 0);
|
|
--secondary: oklch(0.97 0 0);
|
|
--secondary-foreground: oklch(0.205 0 0);
|
|
--muted: oklch(0.97 0 0);
|
|
--muted-foreground: oklch(0.556 0 0);
|
|
--accent: oklch(0.97 0 0);
|
|
--accent-foreground: oklch(0.205 0 0);
|
|
--destructive: oklch(0.577 0.245 27.325);
|
|
--border: oklch(0.922 0 0);
|
|
--input: oklch(0.922 0 0);
|
|
--ring: oklch(0.708 0 0);
|
|
}
|
|
|
|
.dark {
|
|
--background: oklch(0.145 0 0);
|
|
--foreground: oklch(0.985 0 0);
|
|
--card: oklch(0.205 0 0);
|
|
--card-foreground: oklch(0.985 0 0);
|
|
--popover: oklch(0.269 0 0);
|
|
--popover-foreground: oklch(0.985 0 0);
|
|
--primary: oklch(0.922 0 0);
|
|
--primary-foreground: oklch(0.205 0 0);
|
|
--secondary: oklch(0.269 0 0);
|
|
--secondary-foreground: oklch(0.985 0 0);
|
|
--muted: oklch(0.269 0 0);
|
|
--muted-foreground: oklch(0.708 0 0);
|
|
--accent: oklch(0.371 0 0);
|
|
--accent-foreground: oklch(0.985 0 0);
|
|
--destructive: oklch(0.704 0.191 22.216);
|
|
--border: oklch(1 0 0 / 10%);
|
|
--input: oklch(1 0 0 / 15%);
|
|
--ring: oklch(0.556 0 0);
|
|
}
|
|
|
|
@theme inline {
|
|
--color-background: var(--background);
|
|
--color-foreground: var(--foreground);
|
|
--color-card: var(--card);
|
|
--color-card-foreground: var(--card-foreground);
|
|
--color-popover: var(--popover);
|
|
--color-popover-foreground: var(--popover-foreground);
|
|
--color-primary: var(--primary);
|
|
--color-primary-foreground: var(--primary-foreground);
|
|
--color-secondary: var(--secondary);
|
|
--color-secondary-foreground: var(--secondary-foreground);
|
|
--color-muted: var(--muted);
|
|
--color-muted-foreground: var(--muted-foreground);
|
|
--color-accent: var(--accent);
|
|
--color-accent-foreground: var(--accent-foreground);
|
|
--color-destructive: var(--destructive);
|
|
--color-border: var(--border);
|
|
--color-input: var(--input);
|
|
--color-ring: var(--ring);
|
|
}
|
|
```
|
|
|
|
## Complete Base Color Palettes
|
|
|
|
### Neutral (Default)
|
|
|
|
```css
|
|
:root {
|
|
--radius: 0.625rem;
|
|
--background: oklch(1 0 0);
|
|
--foreground: oklch(0.145 0 0);
|
|
--card: oklch(1 0 0);
|
|
--card-foreground: oklch(0.145 0 0);
|
|
--popover: oklch(1 0 0);
|
|
--popover-foreground: oklch(0.145 0 0);
|
|
--primary: oklch(0.205 0 0);
|
|
--primary-foreground: oklch(0.985 0 0);
|
|
--secondary: oklch(0.97 0 0);
|
|
--secondary-foreground: oklch(0.205 0 0);
|
|
--muted: oklch(0.97 0 0);
|
|
--muted-foreground: oklch(0.556 0 0);
|
|
--accent: oklch(0.97 0 0);
|
|
--accent-foreground: oklch(0.205 0 0);
|
|
--destructive: oklch(0.577 0.245 27.325);
|
|
--border: oklch(0.922 0 0);
|
|
--input: oklch(0.922 0 0);
|
|
--ring: oklch(0.708 0 0);
|
|
}
|
|
|
|
.dark {
|
|
--background: oklch(0.145 0 0);
|
|
--foreground: oklch(0.985 0 0);
|
|
--card: oklch(0.205 0 0);
|
|
--card-foreground: oklch(0.985 0 0);
|
|
--popover: oklch(0.205 0 0);
|
|
--popover-foreground: oklch(0.985 0 0);
|
|
--primary: oklch(0.922 0 0);
|
|
--primary-foreground: oklch(0.205 0 0);
|
|
--secondary: oklch(0.269 0 0);
|
|
--secondary-foreground: oklch(0.985 0 0);
|
|
--muted: oklch(0.269 0 0);
|
|
--muted-foreground: oklch(0.708 0 0);
|
|
--accent: oklch(0.269 0 0);
|
|
--accent-foreground: oklch(0.985 0 0);
|
|
--destructive: oklch(0.704 0.191 22.216);
|
|
--border: oklch(1 0 0 / 10%);
|
|
--input: oklch(1 0 0 / 15%);
|
|
--ring: oklch(0.556 0 0);
|
|
}
|
|
```
|
|
|
|
### Zinc (Blue-Gray)
|
|
|
|
```css
|
|
:root {
|
|
--background: oklch(1 0 0);
|
|
--foreground: oklch(0.141 0.005 285.823);
|
|
--primary: oklch(0.21 0.006 285.885);
|
|
--primary-foreground: oklch(0.985 0 0);
|
|
--secondary: oklch(0.967 0.001 286.375);
|
|
--secondary-foreground: oklch(0.21 0.006 285.885);
|
|
--muted: oklch(0.967 0.001 286.375);
|
|
--muted-foreground: oklch(0.552 0.016 285.938);
|
|
--border: oklch(0.92 0.004 286.32);
|
|
}
|
|
|
|
.dark {
|
|
--background: oklch(0.141 0.005 285.823);
|
|
--foreground: oklch(0.985 0 0);
|
|
--primary: oklch(0.92 0.004 286.32);
|
|
--primary-foreground: oklch(0.21 0.006 285.885);
|
|
--secondary: oklch(0.274 0.006 286.033);
|
|
--secondary-foreground: oklch(0.985 0 0);
|
|
--muted: oklch(0.274 0.006 286.033);
|
|
--muted-foreground: oklch(0.705 0.015 286.067);
|
|
}
|
|
```
|
|
|
|
### Slate (Balanced Blue-Gray)
|
|
|
|
```css
|
|
:root {
|
|
--background: oklch(1 0 0);
|
|
--foreground: oklch(0.129 0.042 264.695);
|
|
--primary: oklch(0.208 0.042 265.755);
|
|
--primary-foreground: oklch(0.984 0.003 247.858);
|
|
--secondary: oklch(0.968 0.007 247.896);
|
|
--secondary-foreground: oklch(0.208 0.042 265.755);
|
|
--muted: oklch(0.968 0.007 247.896);
|
|
--muted-foreground: oklch(0.554 0.046 257.417);
|
|
--border: oklch(0.929 0.013 255.508);
|
|
}
|
|
|
|
.dark {
|
|
--background: oklch(0.129 0.042 264.695);
|
|
--foreground: oklch(0.984 0.003 247.858);
|
|
--primary: oklch(0.929 0.013 255.508);
|
|
--primary-foreground: oklch(0.208 0.042 265.755);
|
|
--secondary: oklch(0.279 0.041 260.031);
|
|
--secondary-foreground: oklch(0.984 0.003 247.858);
|
|
--muted: oklch(0.279 0.041 260.031);
|
|
--muted-foreground: oklch(0.704 0.04 256.788);
|
|
}
|
|
```
|
|
|
|
### Stone (Warm Brown-Gray)
|
|
|
|
```css
|
|
:root {
|
|
--background: oklch(1 0 0);
|
|
--foreground: oklch(0.147 0.004 49.25);
|
|
--primary: oklch(0.216 0.006 56.043);
|
|
--primary-foreground: oklch(0.985 0.001 106.423);
|
|
--secondary: oklch(0.97 0.001 106.424);
|
|
--secondary-foreground: oklch(0.216 0.006 56.043);
|
|
--muted: oklch(0.97 0.001 106.424);
|
|
--muted-foreground: oklch(0.553 0.013 58.071);
|
|
--border: oklch(0.923 0.003 48.717);
|
|
}
|
|
|
|
.dark {
|
|
--background: oklch(0.147 0.004 49.25);
|
|
--foreground: oklch(0.985 0.001 106.423);
|
|
--primary: oklch(0.923 0.003 48.717);
|
|
--primary-foreground: oklch(0.216 0.006 56.043);
|
|
--secondary: oklch(0.268 0.007 34.298);
|
|
--secondary-foreground: oklch(0.985 0.001 106.423);
|
|
--muted: oklch(0.268 0.007 34.298);
|
|
--muted-foreground: oklch(0.709 0.01 56.259);
|
|
}
|
|
```
|
|
|
|
### Gray (Purple-Gray)
|
|
|
|
```css
|
|
:root {
|
|
--background: oklch(1 0 0);
|
|
--foreground: oklch(0.13 0.028 261.692);
|
|
--primary: oklch(0.21 0.034 264.665);
|
|
--primary-foreground: oklch(0.985 0.002 247.839);
|
|
--secondary: oklch(0.967 0.003 264.542);
|
|
--secondary-foreground: oklch(0.21 0.034 264.665);
|
|
--muted: oklch(0.967 0.003 264.542);
|
|
--muted-foreground: oklch(0.551 0.027 264.364);
|
|
--border: oklch(0.928 0.006 264.531);
|
|
}
|
|
|
|
.dark {
|
|
--background: oklch(0.13 0.028 261.692);
|
|
--foreground: oklch(0.985 0.002 247.839);
|
|
--primary: oklch(0.928 0.006 264.531);
|
|
--primary-foreground: oklch(0.21 0.034 264.665);
|
|
--secondary: oklch(0.278 0.033 256.848);
|
|
--secondary-foreground: oklch(0.985 0.002 247.839);
|
|
--muted: oklch(0.278 0.033 256.848);
|
|
--muted-foreground: oklch(0.707 0.022 261.325);
|
|
}
|
|
```
|
|
|
|
## Adding Custom Colors
|
|
|
|
```css
|
|
/* Add new color to root */
|
|
:root {
|
|
--warning: oklch(0.84 0.16 84);
|
|
--warning-foreground: oklch(0.28 0.07 46);
|
|
}
|
|
|
|
.dark {
|
|
--warning: oklch(0.41 0.11 46);
|
|
--warning-foreground: oklch(0.99 0.02 95);
|
|
}
|
|
|
|
/* Map to Tailwind */
|
|
@theme inline {
|
|
--color-warning: var(--warning);
|
|
--color-warning-foreground: var(--warning-foreground);
|
|
}
|
|
```
|
|
|
|
Usage:
|
|
```tsx
|
|
<div className="bg-warning text-warning-foreground">
|
|
Warning message
|
|
</div>
|
|
```
|
|
|
|
## Chart Colors
|
|
|
|
```css
|
|
:root {
|
|
--chart-1: oklch(0.646 0.222 41.116);
|
|
--chart-2: oklch(0.6 0.118 184.704);
|
|
--chart-3: oklch(0.398 0.07 227.392);
|
|
--chart-4: oklch(0.828 0.189 84.429);
|
|
--chart-5: oklch(0.769 0.188 70.08);
|
|
}
|
|
|
|
.dark {
|
|
--chart-1: oklch(0.488 0.243 264.376);
|
|
--chart-2: oklch(0.696 0.17 162.48);
|
|
--chart-3: oklch(0.769 0.188 70.08);
|
|
--chart-4: oklch(0.627 0.265 303.9);
|
|
--chart-5: oklch(0.645 0.246 16.439);
|
|
}
|
|
```
|
|
|
|
## Sidebar Colors (Optional)
|
|
|
|
```css
|
|
:root {
|
|
--sidebar: oklch(0.985 0 0);
|
|
--sidebar-foreground: oklch(0.145 0 0);
|
|
--sidebar-primary: oklch(0.205 0 0);
|
|
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
--sidebar-accent: oklch(0.97 0 0);
|
|
--sidebar-accent-foreground: oklch(0.205 0 0);
|
|
--sidebar-border: oklch(0.922 0 0);
|
|
--sidebar-ring: oklch(0.708 0 0);
|
|
}
|
|
|
|
.dark {
|
|
--sidebar: oklch(0.205 0 0);
|
|
--sidebar-foreground: oklch(0.985 0 0);
|
|
--sidebar-primary: oklch(0.488 0.243 264.376);
|
|
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
--sidebar-accent: oklch(0.269 0 0);
|
|
--sidebar-accent-foreground: oklch(0.985 0 0);
|
|
--sidebar-border: oklch(1 0 0 / 10%);
|
|
--sidebar-ring: oklch(0.439 0 0);
|
|
}
|
|
```
|
|
|
|
## Understanding OKLCH
|
|
|
|
**Format:** `oklch(lightness chroma hue [/ alpha])`
|
|
|
|
- **Lightness** (0-1): Brightness, 0 = black, 1 = white
|
|
- **Chroma** (0-0.4): Color intensity, 0 = gray
|
|
- **Hue** (0-360): Color angle, e.g., 0/360 = red, 120 = green, 240 = blue
|
|
- **Alpha** (optional): Transparency, 0 = transparent, 1 = opaque
|
|
|
|
**Benefits:**
|
|
- Perceptually uniform (equal steps look equal)
|
|
- Consistent lightness across all hues
|
|
- Better for programmatic color manipulation
|
|
- Future-proof for modern browsers
|
|
|
|
**Examples:**
|
|
```css
|
|
/* Pure grayscale (chroma = 0) */
|
|
--background: oklch(1 0 0); /* White */
|
|
--foreground: oklch(0.145 0 0); /* Dark gray */
|
|
|
|
/* Colored (chroma > 0) */
|
|
--primary: oklch(0.577 0.245 27.325); /* Red-orange */
|
|
--accent: oklch(0.646 0.222 41.116); /* Yellow-orange */
|
|
|
|
/* With opacity */
|
|
--border: oklch(1 0 0 / 10%); /* 10% opacity white */
|
|
```
|
|
|
|
## Color Naming Convention
|
|
|
|
- **base**: Background color (no suffix)
|
|
- **base-foreground**: Text color on base background
|
|
- Always pair background/foreground for accessible contrast
|
|
|
|
Examples:
|
|
- `bg-primary` + `text-primary-foreground`
|
|
- `bg-muted` + `text-muted-foreground`
|
|
- `bg-destructive` + `text-destructive-foreground`
|