@kbach/react 1.0.0-beta.14 → 1.0.0-beta.16

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 (2) hide show
  1. package/README.md +32 -38
  2. package/package.json +2 -2
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
- By default, `dark:` classes follow the OS `prefers-color-scheme` setting via
192
- plain CSS — zero config, zero JS required, works even if your app never
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
- This default (`darkMode: 'media'`) can't be overridden by an in-app toggle —
200
- `@media (prefers-color-scheme)` only ever reflects the real OS setting. To
201
- add a manual light/dark switcher, opt into `darkMode: 'class'` or
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 — a plain object, auto-discovered by the plugin at your
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
- ```ts
211
- // vite.config.ts — no `config`/`theme` option needed
212
- import { kbach } from '@kbach/react/vite';
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, isDark, setMode, toggle } = useTheme();
216
+ const { mode, toggle } = useTheme();
223
217
  return <button onClick={toggle}>{mode}</button>;
224
218
  }
225
219
  ```
226
220
 
227
- That's the whole setup — one file, no runtime call. The generated CSS
228
- carries the strategy it was built with (as a `--kb-dark-mode` custom
229
- property), and `useTheme()`'s store reads it back from the DOM at startup,
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
- If you're not using the static plugin at all (a pure runtime `kb()` setup,
233
- with no build step generating `dark:` CSS ahead of time), there's nothing
234
- for the runtime to auto-detect — call `applyKbachConfig({ darkMode: '...' })`
235
- yourself instead, once, before your first render:
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, useTheme } from '@kbach/react';
233
+ import { applyKbachConfig } from '@kbach/react';
239
234
 
240
235
  applyKbachConfig({ darkMode: 'attribute' });
241
236
  ```
242
237
 
243
- An explicit `applyKbachConfig()` call always overrides whatever was
244
- auto-detected, if you ever need one — e.g. switching strategy at runtime for
245
- some reason. Keep the value in one shared `kbach.config.js` and import it on
246
- both sides rather than typing the same literal twice, if you do reach for it.
247
-
248
- Works anywhere, no provider needed. `<ThemeProvider defaultMode="dark">` is
249
- optional, for seeding a startup default. Outside React (plain functions,
250
- event handlers), use `getGlobalDarkMode()`/`toggleGlobalDarkMode()` instead.
251
- Note: `useTheme()`/`toggleGlobalDarkMode()` still track `isDark` correctly
252
- under the default `'media'` strategy too (and even without any of the above)
253
- — they just won't visibly affect `dark:` classes unless the runtime has also
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.14",
3
+ "version": "1.0.0-beta.16",
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",
@@ -62,7 +62,7 @@
62
62
  "generate:colors": "node ../core-engine/scripts/generate-palette.mjs src/generatedPalette.ts"
63
63
  },
64
64
  "dependencies": {
65
- "@kbach/core-engine": "1.0.0-beta.8"
65
+ "@kbach/core-engine": "1.0.0-beta.9"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/react": "^19.2.0",