Snippets / Color /

Status Colors in OKLCH

A complete set of semantic status colors — success, warning, error, info — defined in OKLCH for perceptual consistency.

Success Warning Error Info
Widely Supported
colorno-js

Quick implementation

:root {
  --color-success: oklch(0.75 0.18 145);
  --color-warning: oklch(0.80 0.16 85);
  --color-error: oklch(0.65 0.22 25);
  --color-info: oklch(0.70 0.15 265);
}

.status-badge {
  display: inline-flex;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-sans);
}

.status-badge--success {
  background-color: oklch(0.95 0.05 145);
  color: oklch(0.45 0.12 145);
}

.status-badge--warning {
  background-color: oklch(0.96 0.04 85);
  color: oklch(0.50 0.12 85);
}

.status-badge--error {
  background-color: oklch(0.94 0.06 25);
  color: oklch(0.50 0.15 25);
}

.status-badge--info {
  background-color: oklch(0.94 0.04 265);
  color: oklch(0.45 0.12 265);
}

Prompt this to your LLM

Includes role, constraints, two framework variants, and edge cases to handle.

Act as a senior CSS engineer. Create a set of CSS custom properties for semantic status colors (success, warning, error, info) using the oklch() color space.

Requirements:
1. Use oklch() for all colors to ensure perceptual uniformity.
2. Define the following hues:
   - Success: ~145 (Green)
   - Warning: ~85 (Yellow)
   - Error: ~25 (Red)
   - Info: ~265 (Blue)
3. Create a base class .status-badge and modifier classes for each status.
4. Ensure text contrast is accessible (light backgrounds, dark text).
5. Provide two variants:
   a) Standard CSS variables.
   b) Tailwind CSS configuration snippet.

Output only the code blocks.

Why this matters in 2026

OKLCH is now the standard for defining colors in modern CSS because it aligns with human perception. Unlike HSL, where changing lightness doesn't always result in a predictable visual change, OKLCH ensures that a 10% change in lightness looks consistent across all hues.

The logic

We define specific hues for semantic meaning: green for success, yellow for warning, red for error, and blue for info. By using oklch(), we can easily create lighter background variants (e.g., oklch(0.95 ...)) and darker text variants (e.g., oklch(0.45 ...)) while maintaining perfect color harmony.

Accessibility & performance

These colors are tuned for WCAG AA contrast ratios when paired with the specified text colors. Since oklch() is natively supported in modern browsers, no preprocessor or polyfill is needed, keeping the CSS payload minimal and the rendering fast.