@kbach/react 1.0.0-beta.10 → 1.0.0-beta.11
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 +22 -8
- package/package.json +1 -1
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)
|
|
203
|
-
|
|
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
|
-
|
|
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
|
|
226
|
-
`
|
|
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.
|
|
3
|
+
"version": "1.0.0-beta.11",
|
|
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",
|