tailwind-oklch 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +49 -14
  2. package/index.css +51 -59
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -184,6 +184,36 @@ The direction automatically adapts to light/dark mode — "up" always means more
184
184
  </p>
185
185
  ```
186
186
 
187
+ ### Arbitrary Values
188
+
189
+ All three axes support arbitrary values using Tailwind's bracket syntax. This gives you fine-grained control beyond the named stops.
190
+
191
+ **Hue** — any degree value (0–360):
192
+
193
+ ```html
194
+ <div class="hue-[180] bg-3-mid">Teal background</div>
195
+ <div class="bg-h-[280] text-h-[40]">Purple bg, orange text</div>
196
+ ```
197
+
198
+ **Chroma** — integer 0–100, mapped to OKLCH 0.00–1.00 (practical range is roughly 0–25):
199
+
200
+ ```html
201
+ <div class="chroma-[8] bg-lc-3">All properties at chroma 0.08</div>
202
+ <div class="bg-c-[15]">Background chroma 0.15</div>
203
+ ```
204
+
205
+ **Luminance** — integer 0–100, with automatic light/dark mode flip:
206
+
207
+ ```html
208
+ <div class="bg-lc-[60]">
209
+ Light mode: L=0.60 · Dark mode: L=0.40
210
+ </div>
211
+ ```
212
+
213
+ Arbitrary luminance values automatically invert in dark mode (reflected around 0.50), so `bg-lc-[70]` renders as 0.70 in light mode and 0.30 in dark mode — always maintaining the same relationship to the page.
214
+
215
+ Available for all property prefixes (`bg-`, `text-`, `border-`, etc.), global setters (`hue-`, `chroma-`), and gradients (`from-`, `to-`).
216
+
187
217
  ### Gradients
188
218
 
189
219
  ```html
@@ -246,19 +276,24 @@ document.documentElement.style.setProperty('--hue-primary', '180');
246
276
 
247
277
  ### Luminance Contrast Scale
248
278
 
249
- | Stop | Dark Mode | Light Mode |
279
+ | Stop | Light Mode | Dark Mode |
250
280
  |---|---|---|
251
- | `0` / `base` | 0.12 | 0.95 |
252
- | `1` | 0.20 | 0.87 |
253
- | `2` | 0.28 | 0.79 |
254
- | `3` | 0.36 | 0.71 |
255
- | `4` | 0.44 | 0.63 |
256
- | `5` | 0.52 | 0.55 |
257
- | `6` | 0.60 | 0.47 |
258
- | `7` | 0.68 | 0.39 |
259
- | `8` | 0.76 | 0.31 |
260
- | `9` | 0.84 | 0.23 |
261
- | `10` / `fore` | 0.92 | 0.15 |
281
+ | `0` / `base` | 0.95 | 0.12 |
282
+ | `1` | 0.91 | 0.20 |
283
+ | `2` | 0.85 | 0.28 |
284
+ | `3` | 0.78 | 0.36 |
285
+ | `4` | 0.71 | 0.44 |
286
+ | `5` | 0.63 | 0.52 |
287
+ | `6` | 0.54 | 0.60 |
288
+ | `7` | 0.44 | 0.68 |
289
+ | `8` | 0.34 | 0.76 |
290
+ | `9` | 0.23 | 0.84 |
291
+ | `10` / `fore` | 0.15 | 0.92 |
292
+
293
+ Light mode uses a power curve (p≈1.3) so steps near the high-luminance
294
+ base are smaller — small luminance differences are very perceptible
295
+ against a near-white surface, so `lc-1` needs a gentler delta than the
296
+ linear 0.08 would give. Dark mode stays linear.
262
297
 
263
298
  ### Named Chroma Stops
264
299
 
@@ -270,7 +305,7 @@ document.documentElement.style.setProperty('--hue-primary', '180');
270
305
  | `mhi` | 0.18 | Vivid |
271
306
  | `hi` | 0.25 | Maximum saturation |
272
307
 
273
- A numeric chroma scale (`c-10` through `c-95`) is also available for finer control in the decomposed utilities.
308
+ For finer control, use arbitrary chroma values (see [Arbitrary Values](#arbitrary-values) below).
274
309
 
275
310
  ### LC Adjustment Steps
276
311
 
@@ -317,7 +352,7 @@ Override in a `@theme` block:
317
352
 
318
353
  ### Light / Dark Mode
319
354
 
320
- Dark mode is the default. Light mode activates when the root element does **not** have the `.dark` class (`:root:not(.dark)`). The luminance contrast scale flips automatically — `lc-0` is always near the page, `lc-10` is always high contrast — no additional classes needed.
355
+ Light mode is the default. Dark mode activates when the root element has the `.dark` class. The luminance contrast scale flips automatically — `lc-0` is always near the page, `lc-10` is always high contrast — no additional classes needed.
321
356
 
322
357
  ## License
323
358
 
package/index.css CHANGED
@@ -31,37 +31,41 @@
31
31
 
32
32
  /* ── Luminance Contrast Range ─────────────────────────────────────
33
33
  Defines the OKLCH lightness values at 0 (base) and 10 (fore).
34
- Dark mode: base is near black, fore is near white.
35
- Light mode flips them (see :root:not(.dark) below).
34
+ Light mode (default): base is near white, fore is near black.
35
+ Dark mode flips them (see .dark below).
36
36
  Override --lc-range-start and --lc-range-end to shift the range. */
37
- --lc-range-start: 0.12;
38
- --lc-range-end: 0.92;
37
+ --lc-range-start: 0.95;
38
+ --lc-range-end: 0.15;
39
39
 
40
40
  /* ── 0–10 Luminance Contrast Scale ────────────────────────────────
41
- Computed: step N = start + (end - start) × (N / 10)
42
- Dark mode (default): 0→0.12, 5→0.52, 10→0.92
43
- Light mode (override): 0→0.95, 5→0.55, 10→0.15 */
44
- --l-0: 0.12;
45
- --l-1: 0.20;
46
- --l-2: 0.28;
47
- --l-3: 0.36;
48
- --l-4: 0.44;
49
- --l-5: 0.52;
50
- --l-6: 0.60;
51
- --l-7: 0.68;
52
- --l-8: 0.76;
53
- --l-9: 0.84;
54
- --l-10: 0.92;
41
+ Light mode uses a power curve (p≈1.3): smaller steps near the
42
+ high-luminance base, growing toward the fore. Perception is
43
+ more sensitive to differences near white, so subtle surfaces
44
+ need finer L deltas there.
45
+ Computed: step N = start + (end − start) × (N / 10)^1.3
46
+ Light mode (default): 0→0.95, 1→0.91, 5→0.63, 10→0.15
47
+ Dark mode stays linear (see .dark): 0→0.12, 5→0.52, 10→0.92 */
48
+ --l-0: 0.95;
49
+ --l-1: 0.91;
50
+ --l-2: 0.85;
51
+ --l-3: 0.78;
52
+ --l-4: 0.71;
53
+ --l-5: 0.63;
54
+ --l-6: 0.54;
55
+ --l-7: 0.44;
56
+ --l-8: 0.34;
57
+ --l-9: 0.23;
58
+ --l-10: 0.15;
55
59
 
56
60
  /* Semantic aliases */
57
- --l-base: 0.12;
58
- --l-fore: 0.92;
61
+ --l-base: 0.95;
62
+ --l-fore: 0.15;
59
63
 
60
64
  /* Absolute extremes — escape the configured range entirely.
61
65
  none = beyond base (pure white in light, pure black in dark).
62
66
  full = beyond fore (pure black in light, pure white in dark). */
63
- --l-none: 0;
64
- --l-full: 1;
67
+ --l-none: 1;
68
+ --l-full: 0;
65
69
 
66
70
  /* ── Named Chroma Stops ──────────────────────────────────────────────
67
71
  OKLCH chroma: practical range 0–0.25 */
@@ -71,18 +75,6 @@
71
75
  --c-mhi: 0.18;
72
76
  --c-hi: 0.25;
73
77
 
74
- /* ── Numeric Chroma Scale ────────────────────────────────────────── */
75
- --c-10: 0.03;
76
- --c-20: 0.06;
77
- --c-30: 0.09;
78
- --c-40: 0.12;
79
- --c-50: 0.15;
80
- --c-60: 0.18;
81
- --c-70: 0.21;
82
- --c-80: 0.24;
83
- --c-90: 0.27;
84
- --c-95: 0.30;
85
-
86
78
  /* ── LC Adjustment Steps ───────────────────────────────────────────
87
79
  Each step ≈ one position on the 0–10 scale (~0.08 OKLCH L). */
88
80
  --lc-adj-1: 0.08;
@@ -92,33 +84,33 @@
92
84
  --lc-adj-5: 0.40;
93
85
  }
94
86
 
95
- /* ── Light-mode luminance contrast range ──────────────────────────────
96
- In light mode the scale flips: 0/base is near white (blends with
97
- the page), 10/fore is near black (high contrast, like text). */
87
+ /* ── Dark-mode luminance contrast range ──────────────────────────────
88
+ In dark mode the scale flips: 0/base is near black (blends with
89
+ the page), 10/fore is near white (high contrast, like text). */
98
90
 
99
- :root:not(.dark) {
100
- --lc-dir: -1;
101
- --lc-flip: 0;
102
- --lc-range-start: 0.95;
103
- --lc-range-end: 0.15;
91
+ .dark {
92
+ --lc-dir: 1;
93
+ --lc-flip: 1;
94
+ --lc-range-start: 0.12;
95
+ --lc-range-end: 0.92;
104
96
 
105
- --l-0: 0.95;
106
- --l-1: 0.87;
107
- --l-2: 0.79;
108
- --l-3: 0.71;
109
- --l-4: 0.63;
110
- --l-5: 0.55;
111
- --l-6: 0.47;
112
- --l-7: 0.39;
113
- --l-8: 0.31;
114
- --l-9: 0.23;
115
- --l-10: 0.15;
97
+ --l-0: 0.12;
98
+ --l-1: 0.20;
99
+ --l-2: 0.28;
100
+ --l-3: 0.36;
101
+ --l-4: 0.44;
102
+ --l-5: 0.52;
103
+ --l-6: 0.60;
104
+ --l-7: 0.68;
105
+ --l-8: 0.76;
106
+ --l-9: 0.84;
107
+ --l-10: 0.92;
116
108
 
117
- --l-base: 0.95;
118
- --l-fore: 0.15;
109
+ --l-base: 0.12;
110
+ --l-fore: 0.92;
119
111
 
120
- --l-none: 1;
121
- --l-full: 0;
112
+ --l-none: 0;
113
+ --l-full: 1;
122
114
  }
123
115
 
124
116
  /* ── Cascade Defaults ────────────────────────────────────────────────────
@@ -127,8 +119,8 @@
127
119
  naturally flows to children that only set bg-lc-* or bg-c-*. */
128
120
 
129
121
  :root {
130
- --lc-dir: 1;
131
- --lc-flip: 1;
122
+ --lc-dir: -1;
123
+ --lc-flip: 0;
132
124
 
133
125
  --bg-l: var(--l-5);
134
126
  --bg-c: var(--c-lo);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwind-oklch",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "OKLCH color composition system for Tailwind CSS v4",
5
5
  "style": "index.css",
6
6
  "main": "index.css",