tailwind-oklch plugin

tw/ok

Bringing the Tailwind CSS philosophy of atomic utility classes to the color variables that power OKLCH. Tailwind OKLCH lets you set full color values or change one parameter at a time – no more opacity hacks required. Re-theme your whole app with just a variable or a class.

Theme Controls

Tailwind OKLCH gives you Tailwind-style, fine-grained control over your colors. Every color is built from three independent dimensions — hue, luminance, and chroma — each adjustable with utility classes or CSS variables.

Hues

Luminance Range(dark mode)

base (0): 0.12fore (10): 0.92
bg-h-primary · bg-c-mid (0.12)

Chroma Stops

bg-h-primary · bg-lc-5 (0.52)

Chroma controls saturation intensity — from nearly neutral (lo) to fully vivid (hi).

bg-5-mid-primary
bg-5-mid-primary=L - C - H
bg-lc-5
bg-c-mid
bg-h-primary

5×5 Luminance × Chroma Grid

Each matrix shows chroma (rows, hi→lo) × luminance (columns, 0→10) for a given hue. Hover to see the class name.

primary (233°)

lc‑0
lc‑2
lc‑5
lc‑8
lc‑10
c‑hi
c‑mhi
c‑mid
c‑mlo
c‑lo

accent (350°)

lc‑0
lc‑2
lc‑5
lc‑8
lc‑10
c‑hi
c‑mhi
c‑mid
c‑mlo
c‑lo

success (145°)

lc‑0
lc‑2
lc‑5
lc‑8
lc‑10
c‑hi
c‑mhi
c‑mid
c‑mlo
c‑lo

warning (55°)

lc‑0
lc‑2
lc‑5
lc‑8
lc‑10
c‑hi
c‑mhi
c‑mid
c‑mlo
c‑lo

danger (15°)

lc‑0
lc‑2
lc‑5
lc‑8
lc‑10
c‑hi
c‑mhi
c‑mid
c‑mlo
c‑lo

info (220°)

lc‑0
lc‑2
lc‑5
lc‑8
lc‑10
c‑hi
c‑mhi
c‑mid
c‑mlo
c‑lo

Live Component Examples

HTML
<div class="hue-primary bg-1-lo text-10-lo border-1-lo rounded-xl p-6 border">
  <h4 class="text-[0.85rem] mb-3 font-semibold">Multi-Hue Composition</h4>
  <p class="text-lc-6 text-[0.85rem] leading-normal mb-4">
    hue-primary on the container. Badges swap hue — L and C stay identical.
  </p>
  <div class="flex flex-wrap gap-2 mt-2 *:px-3 *:py-1 *:rounded-full *:text-xs *:font-semibold">
    <span class="hue-primary bg-3-mid text-10-lo">primary</span>
    <span class="hue-accent bg-3-mid text-10-lo">accent</span>
    <span class="hue-warning bg-3-mid text-10-lo">warning</span>
    <span class="hue-success bg-3-mid text-10-lo">success</span>
    <span class="hue-info bg-3-mid text-10-lo">info</span>
    <span class="hue-danger bg-3-mid text-10-lo">danger</span>
  </div>
</div>

Multi-Hue Composition

hue-primary on the container. Badges swap hue — L and C stay identical:

primary accent warning success info danger
HTML
<div class="bg-3-mhi-accent text-10-lo-accent border-8-lo-primary rounded-xl p-6 border">
  <h4 class="text-[0.85rem] mb-3 font-semibold">Cascade Override</h4>
  <p class="text-[0.85rem] leading-normal mb-4">
    Parent sets bg-3-mhi-accent. Children inherit chroma + hue,
    override only luminance.
  </p>
  <div class="flex gap-2 font-mono font-semibold *:px-4 *:py-2 *:rounded-lg *:text-[0.75rem]">
    <div class="bg-lc-0 text-10-lo-accent">bg-lc-0</div>
    <div class="bg-lc-7 text-1-mlo-accent">bg-lc-7</div>
    <div class="bg-lc-10 text-1-mid-accent">bg-lc-10</div>
  </div>
</div>

Cascade Override

Parent sets bg-3-mhi-accent. Children inherit chroma + hue, override only luminance — no need to redeclare the full color.

bg-lc-0
bg-lc-7
bg-lc-10
HTML
<div class="bg-0-lo-success text-6-mid-success border-5-mhi-success rounded-xl p-6 border">
  <h4 class="text-[0.85rem] mb-3 font-semibold">Chroma for Activity</h4>
  <p class="text-5-mlo-success text-[0.85rem] leading-normal mb-4">
    On hover, these buttons increase chroma and get a little shadow.
  </p>
  <div class="flex gap-2 *:px-5 *:py-2 *:rounded-lg *:text-[0.8rem] *:font-semibold *:cursor-pointer *:transition-all *:duration-150 *:border *:hover:shadow">
    <div class="bg-3-mid-success text-10-lo-success hover:bg-c-mhi hover:border-c-mid">success</div>
    <div class="bg-0-lo-success text-8-mhi-success border-2-mid-success hover:bg-c-mlo hover:border-c-mhi">outline</div>
  </div>
</div>

Chroma for Activity

On hover, these buttons increase chroma and get a little shadow. Subtle, pleasing, unlikely to distract.

success
outline
HTML
<div class="bg-0-mlo-primary text-7-mid-primary border-3-mid-primary rounded-xl p-6 border">
  <h4 class="text-[0.85rem] mb-3 font-semibold">Luminance for Emphasis</h4>
  <p class="text-lc-5 text-[0.85rem] leading-normal mb-4">
    Every element uses the same chroma and hue. Other elements only
    change luminance. Excellent for accessibility.
  </p>
  <div class="flex gap-2 *:px-5 *:py-2 *:rounded-lg *:text-[0.8rem] *:font-semibold *:cursor-pointer *:transition-all *:duration-150 *:border *:shadow">
    <div class="bg-lc-6 text-lc-1 border-lc-5 hover:bg-lc-5 hover:border-lc-4 hover:text-lc-0">primary</div>
    <div class="border-lc-1 hover:text-lc-6 hover:bg-lc-1 hover:border-lc-3">outline</div>
  </div>
</div>

Luminance for Emphasis

Every element in his card uses the same chroma and hue. Other elements only change luminance. Excellent for accessibility.

primary
outline
HTML
<div class="hue-danger bg-1-mid text-10-lo border-3-mhi rounded-xl p-6 border">
  <h4 class="text-[0.85rem] mb-3 font-semibold">Danger Alert</h4>
  <p class="text-8-mlo text-[0.85rem] leading-normal mb-4">
    hue-danger on the container — every child inherits the hue.
    Only L and C vary per element.
  </p>
  <div class="flex gap-2 *:px-5 *:py-2 *:rounded-lg *:text-[0.8rem] *:font-semibold *:border-0 *:cursor-pointer *:transition-all *:duration-150">
    <div class="bg-5-mhi text-0-lo">Acknowledge</div>
    <div class="bg-5-mhi text-10-lo">Cancel</div>
  </div>
</div>

Danger Alert

hue-danger on the container — every child inherits the hue. Only L and C vary per element.

Acknowledge
Cancel
HTML
<div class="bg-1-mlo-primary text-10-lo-primary border-1-lo-primary rounded-xl p-6 border">
  <h4 class="text-[0.85rem] mb-3 font-semibold">Axis Inheritance</h4>
  <p class="text-5-lo-primary text-[0.85rem] leading-normal mb-4">
    Parent sets hue to primary. Children swap only the hue axis —
    luminance and chroma stay inherited.
  </p>
  <div class="flex gap-2 mt-2 font-mono font-semibold *:bg-lc-3 *:bg-c-mid *:text-center *:px-3 *:py-1.5 *:rounded-full *:text-xs">
    <span class="bg-h-success text-10-lo-success">bg-h-success</span>
    <span class="bg-h-warning text-10-lo-warning">bg-h-warning</span>
    <span class="bg-h-danger text-10-lo-danger">bg-h-danger</span>
  </div>
</div>

Axis Inheritance

Parent sets hue to primary. Children swap only the hue axis — luminance and chroma stay inherited.

bg-h-success bg-h-warning bg-h-danger
HTML
<div class="hue-[180] chroma-[15] bg-lc-[15] text-lc-[90] border-lc-[30] rounded-xl p-6 border">
  <h4 class="text-[0.85rem] mb-3 font-semibold">Arbitrary Values</h4>
  <p class="text-lc-[65] text-[0.85rem] leading-normal mb-4">
    hue-[180] for a custom hue, chroma-[15] for exact chroma.
    Luminance auto-flips between light and dark mode.
  </p>
  <div class="flex flex-wrap gap-2 mt-2 *:px-3 *:py-1 *:rounded-full *:text-xs *:font-semibold">
    <span class="bg-lc-[30] text-lc-[90]">lc-[30]</span>
    <span class="bg-lc-[50] text-lc-[95]">lc-[50]</span>
    <span class="bg-lc-[70] text-lc-[15]">lc-[70]</span>
  </div>
</div>

Arbitrary Values

hue-[180] for a custom hue, chroma-[15] for exact chroma. Luminance auto-flips between light and dark mode.

lc-[30] lc-[50] lc-[70]

Using Hue Context

Set hue-* once on a container and every child inherits it. Elements only specify luminance and chroma via two-axis shorthands like bg-5-mhi — no hue suffix needed. Click a hue to re-theme the showcase.

Project Settings

Manage your project configuration and team preferences.

3 new notifications

You have unread messages from your team.

ActiveDraftArchived

Email notifications

Receive updates about activity.

2,847

Users

$48k

Revenue

+12%

Growth

One hue-primary class on the container. Every element inside uses two-axis shorthands like bg-5-mhi and text-10-lo — no hue suffix needed. Click a different hue above and the entire showcase re-themes instantly.

Relative Luminance Offsets

Sometimes you don't need an absolute luminance step — you just want a little lighter or a little darker than whatever the parent set. bg-lc-up-1 pushes toward the viewer (brighter in dark mode, darker in light mode) while bg-lc-down-1 recedes. Perfect for hover states, active items, and subtle depth — the same classes work on every base color.

Each navbar sets a single base color. bg-lc-up-1 and bg-lc-down-1 nudge luminance toward or away from the viewer — the direction flips automatically in dark mode. Same utility classes, every hue.

Implementation

/* ── your-project.css ────────────────────────────────────────
   Import tailwind-oklch into your Tailwind v4 project. */

@import "tailwindcss";
@import "tailwind-oklch";
@plugin "tailwind-oklch/plugin";

/* That's it. You now have:

   SHORTHAND    bg-5-hi-primary          one class, full color
   DECOMPOSED   bg-lc-5 bg-c-hi bg-h-primary   per-axis control
   CASCADING    parent sets color, child overrides one axis

   Luminance contrast 0–10 scale:
     0 / base  = close to the page color (blends in)
     10 / fore = high contrast with the page (stands out)
     1–9       = evenly distributed increments

   To customize hues, override in your own @theme block: */

@theme {
  --hue-primary: 180;  /* teal instead of purple */
  --hue-accent:  320;  /* pink instead of orange */
}

/* To shift the luminance contrast range: */
:root {
  --lc-range-start: 0.95;  /* light-mode base/0 */
  --lc-range-end:   0.15;  /* light-mode fore/10 */
}
.dark {
  --lc-range-start: 0.12;  /* dark-mode base/0 */
  --lc-range-end:   0.92;  /* dark-mode fore/10 */
}