@grida/tailwindcss-colors 4.0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Grida
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,273 @@
1
+ # `@grida/tailwindcss-colors`
2
+
3
+ Tailwind CSS color data package for programmatic access.
4
+
5
+ This package provides Tailwind CSS color palettes in JSON format for applications that need to **programmatically access** Tailwind color values (e.g., building custom color pickers, canvas rendering, dynamic color manipulation). Colors are sourced directly from the official Tailwind CSS package.
6
+
7
+ > **When to use this package:** You need Tailwind color values in your JavaScript/TypeScript code (e.g., `colors.slate["500"]`).
8
+ > **When NOT to use this package:** You only need Tailwind colors in CSS - use Tailwind CSS directly instead.
9
+
10
+ ## Features
11
+
12
+ - **🌳 Tree-shakable** - Import only the format you need. Bundlers automatically exclude unused formats from your bundle.
13
+ - **📦 Lightweight** - ~96KB total (all formats). Individual JSON files are ~5.5-16KB each.
14
+ - **🎯 Modular exports** - Each format is a separate file with explicit `exports` mapping for optimal tree-shaking.
15
+ - **📊 Multiple formats** - RGB, RGBF, RGBA, HEX, and OKLCH formats for different use cases.
16
+ - **🔢 Numerically sorted** - Colors are sorted by shade (50, 100, 200...) for predictable iteration.
17
+ - **📝 TypeScript support** - Full TypeScript definitions included for all JSON formats.
18
+ - **🎨 Complete palette** - All 22 Tailwind CSS v4 color families with 11 shades each (242 colors total).
19
+
20
+ ## Overview
21
+
22
+ This package contains the complete Tailwind CSS color system in multiple formats:
23
+
24
+ **JSON Files** (for programmatic access - **main purpose**):
25
+
26
+ | Format | File | Value Type | Unit | Description |
27
+ | --------- | ----------------- | -------------- | ------------ | -------------------------------------------------------------- |
28
+ | **RGB** | `json/rgb.json` | `[r, g, b]` | RGB888 | RGB values as integers (0-255) |
29
+ | **RGBF** | `json/rgbf.json` | `[r, g, b]` | RGB32F | RGB values as floats (0-1) |
30
+ | **RGBA** | `json/rgba.json` | `[r, g, b, a]` | `RGB888A32F` | RGB values as integers (0-255), alpha as float (0-1, always 1) |
31
+ | **HEX** | `json/hex.json` | `string` | - | Hex color strings (e.g., `"#64748e"`) |
32
+ | **OKLCH** | `json/oklch.json` | `[l, c, h]` | - | OKLCH values: lightness (0-1), chroma (0+), hue (0-360) |
33
+
34
+ **CSS Files** (not recommended - use Tailwind CSS directly):
35
+
36
+ - **RGB** (`css/rgb.css`) - Colors in `rgb()` format
37
+ - **RGBA** (`css/rgba.css`) - Colors in `rgba()` format
38
+ - **HEX** (`css/hex.css`) - Colors in hexadecimal format
39
+ - **OKLCH** (`css/oklch.css`) - Colors in OKLCH format
40
+
41
+ ## Installation
42
+
43
+ ```bash
44
+ npm install @grida/tailwindcss-colors
45
+ # or
46
+ pnpm add @grida/tailwindcss-colors
47
+ # or
48
+ yarn add @grida/tailwindcss-colors
49
+ ```
50
+
51
+ ## Usage
52
+
53
+ > **Note:** This package is designed for **programmatic access** to Tailwind color values. If you only need Tailwind colors in CSS, use Tailwind CSS directly - there's no reason to install this package.
54
+
55
+ ### CSS Files (Not Recommended)
56
+
57
+ <details>
58
+ <summary>CSS files are provided for completeness, but are not the intended use case.</summary>
59
+
60
+ If you need Tailwind colors in CSS, use Tailwind CSS directly:
61
+
62
+ ```css
63
+ /* Use Tailwind CSS instead */
64
+ @tailwind base;
65
+ @tailwind components;
66
+ @tailwind utilities;
67
+
68
+ /* Then use Tailwind classes */
69
+ .my-element {
70
+ @apply bg-slate-500 text-gray-100;
71
+ }
72
+ ```
73
+
74
+ The CSS files in this package are only provided for edge cases where you need CSS custom properties without Tailwind CSS:
75
+
76
+ ```css
77
+ @import "@grida/tailwindcss-colors/css/rgba.css";
78
+ ```
79
+
80
+ ```css
81
+ .my-element {
82
+ background-color: var(--slate-500);
83
+ color: var(--gray-100);
84
+ }
85
+ ```
86
+
87
+ </details>
88
+
89
+ ### JSON Files (Recommended)
90
+
91
+ **Main Purpose:** This package is designed for applications that need to **programmatically access** Tailwind color values, such as:
92
+
93
+ - Building custom color pickers
94
+ - Dynamic color manipulation
95
+ - Canvas/graphics rendering
96
+ - Color analysis and processing
97
+ - Any use case where you need the actual color values in code
98
+
99
+ #### TypeScript Setup
100
+
101
+ To import JSON files in TypeScript, add `resolveJsonModule` to your `tsconfig.json`:
102
+
103
+ ```json
104
+ {
105
+ "compilerOptions": {
106
+ "resolveJsonModule": true
107
+ }
108
+ }
109
+ ```
110
+
111
+ #### Importing Colors
112
+
113
+ Import JSON files for programmatic access. The package provides TypeScript types automatically:
114
+
115
+ ```typescript
116
+ // RGB array [r, g, b] - nested by color family
117
+ import rgbColors from "@grida/tailwindcss-colors/json/rgb.json";
118
+ const slate500 = rgbColors.slate["500"]; // [98, 116, 142]
119
+
120
+ // RGBF array [r, g, b] - RGB values as floats (0-1)
121
+ import rgbfColors from "@grida/tailwindcss-colors/json/rgbf.json";
122
+ const slate500Rgbf = rgbfColors.slate["500"]; // [0.384, 0.455, 0.557]
123
+
124
+ // RGBA array [r, g, b, a] - RGB: 0-255, Alpha: 0-1 (always 1 for Tailwind colors)
125
+ import rgbaColors from "@grida/tailwindcss-colors/json/rgba.json";
126
+ const slate500Rgba = rgbaColors.slate["500"]; // [98, 116, 142, 1]
127
+
128
+ // Hex string
129
+ import hexColors from "@grida/tailwindcss-colors/json/hex.json";
130
+ const slate500Hex = hexColors.slate["500"]; // "#64748e"
131
+
132
+ // OKLCH array [l, c, h]
133
+ import oklchColors from "@grida/tailwindcss-colors/json/oklch.json";
134
+ const slate500Oklch = oklchColors.slate["500"]; // [0.384, 0.015, 255.59]
135
+
136
+ // Access all shades of a color family
137
+ const allSlateColors = rgbColors.slate; // { "50": [...], "100": [...], ... }
138
+
139
+ // Iterate over color families
140
+ Object.keys(rgbColors).forEach((family) => {
141
+ console.log(`Color family: ${family}`);
142
+ console.log(`Available shades:`, Object.keys(rgbColors[family]));
143
+ });
144
+ ```
145
+
146
+ #### JavaScript (CommonJS)
147
+
148
+ ```javascript
149
+ // Only import what you need - modular exports enable tree-shaking
150
+ const rgbColors = require("@grida/tailwindcss-colors/json/rgb.json");
151
+ const slate500 = rgbColors.slate["500"]; // [98, 116, 142]
152
+ ```
153
+
154
+ #### Tree-shaking
155
+
156
+ This package is fully tree-shakable. When you import a specific format, bundlers (webpack, Rollup, Vite, etc.) will only include that file in your bundle:
157
+
158
+ ```typescript
159
+ // ✅ Only rgb.json is included (~6.6KB)
160
+ import rgbColors from "@grida/tailwindcss-colors/json/rgb.json";
161
+
162
+ // ✅ Only hex.json is included (~5.5KB)
163
+ import hexColors from "@grida/tailwindcss-colors/json/hex.json";
164
+
165
+ // ❌ Unused formats are automatically excluded
166
+ // rgba.json, rgbf.json, oklch.json are NOT bundled
167
+ ```
168
+
169
+ The `exports` field in `package.json` ensures that only explicitly imported files are included in your bundle.
170
+
171
+ #### Usage Examples
172
+
173
+ **React Component:**
174
+
175
+ ```typescript
176
+ import hexColors from "@grida/tailwindcss-colors/json/hex.json";
177
+
178
+ function ColorSwatch({ family, shade }: { family: string; shade: string }) {
179
+ const color = hexColors[family]?.[shade];
180
+ return (
181
+ <div style={{ backgroundColor: color }}>
182
+ {family}-{shade}
183
+ </div>
184
+ );
185
+ }
186
+ ```
187
+
188
+ **Canvas Rendering:**
189
+
190
+ ```typescript
191
+ import rgbaColors from "@grida/tailwindcss-colors/json/rgba.json";
192
+
193
+ // RGBA: RGB values are 0-255, alpha is 0-1 (always 1 for Tailwind colors)
194
+ const [r, g, b, a] = rgbaColors.slate["500"]; // [98, 116, 142, 1]
195
+ ctx.fillStyle = `rgba(${r}, ${g}, ${b}, ${a})`; // rgba(98, 116, 142, 1)
196
+ ctx.fillRect(0, 0, 100, 100);
197
+ ```
198
+
199
+ **Dynamic Color Selection:**
200
+
201
+ ```typescript
202
+ import rgbColors from "@grida/tailwindcss-colors/json/rgb.json";
203
+
204
+ function getColor(family: string, shade: string): [number, number, number] {
205
+ return rgbColors[family]?.[shade] ?? [0, 0, 0];
206
+ }
207
+
208
+ const primaryColor = getColor("blue", "500"); // [43, 127, 255]
209
+ ```
210
+
211
+ ## Color Palette
212
+
213
+ The package includes all standard Tailwind v4 color families:
214
+
215
+ - Slate, Gray, Zinc, Neutral, Stone
216
+ - Red, Orange, Amber, Yellow, Lime, Green, Emerald, Teal, Cyan, Sky, Blue, Indigo, Violet, Purple, Fuchsia, Pink, Rose
217
+
218
+ Each color family includes shades from `50` to `950`.
219
+
220
+ ## Format
221
+
222
+ ### JSON Format
223
+
224
+ JSON files use a nested structure grouped by color family:
225
+
226
+ ```json
227
+ {
228
+ "slate": {
229
+ "50": [248, 250, 252],
230
+ "100": [241, 245, 249],
231
+ ...
232
+ "950": [2, 6, 23]
233
+ },
234
+ "blue": {
235
+ ...
236
+ }
237
+ }
238
+ ```
239
+
240
+ ### CSS Format
241
+
242
+ CSS files provide colors as CSS custom properties following the pattern:
243
+
244
+ ```css
245
+ :root {
246
+ --{color-name}-{shade}: {color-value};
247
+ }
248
+ ```
249
+
250
+ For example:
251
+
252
+ - `--slate-50`: Lightest shade
253
+ - `--slate-500`: Middle shade
254
+ - `--slate-950`: Darkest shade
255
+
256
+ ## Which one to use?
257
+
258
+ Choose the format that best fits your use case:
259
+
260
+ - **RGB** (`rgb.json`) - Use when you need integer RGB values (0-255). Most compact format. Unit: `RGB888`.
261
+ - **RGBF** (`rgbf.json`) - Use when you need floating-point RGB values (0-1) for WebGL, shaders, or graphics APIs. Slightly larger file size due to floating-point storage. Unit: `RGB32F`.
262
+ - **RGBA** (`rgba.json`) - Use when you need RGB with alpha channel. RGB values are integers (0-255), alpha is float (0-1). Unit: `RGB888A32F`.
263
+ - **HEX** (`hex.json`) - Use for web development, CSS, or when you need human-readable color strings.
264
+ - **OKLCH** (`oklch.json`) - Use for perceptual color operations, color mixing, or modern color spaces.
265
+
266
+ > **Note:** RGBF is slightly larger than RGB as it stores numbers in floating-point format. If you are very sensitive about bundle size, use `rgb.json` instead.
267
+
268
+ ## Notes
269
+
270
+ - Colors are sourced directly from the official Tailwind CSS package (`tailwindcss/colors`)
271
+ - Package version matches Tailwind CSS version for consistency
272
+ - Alpha channel (`a`) is always `1` for all colors in Tailwind CSS v4 colors
273
+ - Use the format that best suits your rendering needs (RGBA for canvas, HEX for web, OKLCH for modern color spaces)
package/css/hex.css ADDED
@@ -0,0 +1,244 @@
1
+ :root {
2
+ --amber-50: #fffbeb;
3
+ --amber-100: #fef3c6;
4
+ --amber-200: #fee685;
5
+ --amber-300: #ffd230;
6
+ --amber-400: #ffba00;
7
+ --amber-500: #fd9a00;
8
+ --amber-600: #e17100;
9
+ --amber-700: #bb4d00;
10
+ --amber-800: #973c00;
11
+ --amber-900: #7b3306;
12
+ --amber-950: #461901;
13
+ --blue-50: #eff6ff;
14
+ --blue-100: #dbeafe;
15
+ --blue-200: #bedbff;
16
+ --blue-300: #8ec5ff;
17
+ --blue-400: #51a2ff;
18
+ --blue-500: #2b7fff;
19
+ --blue-600: #155dfc;
20
+ --blue-700: #1447e6;
21
+ --blue-800: #193cb8;
22
+ --blue-900: #1c398e;
23
+ --blue-950: #162456;
24
+ --cyan-50: #ecfeff;
25
+ --cyan-100: #cefafe;
26
+ --cyan-200: #a2f4fd;
27
+ --cyan-300: #53eafd;
28
+ --cyan-400: #00d3f2;
29
+ --cyan-500: #00b8db;
30
+ --cyan-600: #0092b8;
31
+ --cyan-700: #007595;
32
+ --cyan-800: #005f78;
33
+ --cyan-900: #104e64;
34
+ --cyan-950: #053345;
35
+ --emerald-50: #ecfdf5;
36
+ --emerald-100: #d0fae5;
37
+ --emerald-200: #a4f4cf;
38
+ --emerald-300: #5ee9b5;
39
+ --emerald-400: #00d492;
40
+ --emerald-500: #00bc7d;
41
+ --emerald-600: #096;
42
+ --emerald-700: #007a55;
43
+ --emerald-800: #006045;
44
+ --emerald-900: #004f3b;
45
+ --emerald-950: #002c22;
46
+ --fuchsia-50: #fdf4ff;
47
+ --fuchsia-100: #fae8ff;
48
+ --fuchsia-200: #f6cfff;
49
+ --fuchsia-300: #f4a8ff;
50
+ --fuchsia-400: #ed6aff;
51
+ --fuchsia-500: #e12afb;
52
+ --fuchsia-600: #c800de;
53
+ --fuchsia-700: #a800b7;
54
+ --fuchsia-800: #8a0194;
55
+ --fuchsia-900: #721378;
56
+ --fuchsia-950: #4b004f;
57
+ --gray-50: #f9fafb;
58
+ --gray-100: #f3f4f6;
59
+ --gray-200: #e5e7eb;
60
+ --gray-300: #d1d5dc;
61
+ --gray-400: #99a1af;
62
+ --gray-500: #6a7282;
63
+ --gray-600: #4a5565;
64
+ --gray-700: #364153;
65
+ --gray-800: #1e2939;
66
+ --gray-900: #101828;
67
+ --gray-950: #030712;
68
+ --green-50: #f0fdf4;
69
+ --green-100: #dcfce7;
70
+ --green-200: #b9f8cf;
71
+ --green-300: #7bf1a8;
72
+ --green-400: #05df72;
73
+ --green-500: #00c950;
74
+ --green-600: #00a63e;
75
+ --green-700: #008236;
76
+ --green-800: #016630;
77
+ --green-900: #0d542b;
78
+ --green-950: #032e15;
79
+ --indigo-50: #eef2ff;
80
+ --indigo-100: #e0e7ff;
81
+ --indigo-200: #c6d2ff;
82
+ --indigo-300: #a3b3ff;
83
+ --indigo-400: #7c86ff;
84
+ --indigo-500: #615fff;
85
+ --indigo-600: #4f39f6;
86
+ --indigo-700: #432dd7;
87
+ --indigo-800: #372aac;
88
+ --indigo-900: #312c85;
89
+ --indigo-950: #1e1a4d;
90
+ --lime-50: #f7fee7;
91
+ --lime-100: #ecfcca;
92
+ --lime-200: #d8f999;
93
+ --lime-300: #bbf451;
94
+ --lime-400: #9ae600;
95
+ --lime-500: #7ccf00;
96
+ --lime-600: #5ea500;
97
+ --lime-700: #497d00;
98
+ --lime-800: #3c6300;
99
+ --lime-900: #35530e;
100
+ --lime-950: #192e03;
101
+ --neutral-50: #fafafa;
102
+ --neutral-100: #f5f5f5;
103
+ --neutral-200: #e5e5e5;
104
+ --neutral-300: #d4d4d4;
105
+ --neutral-400: #a1a1a1;
106
+ --neutral-500: #737373;
107
+ --neutral-600: #525252;
108
+ --neutral-700: #404040;
109
+ --neutral-800: #262626;
110
+ --neutral-900: #171717;
111
+ --neutral-950: #0a0a0a;
112
+ --orange-50: #fff7ed;
113
+ --orange-100: #ffedd4;
114
+ --orange-200: #ffd6a7;
115
+ --orange-300: #ffb86a;
116
+ --orange-400: #ff8904;
117
+ --orange-500: #ff6900;
118
+ --orange-600: #f54900;
119
+ --orange-700: #ca3500;
120
+ --orange-800: #9f2d00;
121
+ --orange-900: #7e2a0c;
122
+ --orange-950: #441306;
123
+ --pink-50: #fdf2f8;
124
+ --pink-100: #fce7f3;
125
+ --pink-200: #fccee8;
126
+ --pink-300: #fda5d5;
127
+ --pink-400: #fb64b6;
128
+ --pink-500: #f6339a;
129
+ --pink-600: #e60076;
130
+ --pink-700: #c6005c;
131
+ --pink-800: #a3004c;
132
+ --pink-900: #861043;
133
+ --pink-950: #510424;
134
+ --purple-50: #faf5ff;
135
+ --purple-100: #f3e8ff;
136
+ --purple-200: #e9d4ff;
137
+ --purple-300: #dab2ff;
138
+ --purple-400: #c27aff;
139
+ --purple-500: #ad46ff;
140
+ --purple-600: #9810fa;
141
+ --purple-700: #8200db;
142
+ --purple-800: #6e11b0;
143
+ --purple-900: #59168b;
144
+ --purple-950: #3c0366;
145
+ --red-50: #fef2f2;
146
+ --red-100: #ffe2e2;
147
+ --red-200: #ffc9c9;
148
+ --red-300: #ffa2a2;
149
+ --red-400: #ff6467;
150
+ --red-500: #fb2c36;
151
+ --red-600: #e7000b;
152
+ --red-700: #c10007;
153
+ --red-800: #9f0712;
154
+ --red-900: #82181a;
155
+ --red-950: #460809;
156
+ --rose-50: #fff1f2;
157
+ --rose-100: #ffe4e6;
158
+ --rose-200: #ffccd3;
159
+ --rose-300: #ffa1ad;
160
+ --rose-400: #ff637e;
161
+ --rose-500: #ff2056;
162
+ --rose-600: #ec003f;
163
+ --rose-700: #c70036;
164
+ --rose-800: #a50036;
165
+ --rose-900: #8b0836;
166
+ --rose-950: #4d0218;
167
+ --sky-50: #f0f9ff;
168
+ --sky-100: #dff2fe;
169
+ --sky-200: #b8e6fe;
170
+ --sky-300: #74d4ff;
171
+ --sky-400: #00bcff;
172
+ --sky-500: #00a6f4;
173
+ --sky-600: #0084d1;
174
+ --sky-700: #0069a8;
175
+ --sky-800: #00598a;
176
+ --sky-900: #024a70;
177
+ --sky-950: #052f4a;
178
+ --slate-50: #f8fafc;
179
+ --slate-100: #f1f5f9;
180
+ --slate-200: #e2e8f0;
181
+ --slate-300: #cad5e2;
182
+ --slate-400: #90a1b9;
183
+ --slate-500: #62748e;
184
+ --slate-600: #45556c;
185
+ --slate-700: #314158;
186
+ --slate-800: #1d293d;
187
+ --slate-900: #0f172b;
188
+ --slate-950: #020618;
189
+ --stone-50: #fafaf9;
190
+ --stone-100: #f5f5f4;
191
+ --stone-200: #e7e5e4;
192
+ --stone-300: #d6d3d1;
193
+ --stone-400: #a6a09b;
194
+ --stone-500: #79716b;
195
+ --stone-600: #57534d;
196
+ --stone-700: #44403b;
197
+ --stone-800: #292524;
198
+ --stone-900: #1c1917;
199
+ --stone-950: #0c0a09;
200
+ --teal-50: #f0fdfa;
201
+ --teal-100: #cbfbf1;
202
+ --teal-200: #96f7e4;
203
+ --teal-300: #46ecd5;
204
+ --teal-400: #00d5be;
205
+ --teal-500: #00bba7;
206
+ --teal-600: #009689;
207
+ --teal-700: #00786f;
208
+ --teal-800: #005f5a;
209
+ --teal-900: #0b4f4a;
210
+ --teal-950: #022f2e;
211
+ --violet-50: #f5f3ff;
212
+ --violet-100: #ede9fe;
213
+ --violet-200: #ddd6ff;
214
+ --violet-300: #c4b4ff;
215
+ --violet-400: #a684ff;
216
+ --violet-500: #8e51ff;
217
+ --violet-600: #7f22fe;
218
+ --violet-700: #7008e7;
219
+ --violet-800: #5d0ec0;
220
+ --violet-900: #4d179a;
221
+ --violet-950: #2f0d68;
222
+ --yellow-50: #fefce8;
223
+ --yellow-100: #fef9c2;
224
+ --yellow-200: #fff085;
225
+ --yellow-300: #ffdf20;
226
+ --yellow-400: #fcc800;
227
+ --yellow-500: #efb100;
228
+ --yellow-600: #d08700;
229
+ --yellow-700: #a65f00;
230
+ --yellow-800: #894b00;
231
+ --yellow-900: #733e0a;
232
+ --yellow-950: #432004;
233
+ --zinc-50: #fafafa;
234
+ --zinc-100: #f4f4f5;
235
+ --zinc-200: #e4e4e7;
236
+ --zinc-300: #d4d4d8;
237
+ --zinc-400: #9f9fa9;
238
+ --zinc-500: #71717b;
239
+ --zinc-600: #52525c;
240
+ --zinc-700: #3f3f46;
241
+ --zinc-800: #27272a;
242
+ --zinc-900: #18181b;
243
+ --zinc-950: #09090b;
244
+ }