@kbach/react 1.0.0-beta.14 → 1.0.0-beta.15
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/README.md +32 -38
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -188,70 +188,64 @@ live at your project root (e.g. a monorepo app).
|
|
|
188
188
|
|
|
189
189
|
## Dark mode
|
|
190
190
|
|
|
191
|
-
|
|
192
|
-
plain CSS
|
|
193
|
-
imports anything from `@kbach/react`'s runtime:
|
|
191
|
+
**Following the OS setting — zero setup.** `dark:` classes already work,
|
|
192
|
+
via plain CSS, with nothing to configure:
|
|
194
193
|
|
|
195
194
|
```tsx
|
|
196
195
|
<div className="bg-white dark:bg-neutral-12">...</div>
|
|
197
196
|
```
|
|
198
197
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
`'attribute'` (writes `.dark`/`data-theme` onto `<html>` instead):
|
|
198
|
+
**A manual light/dark toggle — one file, no other setup.** `@media
|
|
199
|
+
(prefers-color-scheme)` (the default above) can't be flipped by a button —
|
|
200
|
+
it only ever reflects the OS. For a real toggle, add one file:
|
|
203
201
|
|
|
204
202
|
```js
|
|
205
|
-
// kbach.config.js —
|
|
206
|
-
// project root, no import needed in vite.config.ts/postcss.config.js
|
|
203
|
+
// kbach.config.js — at your project root
|
|
207
204
|
export default { darkMode: 'attribute' };
|
|
208
205
|
```
|
|
209
206
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
export default defineConfig({ plugins: [kbach(), react()] });
|
|
215
|
-
```
|
|
207
|
+
That's it. Don't pass anything to `kbach()`/`'@kbach/react/postcss'` and
|
|
208
|
+
don't call anything at app startup — both sides pick this up on their own
|
|
209
|
+
(the plugin auto-discovers the file; the runtime reads the strategy back
|
|
210
|
+
out of the CSS the plugin already generated). Then just use `useTheme()`:
|
|
216
211
|
|
|
217
212
|
```tsx
|
|
218
|
-
// app entry — no applyKbachConfig() call needed either
|
|
219
213
|
import { useTheme } from '@kbach/react';
|
|
220
214
|
|
|
221
215
|
function ThemeToggle() {
|
|
222
|
-
const { mode,
|
|
216
|
+
const { mode, toggle } = useTheme();
|
|
223
217
|
return <button onClick={toggle}>{mode}</button>;
|
|
224
218
|
}
|
|
225
219
|
```
|
|
226
220
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
so build-time and runtime always agree automatically.
|
|
221
|
+
Works anywhere in the tree, no provider required. `<ThemeProvider
|
|
222
|
+
defaultMode="dark">` is optional, only for seeding a startup default.
|
|
223
|
+
Outside React, use `getGlobalDarkMode()`/`toggleGlobalDarkMode()` directly.
|
|
231
224
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
225
|
+
<details>
|
|
226
|
+
<summary>Not using the static plugin, or need to set the strategy explicitly?</summary>
|
|
227
|
+
|
|
228
|
+
There's nothing for the runtime to auto-detect if no build step ever
|
|
229
|
+
generates `dark:` CSS (a pure runtime `kb()`-only setup) — call
|
|
230
|
+
`applyKbachConfig()` yourself once, before your first render, instead:
|
|
236
231
|
|
|
237
232
|
```tsx
|
|
238
|
-
import { applyKbachConfig
|
|
233
|
+
import { applyKbachConfig } from '@kbach/react';
|
|
239
234
|
|
|
240
235
|
applyKbachConfig({ darkMode: 'attribute' });
|
|
241
236
|
```
|
|
242
237
|
|
|
243
|
-
An explicit
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
learned about `'class'`/`'attribute'`, one way or another.
|
|
238
|
+
An explicit call like this always wins over whatever the CSS auto-detect
|
|
239
|
+
found, if the two ever disagree. If you do reach for it alongside the
|
|
240
|
+
plugin, import the same `kbach.config.js` rather than retyping the value —
|
|
241
|
+
`import kbachConfig from '../kbach.config.js'; applyKbachConfig(kbachConfig);`.
|
|
242
|
+
|
|
243
|
+
`useTheme()`/`toggleGlobalDarkMode()` still track `isDark` correctly under
|
|
244
|
+
the default `'media'` strategy too, with none of the above — they just
|
|
245
|
+
won't visibly affect `dark:` classes until the runtime knows about
|
|
246
|
+
`'class'`/`'attribute'` one way or another.
|
|
247
|
+
|
|
248
|
+
</details>
|
|
255
249
|
|
|
256
250
|
## Theming
|
|
257
251
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kbach/react",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.15",
|
|
4
4
|
"description": "A utility-first styling engine for React, powered by a real Rust/WASM core — Tailwind CSS v4 feature parity with Kbach's own color palette.",
|
|
5
5
|
"keywords": ["css", "react", "tailwind", "utility-first", "wasm", "styling"],
|
|
6
6
|
"license": "MIT",
|