@venix-sistemas/jade 1.1.0 → 1.3.0

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 (64) hide show
  1. package/README.md +555 -228
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +89 -13
  4. package/dist/runtime/components/VenixThemeSwitcher.d.vue.ts +3 -1
  5. package/dist/runtime/components/VenixThemeSwitcher.vue +592 -106
  6. package/dist/runtime/components/VenixThemeSwitcher.vue.d.ts +3 -1
  7. package/dist/runtime/composables/useThemeColors.d.ts +8 -2
  8. package/dist/runtime/composables/useThemeColors.js +24 -9
  9. package/dist/runtime/composables/useThemeCookies.d.ts +17 -2
  10. package/dist/runtime/composables/useThemeCookies.js +44 -7
  11. package/dist/runtime/composables/useThemeLocale.d.ts +7 -2
  12. package/dist/runtime/composables/useThemeLocale.js +2 -2
  13. package/dist/runtime/composables/useThemeSeasonal.d.ts +3 -3
  14. package/dist/runtime/composables/useThemeSeasonal.js +1 -1
  15. package/dist/runtime/composables/useVenixTheme.d.ts +40 -0
  16. package/dist/runtime/composables/useVenixTheme.js +249 -112
  17. package/dist/runtime/nitro/theme-init.js +8 -5
  18. package/dist/runtime/plugins/overlay-scrollbars.client.js +89 -0
  19. package/dist/runtime/plugins/theme-init.server.js +7 -12
  20. package/dist/runtime/plugins/vuetify-theme.js +8 -11
  21. package/dist/runtime/scripts/theme-init.d.ts +33 -11
  22. package/dist/runtime/scripts/theme-init.js +59 -88
  23. package/dist/shared/constants.d.ts +72 -3
  24. package/dist/shared/constants.js +26 -1
  25. package/dist/shared/css/cursor-svg.d.ts +10 -0
  26. package/dist/shared/css/cursor-svg.js +28 -0
  27. package/dist/shared/css/cursor.js +86 -34
  28. package/dist/shared/css/index.d.ts +1 -7
  29. package/dist/shared/css/index.js +5 -5
  30. package/dist/shared/css/scrollbar.js +61 -7
  31. package/dist/shared/css/transition.d.ts +1 -1
  32. package/dist/shared/css/typography.js +13 -0
  33. package/dist/shared/theme.json +308 -192
  34. package/dist/shared/types/color-options.d.ts +26 -2
  35. package/dist/shared/types/colors.d.ts +64 -12
  36. package/dist/shared/types/cursor.d.ts +34 -4
  37. package/dist/shared/types/index.d.ts +3 -3
  38. package/dist/shared/types/runtime-config.d.ts +5 -2
  39. package/dist/shared/types/scrollbar.d.ts +11 -0
  40. package/dist/shared/types/theme.d.ts +7 -0
  41. package/dist/shared/types/typography.d.ts +2 -1
  42. package/dist/shared/utils/icon-refs.d.ts +7 -3
  43. package/dist/shared/utils/icon.d.ts +4 -2
  44. package/dist/shared/utils/icon.js +6 -2
  45. package/dist/shared/utils/index.d.ts +5 -4
  46. package/dist/shared/utils/index.js +12 -6
  47. package/dist/shared/utils/inline-script.d.ts +6 -0
  48. package/dist/shared/utils/inline-script.js +3 -0
  49. package/dist/shared/utils/load.d.ts +2 -3
  50. package/dist/shared/utils/load.js +6 -12
  51. package/dist/shared/utils/merge-themes.d.ts +39 -9
  52. package/dist/shared/utils/merge-themes.js +101 -5
  53. package/dist/shared/utils/normalize.d.ts +0 -11
  54. package/dist/shared/utils/normalize.js +0 -12
  55. package/dist/shared/utils/theme-config.d.ts +15 -6
  56. package/dist/shared/utils/theme-config.js +28 -16
  57. package/dist/shared/utils/theme-resolve.d.ts +23 -22
  58. package/dist/shared/utils/theme-resolve.js +35 -66
  59. package/dist/shared/utils/theme-resolver.d.ts +47 -0
  60. package/dist/shared/utils/theme-resolver.js +140 -0
  61. package/package.json +22 -10
  62. package/README-default.md +0 -84
  63. package/dist/runtime/plugin.js +0 -3
  64. /package/dist/runtime/{plugin.d.ts → plugins/overlay-scrollbars.client.d.ts} +0 -0
package/README.md CHANGED
@@ -1,35 +1,44 @@
1
- <p align="center">
2
- <img src="./docs/images/jade-transparent.png" alt="Jade logo" width="200">
3
- </p>
4
-
5
- <h1 align="center">Jade</h1>
6
-
7
- <p align="center">
8
- <code>@venix-sistemas/jade</code>
9
- </p>
10
-
11
- <p align="center">
12
- <a href="https://www.npmjs.com/package/@venix-sistemas/jade"><img src="https://badge.fury.io/js/@venix-sistemas%2Fjade.svg" alt="npm version"></a>
13
- <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
14
- </p>
15
-
16
- A complete centralized theming system for Nuxt applications: colors, typography, cursor, scrollbar, internationalization and seasonal themes, with UnoCSS, Vuetify and Iconify integrations.
17
-
18
- ## Features
19
-
20
- * 📝 **Typography and font faces customization**
21
- * 🖱️ **Cursor customization**
22
- * 📜 **Scrollbar customization**
23
- * 🎨 **Color customization**, with dark and light themes included
24
- * 🖥️ **System theme preference detection**, including seasonal overrides
25
- * 🎃 **Seasonal themes**: Carnival, Halloween, Christmas and more
26
- * 💾 **Cookie-consent-aware persistence**: nothing is written until the user opts in
27
- * 🌐 **i18n**: internationalization and locale detection for theme names and your own strings
28
- * ⚡ **Nuxt-native integration**
29
- * 🎯 **UnoCSS preset** for the theme's color variables
30
- * 🎭 **Vuetify 4** theme auto-configuration, kept in sync with live theme changes
31
- * ✨ **Unified icons**: emoji, Iconify (animated `line-md`, `mdi`, both bundled and tree-shaken offline) or inline SVG through one component
32
-
1
+ <p align="center">
2
+ <img src="./docs/images/jade-transparent.png" alt="Jade logo" width="200">
3
+ </p>
4
+
5
+ <h1 align="center">Jade</h1>
6
+
7
+ <p align="center">
8
+ <code>@venix-sistemas/jade</code>
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://www.npmjs.com/package/@venix-sistemas/jade"><img src="https://badge.fury.io/js/@venix-sistemas%2Fjade.svg" alt="npm version"></a>
13
+ <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
14
+ </p>
15
+
16
+ <p align="center">
17
+ The UI foundation for Nuxt applications, in a single module: color themes (including seasonal ones),<br>
18
+ typography, scrollbar, cursor, icons and interface translations, with UnoCSS and Vuetify integrations.
19
+ </p>
20
+
21
+ <p align="center">
22
+ <img src="./docs/images/readme/theme-switcher.webp" alt="VenixThemeSwitcher going through the dark themes (Venix, Carnival, Easter, Christmas, Halloween, Ocean), then Ocean in light and automatic mode, and its settings turning the custom scrollbar, cursor and font off and back on" width="800">
23
+ </p>
24
+
25
+ ## Features
26
+
27
+ * 🎨 **Color customization**, with dark and light themes included
28
+ * 🌗 **Theme and mode picked separately**: any theme (Venix, Carnival, Christmas…) in light or dark, each following the system or fixed
29
+ * 🎃 **Seasonal themes**: Carnival, Halloween, Christmas and more
30
+ * 📝 **Typography and font faces customization**
31
+ * 📜 **Scrollbar customization**
32
+ * 🖱️ **Cursor customization**
33
+ * 🎛️ **Ready-made theme switcher**: accessible, phone-friendly, with no UI kit dependency
34
+ * 🖥️ **System preference detection**, including seasonal themes by date
35
+ * 💾 **Cookie-consent-aware persistence**: nothing is written until the user opts in
36
+ * 🌐 **i18n**: internationalization and locale detection for theme names and your own strings
37
+ * ✨ **Unified icons**: emoji, Iconify (animated `line-md`, `mdi`, both bundled and tree-shaken offline) or inline SVG through one component
38
+ * 🎯 **UnoCSS preset** for the theme's color variables
39
+ * 🎭 **Vuetify 4** theme auto-configuration, kept in sync with live theme changes
40
+ * ⚡ **Nuxt-native integration**
41
+
33
42
  ## Installation
34
43
 
35
44
  ```bash
@@ -38,6 +47,8 @@ pnpm add @venix-sistemas/jade
38
47
  npm install @venix-sistemas/jade
39
48
  ```
40
49
 
50
+ <br>
51
+
41
52
  ## Quick Setup
42
53
 
43
54
  ### 1. Add the module
@@ -46,291 +57,418 @@ npm install @venix-sistemas/jade
46
57
  // nuxt.config.ts
47
58
  export default defineNuxtConfig({
48
59
  modules: ['@venix-sistemas/jade'],
49
-
50
- venixTheme: {
51
- color: {
52
- themes: {
53
- dark: {
54
- primary: '#FF6B6B',
55
- },
56
- },
57
- },
58
- },
59
60
  })
60
61
  ```
61
62
 
62
- Every feature except Vuetify is on by default with built-in values, so you only configure what you want to change — the example above just swaps the dark theme's primary color. See [Configuration](#configuration) for every option.
63
-
64
- ### 2. Use the theme
63
+ No configuration is needed: every module except Vuetify is on by default with built-in values. Later, set only what you want to change under `venixTheme` — for example, the Venix theme's primary color in dark mode:
65
64
 
66
- The auto-imported `useVenixTheme()` composable gives access to the theme. It isn't called `useTheme` to avoid colliding with UI libraries (like Vuetify) that auto-import a composable with that name.
67
-
68
- ```vue
69
- <template>
70
- <button @click="theme.toggle('dark')">Dark</button>
71
- <button @click="theme.toggle('light')">Light</button>
72
- </template>
73
-
74
- <script setup lang="ts">
75
- const { theme } = useVenixTheme()
76
- </script>
65
+ ```typescript
66
+ venixTheme: {
67
+ color: {
68
+ themes: {
69
+ venix: { dark: { primary: '#FF6B6B' } },
70
+ },
71
+ },
72
+ }
77
73
  ```
78
74
 
79
- It returns four groups:
75
+ See [Modules](#modules) for what each one does.
80
76
 
81
- - `theme` — state and controls:
82
- - `value`: the applied theme (e.g. `'dark'` when the preference is `'system'`)
83
- - `preference`: the user's raw choice, including `'system'`
84
- - `data`: the active theme's `{ value, name, icon }`
85
- - `toggle(name?)`: switches to `name`, or between `light` and `dark` when called without one
86
- - `isSeasonalActive`, `activeSeasonalTheme`: whether a [seasonal theme](#seasonal-themes) is currently in effect, and which one
87
- - `shouldApplyColors`, `colors`: whether the module applies colors, and the raw color config
88
- - `themes` — every selectable theme, ready to render a picker (see [Theme icons](#theme-icons)).
89
- - `locale` — `current`, `set()` and `translate()` (see [Internationalization](#internationalization)).
90
- - `persistence` — cookie consent controls (see [Cookie Consent](#cookie-consent)).
77
+ ### 2. Add the theme switcher
91
78
 
92
- The state is shared app-wide (via Nuxt's `useState`): every component calling `useVenixTheme()` reads and writes the same theme, so they never go out of sync.
79
+ `<VenixThemeSwitcher>` is an auto-imported dropdown with a **Mode** section (Automatic, Dark, Light) and a **Theme** section (Automatic, Venix and the seasonal themes), followed, below a divider, by the themes your project adds itself. It has no dependency on Vuetify or any other UI kit:
93
80
 
94
- ### 3. Ready-made component
95
-
96
- `<VenixThemeSwitcher>` is an auto-imported dropdown for picking a theme, with no dependency on Vuetify or any other UI kit:
81
+ <p align="center">
82
+ <picture>
83
+ <source media="(prefers-color-scheme: light)" srcset="./docs/images/readme/switcher-light.png">
84
+ <img src="./docs/images/readme/switcher-dark.png" alt="VenixThemeSwitcher open next to the page: the settings gear, then the Mode, Theme (with each seasonal theme's dates) and Custom theme sections" width="800">
85
+ </picture>
86
+ </p>
97
87
 
98
88
  ```vue
99
89
  <template>
100
- <VenixThemeSwitcher label="Color theme" />
90
+ <VenixThemeSwitcher label="Website color" />
101
91
  </template>
102
92
  ```
103
93
 
104
- | Prop | Type | Default | Description |
105
- | ----------- | --------- | ----------------------- | --------------------------------------------------- |
106
- | `label` | `string` | translated, per locale | Accessible label for the button and the menu |
107
- | `showLabel` | `boolean` | `false` | Show the active theme's name next to the icon |
94
+ That's it: visitors can now pick a theme and a mode, and turn the custom scrollbar, cursor and font off. See [Theme switcher](#theme-switcher) for its props, settings and styling, or [`useVenixTheme()`](#usevenixtheme) to build your own controls.
108
95
 
109
- - **Accessible:** arrow keys, Home/End and Esc navigate the menu, focus returns to the button on close, and each change is announced to screen readers.
110
- - **Always legible:** the menu uses fixed neutral colors (dark surface, light text) instead of the active theme's, so every option stays readable whatever theme is applied. The button itself follows the active theme.
111
- - **Lively:** animated icons (e.g. `line-md`) replay on every switch, and the button fades in on mount.
96
+ <br>
112
97
 
113
- It ships with minimal CSS of its own. To restyle it, target `.venix-theme-switcher`, `.venix-theme-switcher__trigger`, `.venix-theme-switcher__menu` and `.venix-theme-switcher__item` (see [`VenixThemeSwitcher.vue`](./src/runtime/components/VenixThemeSwitcher.vue)).
98
+ ## Modules
114
99
 
115
- ### Theme transition
100
+ Jade is a set of independent modules, each configured under its own key in `venixTheme`. Every key accepts `false` (disable), `true` (enable with defaults) or an object (enable and customize):
116
101
 
117
- Every theme switch — manual, through the switcher, or an automatic system/seasonal change — cross-fades using the browser's native [View Transitions API](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API), with no setup. Browsers without support switch instantly, and the animation is skipped for users with `prefers-reduced-motion: reduce`.
102
+ | Module | Key | Default | What it does |
103
+ | --------------------------- | ------------- | ------- | --------------------------------------------------------------------- |
104
+ | [Colors](#colors) | `color` | `true` | Color themes (built-in, seasonal, custom) in light and dark mode, saved per user, as CSS variables and a UnoCSS preset |
105
+ | [Typography](#typography) | `typography` | `true` | Base font family, font size and `@font-face` rules |
106
+ | [Scrollbar](#scrollbar) | `scrollbar` | `true` | A custom scrollbar that follows the active theme |
107
+ | [Cursor](#cursor) | `cursor` | `true` | Custom cursor images |
108
+ | [Translation](#translation) | `translation` | `true` | Detects the user's locale and translates theme names and your own strings |
109
+ | [Icons](#icons) | `icon` | `true` | `<VenixIcon>`: emoji, Iconify (bundled offline) or inline SVG through one component |
110
+ | [Vuetify](#vuetify) | `vuetify` | `false` | Registers the color themes with Vuetify and keeps it in sync |
118
111
 
119
- ## Configuration
112
+ <br>
120
113
 
121
- ### Module Options
114
+ ## Colors
122
115
 
123
- Each option accepts `false` (disable), `true` (enable with defaults) or an object (enable and customize):
116
+ <p align="center">
117
+ <img alt="venixTheme: color" src="https://img.shields.io/badge/venixTheme-color-00A86B?style=for-the-badge">
118
+ <img alt="default: on" src="https://img.shields.io/badge/default-on-2EA44F?style=for-the-badge">
119
+ <img alt="third-party: none" src="https://img.shields.io/badge/third--party-none-6E7781?style=for-the-badge">
120
+ </p>
124
121
 
125
- | Option | Default | Description |
126
- | ------------- | ------- | --------------------------------------------------------------------------- |
127
- | `translation` | `true` | Locale detection for theme names — see [`translation`](#translation-object) |
128
- | `color` | `true` | Color themes — see [`color`](#color-object) and [Themes](#themes) |
129
- | `scrollbar` | `true` | Custom scrollbar — see [`scrollbar`, `cursor`, `typography`](#scrollbar-cursor-and-typography) |
130
- | `cursor` | `true` | Custom cursor images |
131
- | `typography` | `true` | Base font family, font size and `@font-face` rules |
132
- | `icon` | `true` | Installs `@nuxt/icon` and registers `<VenixIcon>` — see [Icons](#icons) |
133
- | `vuetify` | `false` | Vuetify theme auto-configuration — see [Vuetify](#vuetify-integration) |
122
+ Every theme has a light and a dark palette, exposed as CSS variables (`--color-primary`, `--color-background2`…):
134
123
 
135
- #### `translation` object
124
+ <p align="center">
125
+ <img src="./docs/images/readme/palettes.png" alt="Color palettes: Venix dark and light, Halloween dark, Christmas light" width="800">
126
+ </p>
136
127
 
137
- | Property | Type | Default | Description |
138
- | ---------------- | --------- | ------------------- | -------------------------------------------------------- |
139
- | `locale` | `string` | — | Force a locale, skipping detection |
140
- | `defaultLocale` | `string` | `'en-US'` | Fallback when no locale can be detected |
141
- | `cookieSync` | `string` | `'i18n_redirected'` | Cookie the locale is read from (and written by `locale.set()`) |
142
- | `manageHtmlLang` | `boolean` | `false` | Keep `<html lang>` in sync — see [Internationalization](#internationalization) |
128
+ | Option | Type | Default | Description |
129
+ | ---------------- | --------------------------- | -------- | ------------------------------------------------------------- |
130
+ | `apply` | `boolean` | `true` | Apply the resolved theme to `<html>` (`data-theme` and class) |
131
+ | `defaultColor` | `string` | `'dark'` | Initial choice with no saved preference: a theme (mode follows the OS), a variant id like `'dark'` (that theme in that mode) or `'system'` |
132
+ | `themes` | `object` | `{}` | Override or add themes — see [Themes](#themes) |
133
+ | `iconFormat` | `'emote' \| 'css' \| 'svg'` | `'svg'` | Preferred theme icon variant — see [Theme icons](#theme-icons) |
134
+ | `requireConsent` | `boolean` | `true` | Only save the chosen theme after cookie consent — see [Saving preferences](#saving-preferences-cookie-consent) |
135
+ | `seasonal` | `boolean` | `true` | Seasonal themes — `false` removes them entirely, see [Seasonal themes](#seasonal-themes) |
143
136
 
144
- With `translation: false`, detection is off: theme names and the switcher's strings always use `defaultLocale`, and `locale.set()` never writes the cookie.
137
+ ### Themes
145
138
 
146
- #### `color` object
139
+ Each theme has a `light` and a `dark` variant, plus a name (`translations`) and an `icon` shared by both. The module ships with **Venix** (`venix`) and the [seasonal themes](#seasonal-themes), all in both modes. `color.themes` extends that set:
147
140
 
148
- | Property | Type | Default | Description |
149
- | -------------- | --------------------------- | -------- | ------------------------------------------------------------- |
150
- | `apply` | `boolean` | `true` | Apply the resolved theme to `<html>` (`data-theme` and class) |
151
- | `defaultColor` | `string` | `'dark'` | Theme used when there's no preference yet |
152
- | `themes` | `object` | `{}` | Override or add themes — see [Themes](#themes) |
153
- | `iconFormat` | `'emote' \| 'css' \| 'svg'` | `'svg'` | Preferred theme icon variant — see [Theme icons](#theme-icons) |
154
-
155
- #### `scrollbar`, `cursor` and `typography`
156
-
157
- ```typescript
158
- venixTheme: {
159
- scrollbar: {
160
- width: 'auto',
161
- borderRadius: '8px',
162
- borderWidth: '3px',
163
- // A theme color name (follows the active theme) or any CSS color
164
- colors: { thumb: 'primary', thumbHover: 'secondary', track: 'background2', border: 'background3' },
165
- },
166
- cursor: {
167
- // Images served from `public/`; `hotspot` is the click point ("x y")
168
- cursors: {
169
- default: { path: '/cursors/default.png', hotspot: '0 0' },
170
- pointer: { path: '/cursors/pointer.png', hotspot: '0 0' },
171
- text: { path: '/cursors/text.png', hotspot: '0 0' },
172
- },
173
- },
174
- typography: {
175
- defaultFonts: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",
176
- fontSize: '16px',
177
- customFonts: [
178
- { name: 'MyFont', sources: { woff2: '/fonts/MyFont.woff2' }, weight: 'normal', style: 'normal' },
179
- ],
180
- },
181
- }
182
- ```
183
-
184
- The values shown for `scrollbar` and `typography.defaultFonts`/`fontSize` are the defaults. Custom fonts come first in `--font-family-base` (also applied to Vuetify's `--v-font-body`/`--v-font-heading`), with `defaultFonts` as the fallback.
185
-
186
- ## Themes
187
-
188
- The module ships with `dark`, `light` and the [seasonal themes](#seasonal-themes). `color.themes` extends that set:
189
-
190
- - An **existing** name overrides only the properties you set; the rest of the theme (other colors, translations, icon) stays as shipped.
191
- - A **new** name adds a theme that works like a built-in one: its own CSS variables, an entry in `useVenixTheme().themes` (so it appears in `<VenixThemeSwitcher>`), and UnoCSS/Vuetify support when enabled. New themes are dark unless you set `dark: false`.
141
+ - An **existing** name overrides only the properties you set; the rest of the theme (the other variant, other colors, translations, icon) stays as shipped.
142
+ - A **new** name adds a theme that works like a built-in one: its own CSS variables, an entry in `useVenixTheme().themes` (so it appears in `<VenixThemeSwitcher>`), and UnoCSS/Vuetify support when enabled. A theme with only one variant uses it in both modes.
192
143
 
193
144
  ```typescript
194
145
  color: {
195
146
  themes: {
196
- // Overrides only `primary` of the built-in dark theme
197
- dark: {
198
- primary: '#FF6B6B',
147
+ // Overrides only `primary` of the built-in theme in dark mode
148
+ venix: {
149
+ dark: { primary: '#FF6B6B' },
199
150
  },
200
151
 
201
152
  // Adds a project-specific theme
202
153
  summerSale: {
203
- dark: false,
204
- primary: '#FF8A00',
205
- background: '#FFF8EE',
154
+ translations: { 'en-US': 'Summer sale', 'pt-BR': 'Liquidação de verão' },
155
+ icon: '🏖️',
156
+ light: { primary: '#FF8A00', background: '#FFF8EE' },
157
+ dark: { primary: '#FFB04C', background: '#1A1206' },
206
158
  },
207
159
  },
208
160
  }
209
161
  ```
210
162
 
211
- Available colors: `primary`, `secondary`, `accent`, `error`, `info`, `success`, `warning`, `background`, `background2`, `background3`. Each becomes a `--color-<name>` CSS variable, plus `--color-inverse` (white on dark themes, black on light ones).
163
+ Available colors: `primary`, `secondary`, `accent`, `error`, `info`, `success`, `warning`, `background`, `background2`, `background3`. Each becomes a `--color-<name>` CSS variable, plus `--color-inverse` (white on dark variants, black on light ones).
164
+
165
+ Each variant is applied as `<html data-theme="<id>">`, and the id is also its Vuetify theme name. It defaults to `<theme>-<mode>` (`summerSale-light`); set `id` on a variant to choose it. The built-in themes keep the ids they had before light/dark became separate: `dark` and `light` for Venix, `carnaval`, `natal` and `halloween` for the dark seasonal variants (their light ones are `carnaval-light` and so on). Easter, added later, uses the default `pascoa-light` and `pascoa-dark`.
212
166
 
213
- ### Seasonal Themes
167
+ ### Seasonal themes
214
168
 
215
- Built in: 🎭 Carnival, 🎃 Halloween and 🎄 Christmas. While the preference is `'system'` and today is inside a seasonal theme's `dateRange`, it replaces `dark` or `light` — whichever matches its own `dark` flag and the user's system mode.
169
+ Built in: 🎭 Carnival, 🐰 Easter, 🎃 Halloween and 🎄 Christmas, each in light and dark. While the theme is `'system'` (Automatic) and today is inside a seasonal theme's `dateRange`, it replaces the base theme, in the variant matching the mode. Seasonal themes can also be picked directly, any day.
216
170
 
217
- Add your own with `seasonal: true` and a `dateRange`. Seasonal themes aren't directly selectable; they only appear through `'system'`. The range is inclusive and wraps across the new year when `end` comes before `start`. Each bound is a fixed `MM-DD` date or, for movable holidays, a number of days relative to Easter Sunday (`easter`, `easter-47`, `easter+1`):
171
+ Add your own with `seasonal: true` and a `dateRange`. The range is inclusive and wraps across the new year when `end` comes before `start`. Each bound is a fixed `MM-DD` date or, for movable holidays, a number of days relative to Easter Sunday (`easter`, `easter-47`, `easter+1`):
218
172
 
219
173
  ```typescript
220
174
  color: {
221
175
  themes: {
222
176
  blackFriday: {
223
- dark: true,
224
177
  seasonal: true,
225
178
  dateRange: { start: '11-24', end: '11-30' },
226
- primary: '#111111',
227
- background: '#000000',
179
+ dark: { primary: '#FFD400', background: '#000000' },
180
+ light: { primary: '#111111', background: '#FFF8D6' },
228
181
  },
229
- pascoa: {
230
- dark: false,
182
+ corpusChristi: {
231
183
  seasonal: true,
232
- dateRange: { start: 'easter-6', end: 'easter' }, // Holy Week, every year
233
- primary: '#F4A6C0',
234
- background: '#FFF8F0',
184
+ dateRange: { start: 'easter+60', end: 'easter+60' }, // a single day, every year
185
+ light: { primary: '#B8860B', background: '#FFFBEF' },
186
+ dark: { primary: '#F2C94C', background: '#17130A' },
235
187
  },
236
188
  },
237
189
  }
238
190
  ```
239
191
 
240
- The built-in Carnival theme uses `easter-65` to `easter-46`: 20 days, from the pre-Carnival weeks up to Ash Wednesday.
192
+ A seasonal theme with a single variant only takes over automatically when the mode matches it.
241
193
 
242
- ## Icons
194
+ To turn seasonal themes off, set `color.seasonal: false`. All of them, built-in and custom, are removed: they get no CSS, aren't listed in pickers and never take over by date. "Automatic" then always means the base theme, so it's left out of the theme list too.
243
195
 
244
- `jade` installs and configures [`@nuxt/icon`](https://github.com/nuxt/icon) and registers `<VenixIcon>` (and the matching `useVenixIcon()` composable). A single `icon` value accepts three formats:
196
+ The built-in Carnival theme uses `easter-65` to `easter-46`: 20 days, from the pre-Carnival weeks up to Ash Wednesday. Easter uses `easter-7` to `easter+1`: from Palm Sunday to Easter Monday.
245
197
 
246
- ```vue
247
- <template>
248
- <VenixIcon icon="line-md:home" />
249
- <VenixIcon icon="<svg viewBox=&quot;0 0 24 24&quot;>...</svg>" />
250
- <VenixIcon icon="🎨" />
251
- </template>
252
- ```
198
+ ### Theme transition
253
199
 
254
- - **Iconify name** — `collection:name` (e.g. `line-md:home`, `mdi:home`), including [`line-md`](https://icon-sets.iconify.design/line-md/)'s animated icons.
255
- - **Inline SVG** — a string starting with `<svg`, rendered with `v-html`. It isn't sanitized, so only pass SVGs you control, never user input.
256
- - **Emoji or text** — anything else.
200
+ Every theme switch — manual, through the switcher, or an automatic system/seasonal change — cross-fades using the browser's native [View Transitions API](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API), with no setup. Browsers without support switch instantly, and the animation is skipped for users with `prefers-reduced-motion: reduce`.
257
201
 
258
- ### Aliases
202
+ ### Flat format (deprecated)
259
203
 
260
- `icon.aliases` gives short names to any of the three formats:
204
+ Before themes had two variants, each one was a single flat set of colors with a `dark` flag (`summerSale: { dark: false, primary: '#FF8A00' }`), and built-in themes were overridden by variant name (`dark: { primary: '#FF6B6B' }`). Both still work: a flat theme becomes a theme with only that variant (same `data-theme` id as before), and an override by variant name lands on that variant. Each one logs a `[jade]` warning at build time pointing at the new format; the flat format will be removed in 2.0.
205
+
206
+ <br>
207
+
208
+ ## Typography
209
+
210
+ <p align="center">
211
+ <img alt="venixTheme: typography" src="https://img.shields.io/badge/venixTheme-typography-00A86B?style=for-the-badge">
212
+ <img alt="default: on" src="https://img.shields.io/badge/default-on-2EA44F?style=for-the-badge">
213
+ <a href="https://fonts.google.com/specimen/Iceberg"><img alt="font: Iceberg" src="https://img.shields.io/badge/font-Iceberg-1F6FEB?style=for-the-badge"></a>
214
+ </p>
215
+
216
+ Sets the base font for the whole app: `--font-family-base` and `--font-size-base` on `:root`, plus an `@font-face` rule for each custom font.
217
+
218
+ <p align="center">
219
+ <img src="./docs/images/readme/typography.png" alt="The Iceberg font at several sizes" width="800">
220
+ </p>
261
221
 
262
222
  ```typescript
263
223
  venixTheme: {
264
- icon: {
265
- aliases: {
266
- home: 'line-md:home',
267
- favorite: 'line-md:heart-filled',
268
- brand: '🎨',
269
- },
224
+ typography: {
225
+ defaultFonts: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif", // default
226
+ fontSize: '16px', // default
227
+ customFonts: [
228
+ { name: 'MyFont', sources: { woff2: '/fonts/MyFont.woff2' }, weight: 'normal', style: 'normal', preload: true },
229
+ ],
270
230
  },
271
231
  }
272
232
  ```
273
233
 
274
- ```vue
275
- <VenixIcon icon="home" />
276
- ```
234
+ `preload: true` adds a `<link rel="preload">` for the font's first source to the page `<head>`, so it downloads with the page instead of after the CSS, avoiding a flash of the fallback font. The module's own Iceberg font is preloaded.
277
235
 
278
- ### Offline icon collections
236
+ Custom fonts come first in `--font-family-base`, with `defaultFonts` as the fallback. The same font list also goes to Vuetify's `--v-font-body`/`--v-font-heading`, since Vuetify components don't inherit `font-family` from the page.
279
237
 
280
- Icons are bundled at build time, so they work offline instead of being fetched from the Iconify API:
238
+ Visitors can turn the custom fonts off in the [switcher's settings](#theme-switcher), or you can with `font.set(false)`: the module sets `data-venix-font="off"` on `<html>`, and those three variables keep only the `defaultFonts` (or become unset without them, so your `var(--font-family-base, …)` fallback applies).
281
239
 
282
- - **`line-md`** is bundled whole by default.
283
- - **Icons used in theme `icon`s or in `icon.aliases`** are detected automatically, and only those icons are bundled, not their whole collection. That's how the built-in themes' `mdi` icons are included. The collection is looked up in this module's dependencies first, then in your project's `node_modules`.
284
- - **To use any icon of a collection anywhere in your app**, install its `@iconify-json/<collection>` package and list it in `icon.collections` to bundle it whole. Keep `line-md` in the list if you still want it:
240
+ <br>
241
+
242
+ ## Scrollbar
243
+
244
+ <p align="center">
245
+ <img alt="venixTheme: scrollbar" src="https://img.shields.io/badge/venixTheme-scrollbar-00A86B?style=for-the-badge">
246
+ <img alt="default: on" src="https://img.shields.io/badge/default-on-2EA44F?style=for-the-badge">
247
+ <img alt="third-party: OverlayScrollbars (optional)" src="https://img.shields.io/badge/third--party-OverlayScrollbars_(optional)-6E7781?style=for-the-badge">
248
+ </p>
249
+
250
+ A custom scrollbar whose colors follow the active theme. The values below are the defaults:
251
+
252
+ <p align="center">
253
+ <img src="./docs/images/readme/scrollbar.png" alt="Vertical and horizontal scrollbars in the theme colors" width="800">
254
+ </p>
285
255
 
286
256
  ```typescript
287
257
  venixTheme: {
288
- icon: {
289
- collections: ['line-md', 'tabler'],
258
+ scrollbar: {
259
+ // Draws the scrollbars with OverlayScrollbars, so the custom cursor shows over them (see below)
260
+ overlay: false,
261
+ width: 'auto', // 10px for the overlay scrollbar
262
+ borderRadius: '8px',
263
+ borderWidth: '3px', // native scrollbar only
264
+ // A theme color name (follows the active theme) or any CSS color; `border` is native only
265
+ colors: { thumb: 'primary', thumbHover: 'secondary', track: 'background2', border: 'background3' },
290
266
  },
291
267
  }
292
268
  ```
293
269
 
294
- If a referenced collection can't be found, `@nuxt/icon` fetches it from the Iconify API at runtime, which needs internet. Set `icon: false` to skip `@nuxt/icon` entirely, e.g. if your project already configures it.
270
+ The scrollbars are the browser's own, styled with CSS. The CSS-styled scrollbar uses `::-webkit-scrollbar` in Chromium-based browsers and Safari, and `scrollbar-color` in Firefox, which only takes the colors (no border, radius or hover color). Chromium-based browsers (Chrome, Edge, Brave, Opera) draw a scrollbar styled this way as part of the page, so the [custom cursor](#cursor) shows over it too, the pointer over the thumb.
295
271
 
296
- ### Theme icons
272
+ Visitors can turn it off in the [switcher's settings](#theme-switcher), or you can with `scrollbar.set(false)` from `useVenixTheme()`: the module then sets `data-venix-scrollbar="off"` on `<html>` and the browser's own scrollbar comes back.
297
273
 
298
- A theme's `icon` (shown by pickers such as `<VenixThemeSwitcher>`) is either a plain emoji, like `"icon": "🌙"`, or an object with up to three variants:
274
+ ### Overlay scrollbar (optional)
299
275
 
300
- ```json
301
- "light": {
302
- "icon": {
303
- "emote": "☀️",
304
- "css": "mdi:sun-compass",
305
- "svg": "line-md:sunny-filled-loop"
306
- }
276
+ Firefox draws its scrollbar outside the page, and so does every browser for an unstyled one: those ignore the CSS `cursor`, so hovering them shows the system cursor even with the [custom cursor](#cursor) on. With `overlay: true` the scrollbars are drawn by [OverlayScrollbars](https://github.com/KingSora/OverlayScrollbars) instead, as page elements, which the custom cursor applies to (the pointer, since they can be dragged and clicked). It's off by default while it gets tried out in more sites and on phones.
277
+
278
+ OverlayScrollbars doesn't come with the module (it's an optional peer dependency): add it to your project, then turn the option on. With the option on and the package missing, the build warns and keeps the CSS-styled scrollbar.
279
+
280
+ ```bash
281
+ pnpm add overlayscrollbars
282
+ ```
283
+
284
+ ```typescript
285
+ venixTheme: {
286
+ scrollbar: { overlay: true },
307
287
  }
308
288
  ```
309
289
 
310
- - `emote` — an emoji. Required, it's the fallback.
311
- - `css` — an Iconify name rendered in CSS mode: lighter, but never animated.
312
- - `svg` — an Iconify name rendered as a real `<svg>`, needed for animated icons like `line-md`'s.
290
+ It covers:
291
+
292
+ - the page itself (`window.scrollTo` and the like keep working);
293
+ - Vuetify's scroll containers: navigation drawers, scrollable dialogs, `v-select` menus and tables, including the page and containers behind an open dialog staying locked;
294
+ - any element of yours that scrolls, marked with `data-venix-scroll`:
295
+
296
+ ```html
297
+ <div data-venix-scroll style="height: 300px; overflow: auto">…</div>
298
+ ```
299
+
300
+ Everything else keeps the browser's scrollbar, styled with CSS. Scrolling itself stays the browser's own, so smooth scrolling (`scroll-behavior: smooth`, `scrollTo({ behavior: 'smooth' })`), GSAP's ScrollTrigger, ScrollToPlugin and ScrollSmoother, and Lenis keep working. With `overlay: false` OverlayScrollbars isn't added to the bundle at all.
301
+
302
+ <br>
303
+
304
+ ## Cursor
305
+
306
+ <p align="center">
307
+ <img alt="venixTheme: cursor" src="https://img.shields.io/badge/venixTheme-cursor-00A86B?style=for-the-badge">
308
+ <img alt="default: on" src="https://img.shields.io/badge/default-on-2EA44F?style=for-the-badge">
309
+ <img alt="third-party: none" src="https://img.shields.io/badge/third--party-none-6E7781?style=for-the-badge">
310
+ </p>
311
+
312
+ Replaces the default, pointer and text cursors. On by default; set `cursor: false` to keep the system's cursors. Visitors can also turn it off for themselves in the [switcher's settings](#theme-switcher) (or you with `cursor.set(false)`), which sets `data-venix-cursor="off"` on `<html>`:
313
+
314
+ <p align="center">
315
+ <img src="./docs/images/readme/cursor.png" alt="The default, pointer and text cursors" width="800">
316
+ </p>
317
+
318
+ - **`defaultCursors`**: the default cursors, the module's fire images unless you set your own. They show with `themed: false`, in browsers that can't load the drawn cursors and for themes without a `primary`.
319
+ - **`themed`** (on by default): draws each cursor as an SVG in the active color theme's `primary`, so it changes along with the theme. Custom themes get one too, with nothing to draw.
320
+ - **`themeCursors`**: the cursor of a single color theme, by theme name (both modes) or variant id (just that one, which wins over the theme name). It is merged with the module's own entry, `venix: 'base'`, which keeps the Venix theme on the default cursors.
321
+
322
+ <p align="center">
323
+ <img src="./docs/images/readme/cursor-themes.png" alt="The cursors of each built-in theme, dark and light: Venix on the fire images ('base'), Carnival, Easter, Christmas and Halloween drawn in their own color ('themed')" width="800">
324
+ </p>
325
+
326
+ | `themeCursors` value | Cursor shown |
327
+ | --- | --- |
328
+ | `'base'` | the `defaultCursors` (the module's fire cursors, unless you set your own) |
329
+ | `'themed'` | drawn in the theme's `primary` |
330
+ | `'none'` | no custom cursor: the operating system's own |
331
+ | `{ pointer: { path, hotspot } }` | its own images; the cursors left out show as if the theme had no entry |
332
+
333
+ ```typescript
334
+ venixTheme: {
335
+ cursor: {
336
+ // `false` shows the default cursors in every theme without an entry in `themeCursors`
337
+ themed: true,
338
+ // Images served from `public/`; `hotspot` is the click point ("x y")
339
+ defaultCursors: {
340
+ default: { path: '/cursors/default.png', hotspot: '0 0' },
341
+ pointer: { path: '/cursors/pointer.png', hotspot: '0 0' },
342
+ text: { path: '/cursors/text.png', hotspot: '0 0' },
343
+ },
344
+ themeCursors: {
345
+ // Its own pointer; default and text are still drawn in its color
346
+ 'halloween': { pointer: { path: '/cursors/pumpkin.png', hotspot: '8 0' } },
347
+ 'natal': 'none',
348
+ // Drawn in its color, instead of the default cursors
349
+ 'venix': 'themed',
350
+ // Only the light variant of Carnival
351
+ 'carnaval-light': 'base',
352
+ },
353
+ },
354
+ }
355
+ ```
356
+
357
+ > [!NOTE]
358
+ > `defaultCursors` was called `cursors` up to 1.2. The old name still works, with a warning, until 2.0.
359
+
360
+ > [!NOTE]
361
+ > Keep cursor images at **32×32 pixels or smaller**. Browsers accept larger cursors (Chromium up to 128×128), but Chromium falls back to the system cursor whenever a cursor larger than 32×32 would overlap the browser UI, so it flickers near the edges of the window.
362
+ >
363
+ > Browser-drawn UI ignores the CSS `cursor` property and always shows the system cursor. That includes native scrollbars, `<select>` dropdowns, date and color pickers, and the `<textarea>` resize handle.
364
+
365
+ <br>
366
+
367
+ ## Theme switcher
368
+
369
+ <p align="center">
370
+ <img alt="component: &lt;VenixThemeSwitcher&gt;" src="https://img.shields.io/badge/component-%3CVenixThemeSwitcher%3E-00A86B?style=for-the-badge">
371
+ <img alt="UI kit: none needed" src="https://img.shields.io/badge/UI_kit-none_needed-2EA44F?style=for-the-badge">
372
+ </p>
373
+
374
+ `<VenixThemeSwitcher>` (see [Quick Setup](#2-add-the-theme-switcher)) takes these props:
313
375
 
314
- `color.iconFormat` picks the variant for every theme (default `'svg'`), falling back to `emote` when a theme doesn't define it. `useVenixTheme().themes` already resolves it to `{ format, value }`, ready for `<VenixIcon>`:
376
+ | Prop | Type | Default | Description |
377
+ | ----------- | --------- | ----------------------- | --------------------------------------------------- |
378
+ | `label` | `string` | translated, per locale | Accessible label for the button and the menu |
379
+ | `showLabel` | `boolean` | `false` | Show the theme and mode names next to the icon |
380
+ | `hideConsent` | `boolean` | `false` | Leave "Save changes" out of the settings, when your own cookie banner already asks |
381
+
382
+ The gear next to the title opens the **settings**, a few switches for the visitor:
383
+
384
+ <p align="center">
385
+ <picture>
386
+ <source media="(prefers-color-scheme: light)" srcset="./docs/images/readme/switcher-settings-light.png">
387
+ <img src="./docs/images/readme/switcher-settings-dark.png" alt="VenixThemeSwitcher settings: Save changes, Custom scrollbar, Custom cursor and Custom font switches" width="800">
388
+ </picture>
389
+ </p>
390
+
391
+ - **Save changes** — whether their choices are remembered on the next visit: it grants or revokes [cookie consent](#saving-preferences-cookie-consent) (`persistence.grant()`/`revoke()`). Shown only while `color.requireConsent` is on, and not with `hideConsent`.
392
+ - **Custom scrollbar**, **Custom cursor** and **Custom font** — turn the module's [scrollbar](#scrollbar), [cursor](#cursor) or [custom fonts](#typography) off and back on (`scrollbar.set()`/`cursor.set()`/`font.set()`). Each shown only when the project has it on (for the font: `typography` with at least one `customFonts` entry).
393
+
394
+ Without any of them, the gear isn't shown. At the bottom, in small faint print, the settings credit the module with a link to its repository.
395
+
396
+ - **Accessible:** arrow keys, Home/End and Esc navigate the menu, focus returns to the button on close, and each change is announced to screen readers.
397
+ - **Always legible:** the menu uses fixed neutral colors (dark surface, light text) instead of the active theme's, so every option stays readable whatever theme is applied. The button itself follows the active theme.
398
+ - **Seasons at a glance:** each seasonal theme shows its dates in small faint print beside its name (e.g. `01/10 a 31/10` in Portuguese, `10/01 – 10/31` in English) — the running occurrence, or the next one once this year's is over, so themes relative to Easter show the right year's dates.
399
+ - **Lively:** animated icons (e.g. `line-md`) replay on every switch, and the button fades in on mount. The button shows the mode's icon on the base theme, and the theme's own icon when a seasonal or other theme is in effect.
400
+ - **Quick:** picking a mode or a theme keeps the menu open, so both can be set in one go; it closes on the button, a click or tap outside, or Esc.
401
+ - **Fits on phones:** the menu always stays on screen: it opens upward when there's more room above the button, shifts sideways near an edge, and scrolls inside itself when it's taller than the space left (refitted when the screen rotates). On touch screens its targets are bigger, hover highlights are off, and the custom cursor's switch is hidden, since there's no cursor to show.
402
+
403
+ It ships with minimal CSS of its own. To restyle it, target `.venix-theme-switcher`, `.venix-theme-switcher__trigger`, `.venix-theme-switcher__menu`, `.venix-theme-switcher__subheading`, `.venix-theme-switcher__item` (`--mode` for the mode buttons, `--toggle` for the settings), `.venix-theme-switcher__icon-button` (the gear and back buttons) and `.venix-theme-switcher__switch` (see [`VenixThemeSwitcher.vue`](./src/runtime/components/VenixThemeSwitcher.vue)).
404
+
405
+ <br>
406
+
407
+ ## `useVenixTheme()`
408
+
409
+ <p align="center">
410
+ <img alt="composable: useVenixTheme()" src="https://img.shields.io/badge/composable-useVenixTheme()-00A86B?style=for-the-badge">
411
+ <img alt="auto-imported: yes" src="https://img.shields.io/badge/auto--imported-yes-2EA44F?style=for-the-badge">
412
+ </p>
413
+
414
+ The auto-imported `useVenixTheme()` composable gives access to the theme. It isn't called `useTheme` to avoid colliding with UI libraries (like Vuetify) that auto-import a composable with that name.
415
+
416
+ The **theme** (Venix, Carnival, Christmas…) and the **mode** (light or dark) are chosen independently; the applied colors are the theme's variant for that mode. Either can be `'system'`: an automatic theme follows the calendar ([seasonal themes](#seasonal-themes)), an automatic mode follows the OS.
315
417
 
316
418
  ```vue
317
- <VenixIcon
318
- v-if="item.icon"
319
- :icon="item.icon.value"
320
- :mode="item.icon.format === 'emote' ? undefined : item.icon.format"
321
- />
419
+ <template>
420
+ <button @click="mode.set('dark')">Dark</button>
421
+ <button @click="mode.set('light')">Light</button>
422
+ <button @click="theme.set('natal')">Christmas</button>
423
+ </template>
424
+
425
+ <script setup lang="ts">
426
+ const { theme, mode } = useVenixTheme()
427
+ </script>
322
428
  ```
323
429
 
324
- ## Cookie Consent
430
+ It returns:
325
431
 
326
- Two cookies remember the user's choice between visits:
432
+ - `theme` — the theme choice:
433
+ - `preference`: the chosen theme (`'system'`, `'venix'`, `'carnaval'`…)
434
+ - `value`: the variant actually applied, as in `data-theme` (e.g. `'natal-light'`, or `'dark'` for Venix in dark mode)
435
+ - `data`: the chosen theme's `{ value, name, icon }`
436
+ - `set(name)`: picks a theme, keeping the mode
437
+ - `toggle(name?)`: kept for compatibility — without a name switches the mode; `'dark'`/`'light'` select Venix in that mode; `'system'` makes both theme and mode automatic
438
+ - `isSeasonalActive`, `activeSeasonalTheme`: whether a [seasonal theme](#seasonal-themes) is currently in effect, and which one
439
+ - `shouldApplyColors`, `colors`: whether the module applies colors, and the resolved color config
440
+ - `themes` — every selectable theme as `{ value, name, icon, custom }`, ready to render a picker (see [Theme icons](#theme-icons)); `custom` is `true` for themes your project added in `color.themes`.
441
+ - `mode` — the mode choice: `preference` (`'system'`, `'light'`, `'dark'`), `value` (the mode applied, `'light'` or `'dark'`), `data`, `set(mode)` and `toggle()`.
442
+ - `modes` — the three mode options with names and icons, ready to render.
443
+ - `scrollbar` / `cursor` / `font` — the visitor's switch for the custom [scrollbar](#scrollbar), [cursor](#cursor) and [font](#typography): `available` (the project has it on), `enabled` (a `Ref<boolean>`, `true` unless the visitor turned it off) and `set(enabled)`.
444
+ - `locale` — `current`, `set()` and `translate()` (see [Translation](#translation)).
445
+ - `persistence` — cookie consent controls (see [Saving preferences](#saving-preferences-cookie-consent)).
327
446
 
328
- | Cookie | Stores |
329
- | ------------------------ | ----------------------------------------------------------------------------------- |
330
- | `venix-theme-preference` | The user's raw choice (`'dark'`, `'system'`, a custom theme…) |
331
- | `venix-theme-resolved` | The theme actually applied (e.g. `'dark'` for `'system'`), so SSR renders it with no flash |
447
+ The state is shared app-wide (via Nuxt's `useState`): every component calling `useVenixTheme()` reads and writes the same theme, so they never go out of sync.
332
448
 
333
- Neither is written without consent. Switching themes always works; without consent it just isn't remembered on the next visit. (The locale cookie is covered in [Integrating with a routing-based i18n module](#integrating-with-a-routing-based-i18n-module-eg-nuxtjsi18n).)
449
+ <br>
450
+
451
+ ## Saving preferences (cookie consent)
452
+
453
+ <p align="center">
454
+ <img alt="venixTheme: color.requireConsent" src="https://img.shields.io/badge/venixTheme-color.requireConsent-00A86B?style=for-the-badge">
455
+ <img alt="default: waits for consent" src="https://img.shields.io/badge/default-waits_for_consent-2EA44F?style=for-the-badge">
456
+ </p>
457
+
458
+ These cookies remember the visitor's choices between visits, for a year:
459
+
460
+ | Cookie | Stores |
461
+ | ------------------------ | ------------------------------------------------------------------------------------------------------- |
462
+ | `venix-theme-preference` | The chosen theme (`'system'`, `'venix'`, a custom theme…) |
463
+ | `venix-theme-mode` | The chosen mode (`'system'`, `'light'`, `'dark'`) |
464
+ | `venix-theme-resolved` | The variant last applied (e.g. `'natal-light'`) — lets SSR guess light or dark when the mode is `'system'` |
465
+ | `venix-scrollbar`, `venix-cursor`, `venix-font` | `'off'` when the visitor turned the custom scrollbar, cursor or font off, `'on'` otherwise |
466
+
467
+ The theme itself is always recomputed from the first two (with `'system'`, by today's date and the OS color scheme), so a saved seasonal theme never outlives its season.
468
+
469
+ Choices saved before theme and mode were separate (e.g. a theme cookie of `'dark'`) are read as the equivalent theme and mode, so users keep their theme.
470
+
471
+ By default, none of them is written without consent. Switching themes always works; without consent it just isn't remembered on the next visit. In development, the first unsaved theme change logs a `[jade]` warning in the console, so a missing consent setup doesn't go unnoticed.
334
472
 
335
473
  Consent is read from `localStorage['venix-cookie-consent']`, a JSON object with a `functionality: boolean` field — the "functional cookies" category most consent banners already use. The module never writes this key by itself. For a minimal banner, use the built-in helpers:
336
474
 
@@ -346,9 +484,10 @@ const { persistence } = useVenixTheme()
346
484
  </template>
347
485
  ```
348
486
 
487
+ - `persistence.required` — `color.requireConsent`: whether anything waits for consent at all.
349
488
  - `persistence.hasConsent` — reactive `Ref<boolean>`, shared app-wide.
350
489
  - `persistence.grant()` — records consent and saves the current theme to the cookies right away.
351
- - `persistence.revoke()` — records the refusal and deletes both cookies right away.
490
+ - `persistence.revoke()` — records the refusal and deletes the theme cookies right away.
352
491
  - `persistence.enable()` / `persistence.disable()` — lower-level: write or delete the cookies directly (`enable()` still does nothing without consent).
353
492
 
354
493
  If you already have a consent banner or CMP, have it write the same key and then dispatch `venix-cookie-preferences-updated` on `window`, so the module re-syncs immediately:
@@ -358,9 +497,38 @@ localStorage.setItem('venix-cookie-consent', JSON.stringify({ functionality: tru
358
497
  window.dispatchEvent(new Event('venix-cookie-preferences-updated'))
359
498
  ```
360
499
 
361
- ## Internationalization
500
+ For apps without a consent banner — e.g. an internal tool — turn the requirement off, and the theme is always saved:
362
501
 
363
- The resolved locale translates the theme names (each theme's `translations`) and `<VenixThemeSwitcher>`'s own strings. It's detected in this order:
502
+ ```typescript
503
+ venixTheme: {
504
+ color: {
505
+ requireConsent: false,
506
+ },
507
+ }
508
+ ```
509
+
510
+ Consent is then ignored for the theme cookies and for the locale cookie written by `locale.set()` (see [Translation](#translation)): `persistence.revoke()` no longer deletes them. Whether that's acceptable is a decision for each app.
511
+
512
+ <br>
513
+
514
+ ## Translation
515
+
516
+ <p align="center">
517
+ <img alt="venixTheme: translation" src="https://img.shields.io/badge/venixTheme-translation-00A86B?style=for-the-badge">
518
+ <img alt="default: on" src="https://img.shields.io/badge/default-on-2EA44F?style=for-the-badge">
519
+ <a href="https://i18n.nuxtjs.org"><img alt="works with: @nuxtjs/i18n" src="https://img.shields.io/badge/works_with-%40nuxtjs%2Fi18n-1F6FEB?style=for-the-badge"></a>
520
+ </p>
521
+
522
+ Detects the user's locale to translate the theme names (each theme's `translations`), `<VenixThemeSwitcher>`'s own strings and, optionally, your own strings.
523
+
524
+ | Option | Type | Default | Description |
525
+ | ---------------- | --------- | ------------------- | -------------------------------------------------------- |
526
+ | `locale` | `string` | — | Force a locale, skipping detection |
527
+ | `defaultLocale` | `string` | `'en-US'` | Fallback when no locale can be detected |
528
+ | `cookieSync` | `string` | `'i18n_redirected'` | Cookie the locale is read from (and written by `locale.set()`) |
529
+ | `manageHtmlLang` | `boolean` | `false` | Keep `<html lang>` in sync — see [below](#integrating-with-a-routing-based-i18n-module-eg-nuxtjsi18n) |
530
+
531
+ The locale is detected in this order:
364
532
 
365
533
  1. `translation.locale`, if set (skips every other step)
366
534
  2. The locale cookie (`translation.cookieSync`)
@@ -368,6 +536,8 @@ The resolved locale translates the theme names (each theme's `translations`) and
368
536
  4. The `Accept-Language` header (SSR) or `navigator.language` (client)
369
537
  5. `translation.defaultLocale`
370
538
 
539
+ With `translation: false`, detection is off: theme names and the switcher's strings always use `defaultLocale`, and `locale.set()` never writes the cookie. When it's on, `locale.set()` only writes the cookie after [cookie consent](#saving-preferences-cookie-consent), unless `color.requireConsent` is `false`.
540
+
371
541
  ### Using your own translations
372
542
 
373
543
  `locale.translate()` applies the same matching and fallbacks to your own strings:
@@ -394,7 +564,129 @@ venixTheme: {
394
564
 
395
565
  Keep it off with `@nuxtjs/i18n` or similar: that module follows the current route and should own `lang`, while this module's detection can briefly disagree with it (e.g. right after navigating to a localized route) and the two would fight over the attribute.
396
566
 
397
- ## UnoCSS integration
567
+ <br>
568
+
569
+ ## Icons
570
+
571
+ <p align="center">
572
+ <img alt="venixTheme: icon" src="https://img.shields.io/badge/venixTheme-icon-00A86B?style=for-the-badge">
573
+ <img alt="default: on" src="https://img.shields.io/badge/default-on-2EA44F?style=for-the-badge">
574
+ <a href="https://github.com/nuxt/icon"><img alt="uses: @nuxt/icon" src="https://img.shields.io/badge/uses-%40nuxt%2Ficon-1F6FEB?style=for-the-badge"></a>
575
+ <a href="https://icon-sets.iconify.design/"><img alt="icons: Iconify" src="https://img.shields.io/badge/icons-Iconify-1F6FEB?style=for-the-badge"></a>
576
+ </p>
577
+
578
+ <p align="center">
579
+ <img src="./docs/images/readme/icons.png" alt="VenixIcon rendering an animated Iconify icon, an emoji, inline SVG and aliases" width="800">
580
+ </p>
581
+
582
+ Installs and configures [`@nuxt/icon`](https://github.com/nuxt/icon), so every [Iconify](https://icon-sets.iconify.design/) icon is available in your app.
583
+
584
+ **For regular icons, use `@nuxt/icon`'s own `<Icon>`** — Jade doesn't replace it, and the Iconify aliases from `icon.aliases` work there too:
585
+
586
+ ```vue
587
+ <template>
588
+ <Icon name="mdi:home" />
589
+ <Icon name="line-md:home" mode="svg" /> <!-- `mode="svg"` is needed for line-md's animations -->
590
+ </template>
591
+ ```
592
+
593
+ **For special cases, use `<VenixIcon>`** (or the matching `useVenixIcon()` composable): when the same value may be an Iconify name, an emoji or an inline SVG — for example an icon that comes from configuration or data, like the [theme icons](#theme-icons):
594
+
595
+ ```vue
596
+ <template>
597
+ <VenixIcon icon="line-md:home" />
598
+ <VenixIcon icon="<svg viewBox=&quot;0 0 24 24&quot;>...</svg>" />
599
+ <VenixIcon icon="🎨" />
600
+ </template>
601
+ ```
602
+
603
+ - **Iconify name** — `collection:name` (e.g. `line-md:home`, `mdi:home`), rendered with `<Icon>` in CSS mode by default (lighter, but never animated); pass `mode="svg"` for a real `<svg>`, needed for animations.
604
+ - **Inline SVG** — a string starting with `<svg`, rendered with `v-html`. It isn't sanitized, so only pass SVGs you control, never user input.
605
+ - **Emoji or text** — anything else.
606
+
607
+ | Option | Type | Default | Description |
608
+ | ------------- | ------------------------ | ------------- | -------------------------------------------------- |
609
+ | `collections` | `string[]` | `['line-md']` | Iconify collections bundled whole — see [below](#offline-icon-collections) |
610
+ | `aliases` | `Record<string, string>` | `{}` | Short names for any icon value — see [below](#aliases) |
611
+
612
+ Set `icon: false` to skip `@nuxt/icon` entirely, e.g. if your project already configures it. `<VenixIcon>` isn't registered then, and theme icons always use their emoji (`emote`), so `<VenixThemeSwitcher>` keeps working.
613
+
614
+ ### Aliases
615
+
616
+ `icon.aliases` gives short names to any of the three formats:
617
+
618
+ ```typescript
619
+ venixTheme: {
620
+ icon: {
621
+ aliases: {
622
+ home: 'line-md:home',
623
+ favorite: 'line-md:heart-filled',
624
+ brand: '🎨',
625
+ },
626
+ },
627
+ }
628
+ ```
629
+
630
+ ```vue
631
+ <VenixIcon icon="home" />
632
+ ```
633
+
634
+ ### Offline icon collections
635
+
636
+ Icons are bundled at build time, so they work offline instead of being fetched from the Iconify API:
637
+
638
+ - **`line-md`** is bundled whole by default.
639
+ - **Icons used in theme `icon`s or in `icon.aliases`** are detected automatically, and only those icons are bundled, not their whole collection. That's how the built-in themes' `mdi` icons are included. The collection is looked up in this module's dependencies first, then in your project's `node_modules`.
640
+ - **To use any icon of a collection anywhere in your app**, install its `@iconify-json/<collection>` package and list it in `icon.collections` to bundle it whole. The list replaces the default, so keep `line-md` in it if you still want it:
641
+
642
+ ```typescript
643
+ venixTheme: {
644
+ icon: {
645
+ collections: ['line-md', 'tabler'],
646
+ },
647
+ }
648
+ ```
649
+
650
+ If a referenced collection can't be found, `@nuxt/icon` fetches it from the Iconify API at runtime, which needs internet.
651
+
652
+ ### Theme icons
653
+
654
+ A theme's `icon` (shown by pickers such as `<VenixThemeSwitcher>`) is either a plain emoji, like `"icon": "🌙"`, or an object with up to three variants:
655
+
656
+ ```json
657
+ "natal": {
658
+ "icon": {
659
+ "emote": "🎄",
660
+ "css": "mdi:pine-tree-variant",
661
+ "svg": "line-md:star-filled"
662
+ }
663
+ }
664
+ ```
665
+
666
+ - `emote` — an emoji. Required, it's the fallback.
667
+ - `css` — an Iconify name rendered in CSS mode: lighter, but never animated.
668
+ - `svg` — an Iconify name rendered as a real `<svg>`, needed for animated icons like `line-md`'s.
669
+
670
+ `color.iconFormat` picks the variant for every theme (default `'svg'`, so the built-in `line-md` icons animate). When a theme doesn't define it, the other Iconify variant is tried before the emoji: `svg` → `css` → `emote` (or `css` → `svg` → `emote`). The mode options (Automatic, Light, Dark) use the same formats. `useVenixTheme().themes` and `.modes` already resolve it to `{ format, value }`, ready for `<VenixIcon>`:
671
+
672
+ ```vue
673
+ <VenixIcon
674
+ v-if="item.icon"
675
+ :icon="item.icon.value"
676
+ :mode="item.icon.format === 'emote' ? undefined : item.icon.format"
677
+ />
678
+ ```
679
+
680
+ <br>
681
+
682
+ ## Integrations
683
+
684
+ ### UnoCSS preset
685
+
686
+ <p align="center">
687
+ <img alt="import: @venix-sistemas/jade/unocss" src="https://img.shields.io/badge/import-%40venix--sistemas%2Fjade%2Funocss-00A86B?style=for-the-badge">
688
+ <a href="https://unocss.dev"><img alt="requires: UnoCSS" src="https://img.shields.io/badge/requires-UnoCSS-1F6FEB?style=for-the-badge"></a>
689
+ </p>
398
690
 
399
691
  Add the preset to your `uno.config.ts` to use the theme colors as utilities (`text-primary`, `bg-background2`, `border-accent`, …):
400
692
 
@@ -415,7 +707,13 @@ It maps every [theme color](#themes), plus `inverse`, to its CSS variable (`prim
415
707
 
416
708
  The preset has to be added by hand: `@unocss/nuxt` re-reads `uno.config.ts` from disk and discards a `theme` injected by other modules whenever your file declares its own `theme` key. As a preset in your own file, the colors survive that.
417
709
 
418
- ## Vuetify integration
710
+ ### Vuetify
711
+
712
+ <p align="center">
713
+ <img alt="venixTheme: vuetify" src="https://img.shields.io/badge/venixTheme-vuetify-00A86B?style=for-the-badge">
714
+ <img alt="default: off" src="https://img.shields.io/badge/default-off-6E7781?style=for-the-badge">
715
+ <a href="https://nuxt.vuetifyjs.com"><img alt="requires: vuetify-nuxt-module" src="https://img.shields.io/badge/requires-vuetify--nuxt--module-1F6FEB?style=for-the-badge"></a>
716
+ </p>
419
717
 
420
718
  With [`vuetify-nuxt-module`](https://nuxt.vuetifyjs.com) installed, `vuetify: true` registers every color theme with Vuetify and keeps its active theme in sync — no hand-written `theme.themes` mapping:
421
719
 
@@ -434,11 +732,40 @@ export default defineNuxtConfig({
434
732
  - **Order matters:** the themes are registered through Vuetify's [`vuetify:registerModule`](https://nuxt.vuetifyjs.com/guide/advanced/layers-and-hooks.html) hook, which only sees modules listed before Vuetify.
435
733
  - **Real colors:** Vuetify computes contrast and `on-*` colors in JavaScript, so it receives the actual hex values, not `var(...)`. `background2` also fills Vuetify's `surface` slot (cards, toolbars, …).
436
734
  - **Your values win:** anything you set in `vuetify.vuetifyOptions.theme.themes` is merged per color on top of the generated themes.
437
- - **Always in sync:** a small runtime plugin picks Vuetify's initial theme from the same cookies (so the first paint is right, with or without SSR) and applies every later switch with `theme.change()`, inside the same View Transition as the rest of the page.
735
+ - **Always in sync:** a small runtime plugin starts Vuetify on the same theme the page gets (so the first paint is right, with or without SSR) and applies every later switch with `theme.change()`, inside the same View Transition as the rest of the page.
438
736
  - **No flash in SPA mode** (`ssr: false`): Vuetify's theme stylesheet only reaches the DOM after the first render there, so the plugin writes a temporary copy into `<head>` before mount and removes it once Vuetify's own arrives.
439
737
 
440
738
  It's opt-in because it adds a runtime plugin, and it does nothing if `vuetify-nuxt-module` isn't installed. Tested with Vuetify `^4.2.1` and `vuetify-nuxt-module@1.0.0-rc.6`; that module is still pre-1.0, so its hooks may change.
441
739
 
740
+ ### Content-Security-Policy
741
+
742
+ <p align="center">
743
+ <a href="https://nuxt-security.vercel.app"><img alt="works with: nuxt-security" src="https://img.shields.io/badge/works_with-nuxt--security-1F6FEB?style=for-the-badge"></a>
744
+ </p>
745
+
746
+ To avoid a wrong-theme flash, a small inline script in `<head>` applies the theme before the page renders. Under a strict CSP that blocks inline scripts, it needs the request's nonce: with [`nuxt-security`](https://nuxt-security.vercel.app) and nonces enabled, the module adds it automatically (from `event.context.security.nonce`).
747
+
748
+ <br>
749
+
750
+ ## Third-party packages
751
+
752
+ Colors, typography, scrollbar, cursor, translation and the switcher are Jade's own code, with no package behind them (the overlay scrollbar aside). These come from third parties:
753
+
754
+ | Package | Used for | How it's included | License |
755
+ | ------- | -------- | ----------------- | ------- |
756
+ | [`@nuxt/icon`](https://github.com/nuxt/icon) | Renders Iconify icons for `<Icon>` and `<VenixIcon>` ([Icons](#icons)) | Installed with Jade; skipped with `icon: false` | MIT |
757
+ | [`@iconify/utils`](https://github.com/iconify/iconify) | Picks the icons to bundle offline ([Offline icon collections](#offline-icon-collections)) | Installed with Jade | MIT |
758
+ | [`@iconify-json/line-md`](https://github.com/cyberalien/line-md) | Animated Material Line Icons, by Vjacheslav Trushkin | Installed with Jade, bundled by default | MIT |
759
+ | [`@iconify-json/mdi`](https://github.com/Templarian/MaterialDesign) | Material Design Icons, by Pictogrammers, used by the built-in themes | Installed with Jade, only the icons used are bundled | Apache 2.0 |
760
+ | [Iceberg](https://fonts.google.com/specimen/Iceberg) | The module's default custom font ([Typography](#typography)) | Shipped in the package | SIL OFL 1.1 |
761
+ | [OverlayScrollbars](https://github.com/KingSora/OverlayScrollbars) | Scrollbars the custom cursor shows over ([Overlay scrollbar](#overlay-scrollbar-optional)) | Optional, installed by you | MIT |
762
+ | [UnoCSS](https://unocss.dev) | Theme colors as utilities ([UnoCSS preset](#unocss-preset)) | Optional, installed by you | MIT |
763
+ | [Vuetify](https://vuetifyjs.com) + [`vuetify-nuxt-module`](https://nuxt.vuetifyjs.com) | Theme sync with Vuetify ([Vuetify](#vuetify)) | Optional, installed by you | MIT |
764
+ | [`nuxt-security`](https://nuxt-security.vercel.app) | Nonce for the theme script under a strict CSP ([Content-Security-Policy](#content-security-policy)) | Optional, installed by you | MIT |
765
+ | [`@nuxtjs/i18n`](https://i18n.nuxtjs.org) | Shares its locale cookie with [Translation](#translation) | Optional, installed by you | MIT |
766
+
767
+ <br>
768
+
442
769
  ## Development
443
770
 
444
771
  | Command | Description |