@kbach/react 1.0.0-beta.10 → 1.0.0-beta.12

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 +22 -8
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -199,18 +199,31 @@ imports anything from `@kbach/react`'s runtime:
199
199
  This default (`darkMode: 'media'`) can't be overridden by an in-app toggle —
200
200
  `@media (prefers-color-scheme)` only ever reflects the real OS setting. To
201
201
  add a manual light/dark switcher, opt into `darkMode: 'class'` or
202
- `'attribute'` (writes `.dark`/`data-theme` onto `<html>` instead) via
203
- `kbach.config.js` or the plugin's `config`/`theme` option:
202
+ `'attribute'` (writes `.dark`/`data-theme` onto `<html>` instead) — this
203
+ needs setting in **two places**, since they solve two different problems:
204
+
205
+ 1. **Build-time**, via `kbach.config.js` or the plugin's `config`/`theme`
206
+ option — controls which selector the generated CSS for `dark:` classes
207
+ compiles to (`[data-theme="dark"] .dark\:bg-neutral-12` vs
208
+ `.dark .dark\:bg-neutral-12` vs a plain `@media` query).
209
+ 2. **Runtime**, via `applyKbachConfig()` — controls what `useTheme()`'s
210
+ `toggle()`/`setMode()` actually write to the DOM. This is a *separate*
211
+ module from the build step above (it has to be: the plugin runs in
212
+ Node during your build, this runs in the browser) — setting only the
213
+ plugin option compiles the right CSS but leaves the toggle a silent
214
+ no-op, since the runtime still thinks the strategy is the `'media'`
215
+ default and has nothing to write to the DOM for it.
204
216
 
205
217
  ```js
206
- // kbach.config.js
218
+ // kbach.config.js — build-time, read by the Vite/PostCSS plugin
207
219
  export default { darkMode: 'attribute' };
208
220
  ```
209
221
 
210
- Then:
211
-
212
222
  ```tsx
213
- import { useTheme } from '@kbach/react';
223
+ // app entry (e.g. root.tsx / main.tsx) — runtime, same value as above
224
+ import { applyKbachConfig, useTheme } from '@kbach/react';
225
+
226
+ applyKbachConfig({ darkMode: 'attribute' }); // call once, before first render
214
227
 
215
228
  function ThemeToggle() {
216
229
  const { mode, isDark, setMode, toggle } = useTheme();
@@ -222,8 +235,9 @@ Works anywhere, no provider needed. `<ThemeProvider defaultMode="dark">` is
222
235
  optional, for seeding a startup default. Outside React (plain functions,
223
236
  event handlers), use `getGlobalDarkMode()`/`toggleGlobalDarkMode()` instead.
224
237
  Note: `useTheme()`/`toggleGlobalDarkMode()` still track `isDark` correctly
225
- under the default `'media'` strategy too — they just won't visibly affect
226
- `dark:` classes unless you've switched to `'class'`/`'attribute'`.
238
+ under the default `'media'` strategy too (and even without ever calling
239
+ `applyKbachConfig()`) — they just won't visibly affect `dark:` classes
240
+ unless the runtime has also been told about `'class'`/`'attribute'`.
227
241
 
228
242
  ## Theming
229
243
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbach/react",
3
- "version": "1.0.0-beta.10",
3
+ "version": "1.0.0-beta.12",
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.6"
65
+ "@kbach/core-engine": "1.0.0-beta.7"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/react": "^19.2.0",