@raxrai/stylelab-ui 0.3.1 → 0.3.2

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 CHANGED
@@ -49,6 +49,8 @@ export default function RootLayout({ children }) {
49
49
  }
50
50
  ```
51
51
 
52
+ Optional props: `storageKey` (default `"stylelab-theme"`) for the localStorage key; `persistTheme` (default `true`). When `persistTheme={false}`, the provider does not read or write localStorage (theme is fixed to `defaultTheme` unless you change it in memory).
53
+
52
54
  ### 3. Use components
53
55
 
54
56
  ```tsx
@@ -213,6 +215,10 @@ import { cn, useFocusTrap, useClickOutside, useKeyboardNavigation, getNextListIn
213
215
 
214
216
  ## Changelog
215
217
 
218
+ ### [0.3.2]
219
+
220
+ - **ThemeProvider** — Optional `persistTheme` prop (default `true`). When `persistTheme={false}`, the provider does not read from or write to localStorage: theme stays at `defaultTheme` unless changed in memory. Use for fixed-theme pages (e.g. landing, docs) or nested providers where only the inner tree should persist. Optional `storageKey` (default `"stylelab-theme"`) still applies when `persistTheme` is true.
221
+
216
222
  ### [0.3.1]
217
223
 
218
224
  - **Dropdown** — `disabled` prop: when true, the dropdown does not open and the trigger is non-interactive (opacity, cursor, no popover). Use for empty or loading state.
package/dist/index.cjs CHANGED
@@ -341,12 +341,14 @@ function getStoredTheme(storageKey, defaultTheme) {
341
341
  function ThemeProvider({
342
342
  children,
343
343
  defaultTheme = "minimal",
344
- storageKey = "stylelab-theme"
344
+ storageKey = "stylelab-theme",
345
+ persistTheme = true
345
346
  }) {
346
347
  const [theme, setThemeState] = (0, import_react.useState)(defaultTheme);
347
348
  (0, import_react.useEffect)(() => {
349
+ if (!persistTheme) return;
348
350
  setThemeState((prev) => getStoredTheme(storageKey, prev));
349
- }, [storageKey]);
351
+ }, [storageKey, persistTheme]);
350
352
  (0, import_react.useEffect)(() => {
351
353
  if (typeof document !== "undefined") {
352
354
  try {
@@ -361,12 +363,12 @@ function ThemeProvider({
361
363
  if (typeof document !== "undefined") {
362
364
  try {
363
365
  document.documentElement.dataset.stylelabTheme = next;
364
- localStorage.setItem(storageKey, next);
366
+ if (persistTheme) localStorage.setItem(storageKey, next);
365
367
  } catch (_) {
366
368
  }
367
369
  }
368
370
  },
369
- [storageKey]
371
+ [storageKey, persistTheme]
370
372
  );
371
373
  const value = (0, import_react.useMemo)(
372
374
  () => ({ theme, setTheme }),