@venix-sistemas/jade 1.4.0 β†’ 1.4.2-alpha.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 (45) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +994 -969
  3. package/dist/module.d.mts +1 -0
  4. package/dist/module.json +4 -1
  5. package/dist/module.mjs +39 -10
  6. package/dist/runtime/components/VenixIcon.vue +20 -20
  7. package/dist/runtime/components/VenixThemeSwitcher.vue +336 -336
  8. package/dist/runtime/composables/useVenixTheme.d.ts +4 -4
  9. package/dist/runtime/composables/useVenixTheme.js +25 -0
  10. package/dist/runtime/nitro/theme-init.js +1 -1
  11. package/dist/runtime/scripts/theme-init.d.ts +11 -1
  12. package/dist/runtime/scripts/theme-init.js +25 -2
  13. package/dist/runtime/server/tsconfig.json +3 -3
  14. package/dist/shared/css/colors.d.ts +1 -1
  15. package/dist/shared/css/colors.js +11 -3
  16. package/dist/shared/css/index.js +1 -1
  17. package/dist/shared/css/tokens.d.ts +7 -0
  18. package/dist/shared/css/tokens.js +32 -5
  19. package/dist/shared/theme.json +314 -320
  20. package/dist/shared/token-names.d.ts +14 -5
  21. package/dist/shared/token-names.js +1 -1
  22. package/dist/shared/types/color-options.d.ts +24 -1
  23. package/dist/shared/types/colors.d.ts +2 -0
  24. package/dist/shared/types/index.d.ts +3 -1
  25. package/dist/shared/types/runtime-config.d.ts +2 -0
  26. package/dist/shared/types/theme-names.d.ts +23 -0
  27. package/dist/shared/types/theme-names.js +0 -0
  28. package/dist/shared/utils/base-url.d.ts +15 -0
  29. package/dist/shared/utils/base-url.js +32 -0
  30. package/dist/shared/utils/derive-seeds.d.ts +24 -0
  31. package/dist/shared/utils/derive-seeds.js +30 -0
  32. package/dist/shared/utils/load.d.ts +1 -1
  33. package/dist/shared/utils/load.js +1 -1
  34. package/dist/shared/utils/merge-themes.d.ts +10 -0
  35. package/dist/shared/utils/merge-themes.js +55 -0
  36. package/dist/shared/utils/oklab.d.ts +8 -0
  37. package/dist/shared/utils/oklab.js +15 -2
  38. package/dist/shared/utils/scale.d.ts +7 -2
  39. package/dist/shared/utils/scale.js +4 -3
  40. package/dist/shared/utils/theme-color.d.ts +9 -0
  41. package/dist/shared/utils/theme-color.js +10 -0
  42. package/dist/shared/utils/theme-types.d.ts +8 -0
  43. package/dist/shared/utils/theme-types.js +16 -0
  44. package/dist/types.d.mts +2 -0
  45. package/package.json +25 -24
package/README.md CHANGED
@@ -1,969 +1,994 @@
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
-
42
- ## Installation
43
-
44
- ```bash
45
- pnpm add @venix-sistemas/jade
46
- # or
47
- npm install @venix-sistemas/jade
48
- ```
49
-
50
- <br>
51
-
52
- ## Quick Setup
53
-
54
- ### 1. Add the module
55
-
56
- ```typescript
57
- // nuxt.config.ts
58
- export default defineNuxtConfig({
59
- modules: ['@venix-sistemas/jade'],
60
- })
61
- ```
62
-
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, your own brand theme as the one new visitors start on:
64
-
65
- ```typescript
66
- venixTheme: {
67
- color: {
68
- themes: {
69
- acme: {
70
- translations: { 'en-US': 'Acme', 'pt-BR': 'Acme' },
71
- light: { primary: '#1565C0', background: '#F5F8FC' },
72
- dark: { primary: '#64B5F6', background: '#0B1420' },
73
- },
74
- },
75
- defaultColor: 'acme',
76
- },
77
- }
78
- ```
79
-
80
- > [!IMPORTANT]
81
- > **Venix** (`venix`) is the brand theme of Venix Sistemas: keep its colors as shipped. For another identity, add a theme of your own (as above) and point `defaultColor` at it. Venix stays available in the switcher next to it. Overriding Venix's colors logs a `[jade]` warning at build time, unless `color.allowVenixOverride` is `true`.
82
-
83
- See [Modules](#modules) for what each one does.
84
-
85
- ### 2. Add the theme switcher
86
-
87
- `<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:
88
-
89
- <p align="center">
90
- <picture>
91
- <source media="(prefers-color-scheme: light)" srcset="./docs/images/readme/switcher-light.png">
92
- <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">
93
- </picture>
94
- </p>
95
-
96
- ```vue
97
- <template>
98
- <VenixThemeSwitcher label="Website color" />
99
- </template>
100
- ```
101
-
102
- 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.
103
-
104
- <br>
105
-
106
- ## Modules
107
-
108
- 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):
109
-
110
- | Module | Key | Default | What it does |
111
- | --------------------------- | ------------- | ------- | --------------------------------------------------------------------- |
112
- | [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 |
113
- | [Typography](#typography) | `typography` | `true` | Base font family, font size and `@font-face` rules |
114
- | [Scrollbar](#scrollbar) | `scrollbar` | `true` | A custom scrollbar that follows the active theme |
115
- | [Cursor](#cursor) | `cursor` | `true` | Custom cursor images |
116
- | [Translation](#translation) | `translation` | `true` | Detects the user's locale and translates theme names and your own strings |
117
- | [Icons](#icons) | `icon` | `true` | `<VenixIcon>`: emoji, Iconify (bundled offline) or inline SVG through one component |
118
- | [Vuetify](#vuetify) | `vuetify` | `false` | Registers the color themes with Vuetify and keeps it in sync |
119
- | [Experimental](#built-in-themes-and-experimental) | `experimental` | `false` | Experimental features to try on a project: today, the semantic color tokens on your own themes too, and on Vuetify |
120
-
121
- <br>
122
-
123
- ## Colors
124
-
125
- <p align="center">
126
- <img alt="venixTheme: color" src="https://img.shields.io/badge/venixTheme-color-00A86B?style=for-the-badge">
127
- <img alt="default: on" src="https://img.shields.io/badge/default-on-2EA44F?style=for-the-badge">
128
- <img alt="third-party: none" src="https://img.shields.io/badge/third--party-none-6E7781?style=for-the-badge">
129
- </p>
130
-
131
- Every theme has a light and a dark palette, exposed as CSS variables (`--color-primary`, `--color-background2`…):
132
-
133
- <p align="center">
134
- <img src="./docs/images/readme/palettes.png" alt="Color palettes: Venix dark and light, Halloween dark, Christmas light" width="800">
135
- </p>
136
-
137
- | Option | Type | Default | Description |
138
- | ---------------- | --------------------------- | -------- | ------------------------------------------------------------- |
139
- | `apply` | `boolean` | `true` | Apply the resolved theme to `<html>` (`data-theme` and class) |
140
- | `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'`. A value that matches no available theme warns at build time and falls back to `'system'` |
141
- | `themes` | `object` | `{}` | Override or add themes β€” see [Themes](#themes) |
142
- | `iconFormat` | `'emote' \| 'css' \| 'svg'` | `'svg'` | Preferred theme icon variant β€” see [Theme icons](#theme-icons) |
143
- | `requireConsent` | `boolean` | `true` | Only save the chosen theme after cookie consent β€” see [Saving preferences](#saving-preferences-cookie-consent) |
144
- | `seasonal` | `boolean` | `true` | Seasonal themes β€” `false` removes them entirely, see [Seasonal themes](#seasonal-themes) |
145
- | `allowVenixOverride` | `boolean` | `false` | Override the colors of the Venix brand theme without the build warning β€” see [Themes](#themes) |
146
- | `contrast` | `'AA' \| 'AAA' \| false` | `'AA'` | Experimental. Contrast the [semantic tokens](#semantic-tokens-experimental) aim for, and what the build warns about; `false` skips the warning |
147
-
148
- ### Themes
149
-
150
- 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:
151
-
152
- - An **existing** name overrides only the properties you set; the rest of the theme (the other variant, other colors, translations, icon) stays as shipped. Venix's colors are the exception: they're the Venix Sistemas brand, so overriding them warns at build time unless `allowVenixOverride` is `true`. Add your own theme instead.
153
- - 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.
154
-
155
- ```typescript
156
- color: {
157
- themes: {
158
- // Overrides only the name of a built-in seasonal theme
159
- natal: {
160
- translations: { 'en-US': 'Holidays', 'pt-BR': 'Festas' },
161
- },
162
-
163
- // Adds a project-specific theme
164
- summerSale: {
165
- translations: { 'en-US': 'Summer sale', 'pt-BR': 'LiquidaΓ§Γ£o de verΓ£o' },
166
- icon: 'πŸ–οΈ',
167
- light: { primary: '#FF8A00', background: '#FFF8EE' },
168
- dark: { primary: '#FFB04C', background: '#1A1206' },
169
- },
170
- },
171
- }
172
- ```
173
-
174
- 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). For colors that meet WCAG contrast by construction, the built-in themes also ship [semantic tokens](#semantic-tokens-experimental) (experimental), and your own themes can opt in.
175
-
176
- 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`.
177
-
178
- ### Seasonal themes
179
-
180
- 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.
181
-
182
- 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`):
183
-
184
- ```typescript
185
- color: {
186
- themes: {
187
- blackFriday: {
188
- seasonal: true,
189
- dateRange: { start: '11-24', end: '11-30' },
190
- dark: { primary: '#FFD400', background: '#000000' },
191
- light: { primary: '#111111', background: '#FFF8D6' },
192
- },
193
- corpusChristi: {
194
- seasonal: true,
195
- dateRange: { start: 'easter+60', end: 'easter+60' }, // a single day, every year
196
- light: { primary: '#B8860B', background: '#FFFBEF' },
197
- dark: { primary: '#F2C94C', background: '#17130A' },
198
- },
199
- },
200
- }
201
- ```
202
-
203
- A seasonal theme with a single variant only takes over automatically when the mode matches it.
204
-
205
- 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.
206
-
207
- 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.
208
-
209
- ### Semantic tokens (experimental)
210
-
211
- > **Experimental.** Additive, and the names or steps may still change before it's declared stable. Everything above (`--color-primary`, `--color-background2`…) keeps working exactly as before, next to the tokens: the built-in themes ship both, and your own themes opt in per theme (or all at once with [`experimental`](#built-in-themes-and-experimental)).
212
-
213
- A theme with `tokens: true` (the built-in themes have it already) also gets **semantic tokens**: CSS variables named for where the color goes (`--jade-text-primary`, `--jade-fill-primary`, `--jade-bg-subtle`…), generated from the variant's `primary`, `secondary` and `background`. Each token points at a step of a 12-step scale whose pairs are placed so they meet WCAG 2.1 contrast, so you don't have to guess which shade is readable on which background.
214
-
215
- ```typescript
216
- color: {
217
- themes: {
218
- brand: {
219
- tokens: true,
220
- translations: { 'en-US': 'Brand', 'pt-BR': 'Marca' },
221
- light: { primary: '#FF0000', secondary: '#FF8800', background: '#FAFAFA' },
222
- dark: { primary: '#FF6B6B', secondary: '#FFB96A', background: '#0C0C0C' },
223
- },
224
- },
225
- contrast: 'AA', // 'AA' | 'AAA' | false
226
- }
227
- ```
228
-
229
- ```css
230
- .card {
231
- background: var(--jade-bg-subtle);
232
- color: var(--jade-text);
233
- border: 1px solid var(--jade-border);
234
- }
235
-
236
- .button {
237
- background: var(--jade-fill-primary);
238
- color: var(--jade-on-primary);
239
- }
240
-
241
- .button:hover {
242
- background: var(--jade-fill-primary-hover);
243
- }
244
- ```
245
-
246
- The old variables stay: a token theme still emits `--color-primary` and `--color-secondary` (the seeds), so CSS written for the original model works on it too. A token theme should set `background`; without one the tokens are built on `#FFFFFF` (light) or `#121212` (dark).
247
-
248
- **Names.** `--color-<property>[-<role>][-<variant>][-<state>]`: the property says what the color is for (`bg`, `text`, `fill`, `on`, `border`), the role is `primary` or `secondary`, the variant is `subtle`, `muted`, `strong` or `focus`, and the state is `hover` or `active`. None of them repeats a name from the original model, so both live side by side.
249
-
250
- Neutral tokens, built from the theme's `background` (`--jade-bg` *is* the background, exactly). By default they lean very slightly toward the hue of `primary`, so the surfaces feel of one piece with the theme. A `background` that already has a color of its own (a peach `#FFF8F0`, say) is not pulled toward `primary`: its own hue is kept, and the surfaces and borders get more of it the farther they sit from the page, the way a hand-made palette does, so a card doesn't look grayer than the page behind it. A gray `background` (`#FAFAFA`, `#0C0C0C`) works as described above. Set `neutralTint: false` next to `tokens: true` for plain grays instead (contrast is the same either way):
251
-
252
- | Token | Use |
253
- | ----- | --- |
254
- | `bg` | Page |
255
- | `bg-subtle` | Card, sidebar, striped row |
256
- | `bg-muted` | Neutral component at rest: chip, quiet button, disabled field |
257
- | `bg-hover` / `bg-active` | Neutral item under the pointer / pressed or selected |
258
- | `border` | Divider, decorative outline |
259
- | `border-strong` | Outline that identifies a control, like a form field (3:1) |
260
- | `border-focus` | Keyboard focus ring (3:1) |
261
- | `text` | Main text |
262
- | `text-muted` | Helper text, dates, captions |
263
- | `text-disabled` | Disabled controls (WCAG exempts them) |
264
-
265
- Tokens for each role (`primary`, `secondary`), shown for `primary`:
266
-
267
- | Token | Use |
268
- | ----- | --- |
269
- | `fill-primary` | Main button, strong badge, toggle on. It is the seed, exactly |
270
- | `fill-primary-hover` | The same under the pointer |
271
- | `on-primary` | Text and icons on `fill-primary`: white or black, whichever contrasts more |
272
- | `bg-primary` / `bg-primary-hover` / `bg-primary-active` | Soft tinted background: selected item, highlight box, soft badge |
273
- | `text-primary` | Link, colored text on neutral backgrounds and on `bg-primary` |
274
- | `text-primary-strong` | Colored text on `bg-primary-hover` and `bg-primary-active` |
275
- | `border-primary` | Decorative outline of something on `bg-primary` |
276
- | `border-primary-strong` | Outline that must be seen (3:1) |
277
-
278
- **The scale.** Each seed becomes 12 steps defined by their contrast ratio against the background, not by fixed lightness, so the same ratios work in light and dark mode: 1–2 area backgrounds, 3–5 component backgrounds (rest, hover, pressed), 6–8 borders, 9–10 solid fill (the seed and its hover), 11–12 text. The hover moves away from the text on it: lighter when `on-*` is black, darker when it's white, so the text never loses contrast. A seed that sits close to the background (orange on white) gets its steps squeezed to fit under it.
279
-
280
- **Stronger or weaker surfaces.** `tokens` can also be an object that re-points individual tokens at another step (1–12) of the generated scales, instead of a fixed color. The reference is `neutral-<n>` or `<role>-<n>`, and the steps mean the same in light and dark, so one entry covers both modes and still follows the seeds. Handy when a surface reads too faint or too heavy for a theme:
281
-
282
- ```ts
283
- color: {
284
- themes: {
285
- brand: {
286
- tokens: { 'bg-subtle': 'neutral-3', 'border-strong': 'neutral-10' }, // cards a step above the default
287
- light: { primary: '#0B6E8A', background: '#F4FAFC' },
288
- dark: { primary: '#4FC3D9', background: '#08141A' },
289
- },
290
- },
291
- }
292
- ```
293
-
294
- The overridden tokens go through the same contrast check, and moving a surface moves what sits on it: `bg-subtle` at `neutral-3` warns that `border-strong` falls to 2.85:1 on it until that one moves too. Any token can be overridden except `on-<role>`, which is white or black. A token, step or role that doesn't exist is ignored, with a `[jade]` warning. A hex color isn't accepted: it would be the same in both modes.
295
-
296
- **Contrast.** `color.contrast` sets the target: `'AA'` (default: text 4.5:1, outlines 3:1) or `'AAA'` (text 7:1). At build time each token variant is checked for these pairs, and one `[jade]` warning per variant lists every pair that falls short, with its ratio:
297
-
298
- - `text` on `bg`, `bg-subtle`, `bg-muted`, `bg-hover`, `bg-active`; `text-muted` on `bg`, `bg-subtle`, `bg-muted`
299
- - `border-strong` and `border-focus` on `bg` and `bg-subtle`
300
- - per role: `on-<role>` on `fill-<role>` and `fill-<role>-hover`; `text-<role>` on `bg`, `bg-subtle`, `bg-muted` and `bg-<role>`; `text-<role>-strong` on `bg-<role>-hover` and `bg-<role>-active`; `text` on `bg-<role>` and `bg-<role>-active`; `border-<role>-strong` on `bg`
301
-
302
- A warning usually means the seed itself can't get there, not that the scale is wrong. The Venix red (`#FF0000`) reaches 5.25:1 with black text, so at `'AAA'` the light variant warns about `on-primary`; pick a darker seed or stay on `'AA'`. `false` skips the warning but still generates the tokens, as AA. With `'AA'`, `on-*` can never fail: the better of black and white always reaches at least 4.58:1.
303
-
304
- **Where the tokens show up.**
305
-
306
- - **CSS:** in the variant's `[data-theme]` block, after the usual variables.
307
- - **`useVenixTheme().tokens`:** `all` (every variant's tokens by `data-theme` id), `current` (the applied theme's, `undefined` when it has none) and `cssVar('text-primary')` β†’ `'var(--jade-text-primary)'`. See [`useVenixTheme()`](#usevenixtheme).
308
- - **UnoCSS:** one class per token, with the `jade-` prefix: `jade-bg-subtle`, `jade-text-muted`, `jade-fill-primary`. See [UnoCSS preset](#unocss-preset).
309
- - **Vuetify:** `on-primary`, `on-secondary`, `surface`, `on-surface` and `on-background`. See [Vuetify](#vuetify).
310
- - **`<VenixThemeSwitcher>`:** its menu follows the tokens on token themes and keeps its fixed palette everywhere else.
311
-
312
- The tokens are generated at build time with [Adobe Leonardo](https://github.com/adobe/leonardo) and never reach the client bundle; the client only receives the resulting hex values. Roles in this version are `primary` and `secondary`.
313
-
314
- #### Built-in themes and `experimental`
315
-
316
- Venix and the four seasonal themes ship with `tokens: true`, **next to** the old model: `--color-primary`, `--color-background2`… keep exactly the values they had, so nothing written for 1.x changes. Venix keeps plain gray surfaces (`neutralTint: false`) and lifts `bg-subtle` and `bg-muted` a step, close to its old `background2`/`3`; a seasonal theme keeps the hue of its own `background`.
317
-
318
- Two things are left as they were for projects that already exist:
319
-
320
- - **Vuetify.** The tokens of the built-in themes don't feed Vuetify's colors in 1.x: it keeps picking its own text color on `primary`, so buttons don't change. A theme you set `tokens` on yourself does feed it.
321
- - **The build's contrast check.** It skips the built-in themes: at `'AAA'` some of their seeds can't reach 7:1, and that isn't yours to fix.
322
-
323
- Your own themes opt in per theme with `tokens`. To get the tokens on all of them at once, turn on the `experimental` option. It's **off by default**:
324
-
325
- ```typescript
326
- venixTheme: {
327
- experimental: true, // or { enabled: true }
328
- }
329
- ```
330
-
331
- Every theme that doesn't set `tokens` itself then gets them, built from its own `primary`, `secondary` and `background`, so `jade-bg-subtle`, `var(--jade-text-primary)` and `useVenixTheme().tokens` work on whichever theme is applied. A theme with `tokens: false` stays out, and one with its own `tokens` keeps them as written. The contrast check covers them, and asking for the tokens everywhere includes Vuetify's colors (see [Vuetify](#vuetify)), the built-in themes' too.
332
-
333
- It is a build-time choice, equivalent to writing `tokens: true` on every theme: there is no switch for the visitor. Both models live side by side until 2.0.0, when the old `--color-*` variables and `background2`/`3` go and the tokens become the only model.
334
-
335
- ### Theme transition
336
-
337
- 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`.
338
-
339
- ### Flat format (deprecated)
340
-
341
- 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.
342
-
343
- <br>
344
-
345
- ## Typography
346
-
347
- <p align="center">
348
- <img alt="venixTheme: typography" src="https://img.shields.io/badge/venixTheme-typography-00A86B?style=for-the-badge">
349
- <img alt="default: on" src="https://img.shields.io/badge/default-on-2EA44F?style=for-the-badge">
350
- <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>
351
- </p>
352
-
353
- 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.
354
-
355
- <p align="center">
356
- <img src="./docs/images/readme/typography.png" alt="The Iceberg font at several sizes" width="800">
357
- </p>
358
-
359
- ```typescript
360
- venixTheme: {
361
- typography: {
362
- defaultFonts: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif", // default
363
- fontSize: '16px', // default
364
- customFonts: [
365
- { name: 'MyFont', sources: { woff2: '/fonts/MyFont.woff2' }, weight: 'normal', style: 'normal', preload: true },
366
- ],
367
- },
368
- }
369
- ```
370
-
371
- `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.
372
-
373
- 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.
374
-
375
- 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).
376
-
377
- <br>
378
-
379
- ## Scrollbar
380
-
381
- <p align="center">
382
- <img alt="venixTheme: scrollbar" src="https://img.shields.io/badge/venixTheme-scrollbar-00A86B?style=for-the-badge">
383
- <img alt="default: on" src="https://img.shields.io/badge/default-on-2EA44F?style=for-the-badge">
384
- <img alt="third-party: OverlayScrollbars (optional)" src="https://img.shields.io/badge/third--party-OverlayScrollbars_(optional)-6E7781?style=for-the-badge">
385
- </p>
386
-
387
- A custom scrollbar whose colors follow the active theme. The values below are the defaults:
388
-
389
- <p align="center">
390
- <img src="./docs/images/readme/scrollbar.png" alt="Vertical and horizontal scrollbars in the theme colors" width="800">
391
- </p>
392
-
393
- ```typescript
394
- venixTheme: {
395
- scrollbar: {
396
- // Draws the scrollbars with OverlayScrollbars, so the custom cursor shows over them (see below)
397
- overlay: false,
398
- width: 'auto', // 10px for the overlay scrollbar
399
- borderRadius: '8px',
400
- borderWidth: '3px', // native scrollbar only
401
- // A theme color name (follows the active theme) or any CSS color; `border` is native only
402
- colors: { thumb: 'primary', thumbHover: 'secondary', track: 'background2', border: 'background3' },
403
- },
404
- }
405
- ```
406
-
407
- 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.
408
-
409
- 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.
410
-
411
- ### Overlay scrollbar (optional)
412
-
413
- 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.
414
-
415
- 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.
416
-
417
- ```bash
418
- pnpm add overlayscrollbars
419
- ```
420
-
421
- ```typescript
422
- venixTheme: {
423
- scrollbar: { overlay: true },
424
- }
425
- ```
426
-
427
- It covers:
428
-
429
- - the page itself (`window.scrollTo` and the like keep working);
430
- - Vuetify's scroll containers: navigation drawers, scrollable dialogs, `v-select` menus and tables, including the page and containers behind an open dialog staying locked;
431
- - any element of yours that scrolls, marked with `data-venix-scroll`:
432
-
433
- ```html
434
- <div data-venix-scroll style="height: 300px; overflow: auto">…</div>
435
- ```
436
-
437
- 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.
438
-
439
- <br>
440
-
441
- ## Cursor
442
-
443
- <p align="center">
444
- <img alt="venixTheme: cursor" src="https://img.shields.io/badge/venixTheme-cursor-00A86B?style=for-the-badge">
445
- <img alt="default: on" src="https://img.shields.io/badge/default-on-2EA44F?style=for-the-badge">
446
- <img alt="third-party: none" src="https://img.shields.io/badge/third--party-none-6E7781?style=for-the-badge">
447
- </p>
448
-
449
- 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>`:
450
-
451
- <p align="center">
452
- <img src="./docs/images/readme/cursor.png" alt="The default, pointer and text cursors" width="800">
453
- </p>
454
-
455
- - **`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`.
456
- - **`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.
457
- - **`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.
458
-
459
- <p align="center">
460
- <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">
461
- </p>
462
-
463
- | `themeCursors` value | Cursor shown |
464
- | --- | --- |
465
- | `'base'` | the `defaultCursors` (the module's fire cursors, unless you set your own) |
466
- | `'themed'` | drawn in the theme's `primary` |
467
- | `'none'` | no custom cursor: the operating system's own |
468
- | `{ pointer: { path, hotspot } }` | its own images; the cursors left out show as if the theme had no entry |
469
-
470
- ```typescript
471
- venixTheme: {
472
- cursor: {
473
- // `false` shows the default cursors in every theme without an entry in `themeCursors`
474
- themed: true,
475
- // Images served from `public/`; `hotspot` is the click point ("x y")
476
- defaultCursors: {
477
- default: { path: '/cursors/default.png', hotspot: '0 0' },
478
- pointer: { path: '/cursors/pointer.png', hotspot: '0 0' },
479
- text: { path: '/cursors/text.png', hotspot: '0 0' },
480
- },
481
- themeCursors: {
482
- // Its own pointer; default and text are still drawn in its color
483
- 'halloween': { pointer: { path: '/cursors/pumpkin.png', hotspot: '8 0' } },
484
- 'natal': 'none',
485
- // Drawn in its color, instead of the default cursors
486
- 'venix': 'themed',
487
- // Only the light variant of Carnival
488
- 'carnaval-light': 'base',
489
- },
490
- },
491
- }
492
- ```
493
-
494
- ### Cursors in your own CSS
495
-
496
- The custom cursor is set on `<html>` and reaches the rest of the page by inheritance. Any element with a `cursor` of its own shows that one instead, so a fixed `cursor: pointer` in your CSS shows the **system's** hand. Use the module's variables:
497
-
498
- ```css
499
- .my-clickable { cursor: var(--cursor-pointer); }
500
- .my-readonly { cursor: var(--cursor-default); }
501
- .my-editor { cursor: var(--cursor-text); }
502
- ```
503
-
504
- They follow the color theme and switch to the system's cursors when the visitor turns the custom cursor off. The utility classes `cursor-default`, `cursor-pointer` and `cursor-text` (Vuetify's, and UnoCSS's with the [UnoCSS preset](#unocss-preset)) use them too.
505
-
506
- The module already gives the variables to what browsers and Vuetify 4 style with a fixed cursor: links, buttons, form fields, and Vuetify's clickable components (table rows with `@click:row`, sortable headers, `v-card` with `hover`, chip close buttons, `v-select`, switches, sliders, menu activators and so on). Its CSS is outside any `@layer`, so it wins over Vuetify's, which is layered, without `!important`. Your own rules (outside a layer, too) still win over it when they are more specific. For a table with `@click:row` where only some rows do something:
507
-
508
- ```css
509
- .orders .v-data-table__tr--clickable.no-action { cursor: var(--cursor-default); }
510
- ```
511
-
512
- Or the class `cursor-default` on those rows (`:row-props="row => ({ class: row.item.locked && 'cursor-default' })"`). Links, buttons, `[role="button"]`, text fields and disabled elements keep `!important`, so the pointer shows over everything inside a link or button and the arrow over a disabled one; for these, change the cursor with `!important` too (`!cursor-default` in UnoCSS).
513
-
514
- > [!NOTE]
515
- > `defaultCursors` was called `cursors` up to 1.2. The old name still works, with a warning, until 2.0.
516
-
517
- > [!NOTE]
518
- > 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.
519
- >
520
- > 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.
521
-
522
- <br>
523
-
524
- ## Theme switcher
525
-
526
- <p align="center">
527
- <img alt="component: &lt;VenixThemeSwitcher&gt;" src="https://img.shields.io/badge/component-%3CVenixThemeSwitcher%3E-00A86B?style=for-the-badge">
528
- <img alt="UI kit: none needed" src="https://img.shields.io/badge/UI_kit-none_needed-2EA44F?style=for-the-badge">
529
- </p>
530
-
531
- `<VenixThemeSwitcher>` (see [Quick Setup](#2-add-the-theme-switcher)) takes these props:
532
-
533
- | Prop | Type | Default | Description |
534
- | ----------- | --------- | ----------------------- | --------------------------------------------------- |
535
- | `label` | `string` | translated, per locale | Accessible label for the button and the menu |
536
- | `showLabel` | `boolean` | `false` | Show the theme and mode names next to the icon |
537
- | `hideConsent` | `boolean` | `false` | Leave "Save changes" and the save reminder out, when your own cookie banner already asks |
538
-
539
- And emits one event:
540
-
541
- | Event | When |
542
- | ---------------- | ------------------------------------------------------------------------------------------ |
543
- | `consent-needed` | The visitor's first change on this visit that won't be remembered (no consent yet, with `color.requireConsent`) |
544
-
545
- With your own cookie banner, use it to bring the banner up at the moment it matters:
546
-
547
- ```vue
548
- <VenixThemeSwitcher hide-consent @consent-needed="openCookieBanner()" />
549
- ```
550
-
551
- The gear next to the title opens the **settings**, a few switches for the visitor:
552
-
553
- <p align="center">
554
- <picture>
555
- <source media="(prefers-color-scheme: light)" srcset="./docs/images/readme/switcher-settings-light.png">
556
- <img src="./docs/images/readme/switcher-settings-dark.png" alt="VenixThemeSwitcher settings: Save changes, Custom scrollbar, Custom cursor and Custom font switches" width="800">
557
- </picture>
558
- </p>
559
-
560
- - **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`.
561
- - **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).
562
-
563
- 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.
564
-
565
- Since "Save changes" is easy to miss, a change that won't be remembered (a theme, a mode or one of the switches, without consent yet) opens a small reminder at the bottom of the menu: **Remember your choices? Β· Uses cookies**, with **Save** and **Γ—** (not now). **Save** grants consent right there (`persistence.grant()`) and briefly confirms; **Γ—** hides the reminder for the rest of the visit. Nothing is stored for "not now" (that would itself need consent), so it can come back on the next visit after another change. It never shows with `hideConsent`, once consent is recorded, or after the visitor revoked it on this visit.
566
-
567
- - **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.
568
- - **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.
569
- - **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.
570
- - **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.
571
- - **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.
572
- - **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.
573
-
574
- 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), `.venix-theme-switcher__prompt` (the save reminder) and `.venix-theme-switcher__switch` (see [`VenixThemeSwitcher.vue`](./src/runtime/components/VenixThemeSwitcher.vue)).
575
-
576
- <br>
577
-
578
- ## `useVenixTheme()`
579
-
580
- <p align="center">
581
- <img alt="composable: useVenixTheme()" src="https://img.shields.io/badge/composable-useVenixTheme()-00A86B?style=for-the-badge">
582
- <img alt="auto-imported: yes" src="https://img.shields.io/badge/auto--imported-yes-2EA44F?style=for-the-badge">
583
- </p>
584
-
585
- 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.
586
-
587
- 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.
588
-
589
- ```vue
590
- <template>
591
- <button @click="mode.set('dark')">Dark</button>
592
- <button @click="mode.set('light')">Light</button>
593
- <button @click="theme.set('natal')">Christmas</button>
594
- </template>
595
-
596
- <script setup lang="ts">
597
- const { theme, mode } = useVenixTheme()
598
- </script>
599
- ```
600
-
601
- It returns:
602
-
603
- - `theme` β€” the theme choice:
604
- - `preference`: the chosen theme (`'system'`, `'venix'`, `'carnaval'`…)
605
- - `value`: the variant actually applied, as in `data-theme` (e.g. `'natal-light'`, or `'dark'` for Venix in dark mode)
606
- - `data`: the chosen theme's `{ value, name, icon }`
607
- - `set(name)`: picks a theme, keeping the mode
608
- - `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
609
- - `isSeasonalActive`, `activeSeasonalTheme`: whether a [seasonal theme](#seasonal-themes) is currently in effect, and which one
610
- - `shouldApplyColors`, `colors`: whether the module applies colors, and the resolved color config
611
- - `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`.
612
- - `mode` β€” the mode choice: `preference` (`'system'`, `'light'`, `'dark'`), `value` (the mode applied, `'light'` or `'dark'`), `data`, `set(mode)` and `toggle()`.
613
- - `modes` β€” the three mode options with names and icons, ready to render.
614
- - `tokens` β€” the [semantic tokens](#semantic-tokens-experimental) (experimental) of the themes with `tokens: true` (the built-in ones included): `all` (every variant's tokens by `data-theme` id), `current` (a computed with the applied theme's tokens, `undefined` when it has none) and `cssVar('text-primary')`, which returns `'var(--jade-text-primary)'`.
615
- - `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)`.
616
- - `locale` β€” `current`, `set()` and `translate()` (see [Translation](#translation)).
617
- - `persistence` β€” cookie consent controls (see [Saving preferences](#saving-preferences-cookie-consent)).
618
-
619
- 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.
620
-
621
- <br>
622
-
623
- ## Saving preferences (cookie consent)
624
-
625
- <p align="center">
626
- <img alt="venixTheme: color.requireConsent" src="https://img.shields.io/badge/venixTheme-color.requireConsent-00A86B?style=for-the-badge">
627
- <img alt="default: waits for consent" src="https://img.shields.io/badge/default-waits_for_consent-2EA44F?style=for-the-badge">
628
- </p>
629
-
630
- These cookies remember the visitor's choices between visits, for a year:
631
-
632
- | Cookie | Stores |
633
- | ------------------------ | ------------------------------------------------------------------------------------------------------- |
634
- | `venix-theme-preference` | The chosen theme (`'system'`, `'venix'`, a custom theme…) |
635
- | `venix-theme-mode` | The chosen mode (`'system'`, `'light'`, `'dark'`) |
636
- | `venix-theme-resolved` | The variant last applied (e.g. `'natal-light'`) β€” lets SSR guess light or dark when the mode is `'system'` |
637
- | `venix-scrollbar`, `venix-cursor`, `venix-font` | `'off'` when the visitor turned the custom scrollbar, cursor or font off, `'on'` otherwise |
638
-
639
- 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.
640
-
641
- Open pages follow these cookies live: a choice saved in another tab, or by another site on the same host using this module (cookies are shared by host, not by port β€” e.g. two apps on `localhost`, or subdomains sharing a cookie domain), is applied without a reload. Browsers with the [Cookie Store API](https://developer.mozilla.org/docs/Web/API/Cookie_Store_API) apply it right away; the others when the page is focused again. A page only follows them while it can save its own choices (see consent below).
642
-
643
- 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.
644
-
645
- 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.
646
-
647
- 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:
648
-
649
- ```vue
650
- <script setup lang="ts">
651
- const { persistence } = useVenixTheme()
652
- </script>
653
-
654
- <template>
655
- <p>Cookies: {{ persistence.hasConsent.value ? 'allowed' : 'not allowed' }}</p>
656
- <button @click="persistence.grant()">Allow cookies</button>
657
- <button @click="persistence.revoke()">Revoke cookies</button>
658
- </template>
659
- ```
660
-
661
- - `persistence.required` β€” `color.requireConsent`: whether anything waits for consent at all.
662
- - `persistence.hasConsent` β€” reactive `Ref<boolean>`, shared app-wide.
663
- - `persistence.grant()` β€” records consent and saves the current theme to the cookies right away.
664
- - `persistence.revoke()` β€” records the refusal and deletes the theme cookies right away.
665
- - `persistence.enable()` / `persistence.disable()` β€” lower-level: write or delete the cookies directly (`enable()` still does nothing without consent).
666
-
667
- 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:
668
-
669
- ```ts
670
- localStorage.setItem('venix-cookie-consent', JSON.stringify({ functionality: true }))
671
- window.dispatchEvent(new Event('venix-cookie-preferences-updated'))
672
- ```
673
-
674
- For apps without a consent banner β€” e.g. an internal tool β€” turn the requirement off, and the theme is always saved:
675
-
676
- ```typescript
677
- venixTheme: {
678
- color: {
679
- requireConsent: false,
680
- },
681
- }
682
- ```
683
-
684
- 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.
685
-
686
- <br>
687
-
688
- ## Translation
689
-
690
- <p align="center">
691
- <img alt="venixTheme: translation" src="https://img.shields.io/badge/venixTheme-translation-00A86B?style=for-the-badge">
692
- <img alt="default: on" src="https://img.shields.io/badge/default-on-2EA44F?style=for-the-badge">
693
- <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>
694
- </p>
695
-
696
- Detects the user's locale to translate the theme names (each theme's `translations`), `<VenixThemeSwitcher>`'s own strings and, optionally, your own strings.
697
-
698
- | Option | Type | Default | Description |
699
- | ---------------- | --------- | ------------------- | -------------------------------------------------------- |
700
- | `locale` | `string` | β€” | Force a locale, skipping detection |
701
- | `defaultLocale` | `string` | `'en-US'` | Fallback when no locale can be detected |
702
- | `cookieSync` | `string` | `'i18n_redirected'` | Cookie the locale is read from (and written by `locale.set()`) |
703
- | `manageHtmlLang` | `boolean` | `false` | Keep `<html lang>` in sync β€” see [below](#integrating-with-a-routing-based-i18n-module-eg-nuxtjsi18n) |
704
-
705
- The locale is detected in this order:
706
-
707
- 1. `translation.locale`, if set (skips every other step)
708
- 2. The locale cookie (`translation.cookieSync`)
709
- 3. The URL's locale prefix (e.g. `/en/...`), if a theme has a translation for it
710
- 4. The `Accept-Language` header (SSR) or `navigator.language` (client)
711
- 5. `translation.defaultLocale`
712
-
713
- 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`.
714
-
715
- ### Using your own translations
716
-
717
- `locale.translate()` applies the same matching and fallbacks to your own strings:
718
-
719
- ```ts
720
- const { locale } = useVenixTheme()
721
-
722
- locale.translate({ 'en-US': 'Hello', 'pt-BR': 'OlΓ‘' }, 'Hello') // second argument: fallback
723
- ```
724
-
725
- ### Integrating with a routing-based i18n module (e.g. `@nuxtjs/i18n`)
726
-
727
- `translation.cookieSync` defaults to `'i18n_redirected'`, the same cookie `@nuxtjs/i18n` uses, so theme names follow your app's locale with no extra setup. If you renamed the cookie on either side, point `cookieSync` at the same name.
728
-
729
- `<html lang>` isn't touched by default. If your app has **no** routing i18n module, turn on `manageHtmlLang` so `lang` reflects the resolved locale (WCAG 3.1.1 β€” screen readers pronounce the theme names correctly):
730
-
731
- ```ts
732
- venixTheme: {
733
- translation: {
734
- manageHtmlLang: true,
735
- },
736
- }
737
- ```
738
-
739
- 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.
740
-
741
- <br>
742
-
743
- ## Icons
744
-
745
- <p align="center">
746
- <img alt="venixTheme: icon" src="https://img.shields.io/badge/venixTheme-icon-00A86B?style=for-the-badge">
747
- <img alt="default: on" src="https://img.shields.io/badge/default-on-2EA44F?style=for-the-badge">
748
- <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>
749
- <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>
750
- </p>
751
-
752
- <p align="center">
753
- <img src="./docs/images/readme/icons.png" alt="VenixIcon rendering an animated Iconify icon, an emoji, inline SVG and aliases" width="528">
754
- </p>
755
-
756
- Installs and configures [`@nuxt/icon`](https://github.com/nuxt/icon), so every [Iconify](https://icon-sets.iconify.design/) icon is available in your app.
757
-
758
- **For regular icons, use `@nuxt/icon`'s own `<Icon>`** β€” Jade doesn't replace it, and the Iconify aliases from `icon.aliases` work there too:
759
-
760
- ```vue
761
- <template>
762
- <Icon name="mdi:home" />
763
- <Icon name="line-md:home" mode="svg" /> <!-- `mode="svg"` is needed for line-md's animations -->
764
- </template>
765
- ```
766
-
767
- **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):
768
-
769
- ```vue
770
- <template>
771
- <VenixIcon icon="line-md:home" />
772
- <VenixIcon icon="<svg viewBox=&quot;0 0 24 24&quot;>...</svg>" />
773
- <VenixIcon icon="🎨" />
774
- </template>
775
- ```
776
-
777
- - **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.
778
- - **Inline SVG** β€” a string starting with `<svg`, rendered with `v-html`. It isn't sanitized, so only pass SVGs you control, never user input.
779
- - **Emoji or text** β€” anything else.
780
-
781
- | Option | Type | Default | Description |
782
- | ------------- | ------------------------ | ------------- | -------------------------------------------------- |
783
- | `collections` | `string[]` | `['line-md']` | Iconify collections bundled whole β€” see [below](#offline-icon-collections) |
784
- | `aliases` | `Record<string, string>` | `{}` | Short names for any icon value β€” see [below](#aliases) |
785
-
786
- 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.
787
-
788
- ### Aliases
789
-
790
- `icon.aliases` gives short names to any of the three formats:
791
-
792
- ```typescript
793
- venixTheme: {
794
- icon: {
795
- aliases: {
796
- home: 'line-md:home',
797
- favorite: 'line-md:heart-filled',
798
- brand: '🎨',
799
- },
800
- },
801
- }
802
- ```
803
-
804
- ```vue
805
- <VenixIcon icon="home" />
806
- ```
807
-
808
- ### Offline icon collections
809
-
810
- Icons are bundled at build time, so they work offline instead of being fetched from the Iconify API:
811
-
812
- - **`line-md`** is bundled whole by default.
813
- - **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`.
814
- - **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:
815
-
816
- ```typescript
817
- venixTheme: {
818
- icon: {
819
- collections: ['line-md', 'tabler'],
820
- },
821
- }
822
- ```
823
-
824
- If a referenced collection can't be found, `@nuxt/icon` fetches it from the Iconify API at runtime, which needs internet.
825
-
826
- ### Theme icons
827
-
828
- 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:
829
-
830
- ```json
831
- "natal": {
832
- "icon": {
833
- "emote": "πŸŽ„",
834
- "css": "mdi:pine-tree-variant",
835
- "svg": "line-md:star-filled"
836
- }
837
- }
838
- ```
839
-
840
- - `emote` β€” an emoji. Required, it's the fallback.
841
- - `css` β€” an Iconify name rendered in CSS mode: lighter, but never animated.
842
- - `svg` β€” an Iconify name rendered as a real `<svg>`, needed for animated icons like `line-md`'s.
843
-
844
- `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>`:
845
-
846
- ```vue
847
- <VenixIcon
848
- v-if="item.icon"
849
- :icon="item.icon.value"
850
- :mode="item.icon.format === 'emote' ? undefined : item.icon.format"
851
- />
852
- ```
853
-
854
- <br>
855
-
856
- ## Integrations
857
-
858
- ### UnoCSS preset
859
-
860
- <p align="center">
861
- <img alt="import: @venix-sistemas/jade/unocss" src="https://img.shields.io/badge/import-%40venix--sistemas%2Fjade%2Funocss-00A86B?style=for-the-badge">
862
- <a href="https://unocss.dev"><img alt="requires: UnoCSS" src="https://img.shields.io/badge/requires-UnoCSS-1F6FEB?style=for-the-badge"></a>
863
- </p>
864
-
865
- Add the preset to your `uno.config.ts` to use the theme colors as utilities (`text-primary`, `bg-background2`, `border-accent`, …):
866
-
867
- ```typescript
868
- // uno.config.ts
869
- import { defineConfig } from 'unocss'
870
- import { venixUnoPreset } from '@venix-sistemas/jade/unocss'
871
-
872
- export default defineConfig({
873
- presets: [
874
- venixUnoPreset(),
875
- // ...your other presets
876
- ],
877
- })
878
- ```
879
-
880
- It maps every [theme color](#themes), plus `inverse`, to its CSS variable (`primary: 'var(--color-primary)'`, …), so utilities follow the active theme. Colors you define yourself in `uno.config.ts` take precedence.
881
-
882
- The [semantic tokens](#semantic-tokens-experimental) (experimental) are classes named after their CSS variable, with the `jade-` prefix: `--jade-bg-subtle` β†’ `jade-bg-subtle`, `jade-text-muted`, `jade-border-strong`, `jade-fill-primary`, `jade-on-primary`, `hover:jade-bg-hover`. Each sets the property the token is for (`bg-*` and `fill-*` the background, `text-*` and `on-*` the text color, `border-*` the border color). The prefix keeps them apart from other color systems' classes (Vuetify's `text-primary`, or the `text-muted` and `bg-muted` of Bootstrap and shadcn), and from the plain `bg-primary` / `text-primary` above. They are rules, not theme colors, so there is no `/50` opacity (it doesn't apply to a `var()` anyway) and no ring, divider or gradient version. They only have a value on themes with `tokens: true`. Pass `venixUnoPreset({ tokens: false })` to leave them out.
883
-
884
- It also makes `cursor-default`, `cursor-pointer` and `cursor-text` use the [custom cursor](#cursors-in-your-own-css) (`cursor: var(--cursor-pointer, pointer)`, the system's when the module's cursor is off), with variants and `!` included (`hover:cursor-pointer`, `!cursor-default`). These replace `presetWind`'s rules of the same name wherever the preset sits in `presets`.
885
-
886
- 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.
887
-
888
- ### Vuetify
889
-
890
- <p align="center">
891
- <img alt="venixTheme: vuetify" src="https://img.shields.io/badge/venixTheme-vuetify-00A86B?style=for-the-badge">
892
- <img alt="default: off" src="https://img.shields.io/badge/default-off-6E7781?style=for-the-badge">
893
- <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>
894
- </p>
895
-
896
- 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:
897
-
898
- ```typescript
899
- export default defineNuxtConfig({
900
- modules: [
901
- '@venix-sistemas/jade', // must come before the Vuetify module
902
- 'vuetify-nuxt-module',
903
- ],
904
- venixTheme: {
905
- vuetify: true,
906
- },
907
- })
908
- ```
909
-
910
- - **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.
911
- - **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, …).
912
- - **Semantic tokens** (experimental): a theme you set `tokens: true` on (or every theme, with `experimental`) also gives Vuetify `on-primary` and `on-secondary` (it would otherwise pick its own, which prefers white on the Venix red, 4.0:1), `surface` from `bg-subtle` (unless the theme sets `background2`), and `on-surface` and `on-background` from `text`. The built-in themes carry tokens of their own, but in 1.x those stay out of Vuetify, so its colors don't change under existing projects. See [Semantic tokens](#semantic-tokens-experimental).
913
- - **Your values win:** anything you set in `vuetify.vuetifyOptions.theme.themes` is merged per color on top of the generated themes.
914
- - **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.
915
- - **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.
916
-
917
- 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.
918
-
919
- ### Content-Security-Policy
920
-
921
- <p align="center">
922
- <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>
923
- </p>
924
-
925
- 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`).
926
-
927
- <br>
928
-
929
- ## Third-party packages
930
-
931
- Colors, typography, scrollbar, cursor, translation and the switcher are Jade's own code, with no package behind them (the overlay scrollbar and the build-time color engine of the semantic tokens aside). These come from third parties:
932
-
933
- | Package | Used for | How it's included | License |
934
- | ------- | -------- | ----------------- | ------- |
935
- | [`@adobe/leonardo-contrast-colors`](https://github.com/adobe/leonardo) | Generates the 12-step color scales behind the [semantic tokens](#semantic-tokens-experimental), at build time only: it never reaches the browser bundle | Installed with Jade | Apache 2.0 |
936
- | [`@nuxt/icon`](https://github.com/nuxt/icon) | Renders Iconify icons for `<Icon>` and `<VenixIcon>` ([Icons](#icons)) | Installed with Jade; skipped with `icon: false` | MIT |
937
- | [`@iconify/utils`](https://github.com/iconify/iconify) | Picks the icons to bundle offline ([Offline icon collections](#offline-icon-collections)) | Installed with Jade | MIT |
938
- | [`@iconify-json/line-md`](https://github.com/cyberalien/line-md) | Animated Material Line Icons, by Vjacheslav Trushkin | Installed with Jade, bundled by default | MIT |
939
- | [`@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 |
940
- | [Iceberg](https://fonts.google.com/specimen/Iceberg) | The module's default custom font ([Typography](#typography)) | Shipped in the package | SIL OFL 1.1 |
941
- | [OverlayScrollbars](https://github.com/KingSora/OverlayScrollbars) | Scrollbars the custom cursor shows over ([Overlay scrollbar](#overlay-scrollbar-optional)) | Optional, installed by you | MIT |
942
- | [UnoCSS](https://unocss.dev) | Theme colors as utilities ([UnoCSS preset](#unocss-preset)) | Optional, installed by you | MIT |
943
- | [Vuetify](https://vuetifyjs.com) + [`vuetify-nuxt-module`](https://nuxt.vuetifyjs.com) | Theme sync with Vuetify ([Vuetify](#vuetify)) | Optional, installed by you | MIT |
944
- | [`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 |
945
- | [`@nuxtjs/i18n`](https://i18n.nuxtjs.org) | Shares its locale cookie with [Translation](#translation) | Optional, installed by you | MIT |
946
-
947
- <br>
948
-
949
- ## Development
950
-
951
- | Command | Description |
952
- | -------------- | -------------------- |
953
- | `pnpm install` | Install dependencies |
954
- | `pnpm dev` | Start the [playground](./playground) |
955
- | `pnpm test` | Run the tests |
956
- | `pnpm lint` | Run the linter |
957
- | `pnpm prepack` | Build the package |
958
-
959
- ## Brand
960
-
961
- The Jade logo, in the variants shipped with the repository (`docs/images`):
962
-
963
- | Transparent | Dark background | Emblem |
964
- | :---------: | :-------------: | :--------------: |
965
- | <img src="./docs/images/jade-transparent.png" alt="Jade, transparent background" width="200"> | <img src="./docs/images/jade.png" alt="Jade, dark background" width="200"> | <img src="./docs/images/jade-emblem.png" alt="Jade emblem" width="200"> |
966
-
967
- ## License
968
-
969
- [MIT](./LICENSE)
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
+
42
+ ## Installation
43
+
44
+ ```bash
45
+ pnpm add @venix-sistemas/jade
46
+ # or
47
+ npm install @venix-sistemas/jade
48
+ ```
49
+
50
+ <br>
51
+
52
+ ## Quick Setup
53
+
54
+ ### 1. Add the module
55
+
56
+ ```typescript
57
+ // nuxt.config.ts
58
+ export default defineNuxtConfig({
59
+ modules: ['@venix-sistemas/jade'],
60
+ })
61
+ ```
62
+
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, your own brand theme as the one new visitors start on:
64
+
65
+ ```typescript
66
+ venixTheme: {
67
+ color: {
68
+ themes: {
69
+ acme: {
70
+ translations: { 'en-US': 'Acme', 'pt-BR': 'Acme' },
71
+ light: { primary: '#1565C0', background: '#F5F8FC' },
72
+ dark: { primary: '#64B5F6', background: '#0B1420' },
73
+ },
74
+ },
75
+ defaultColor: 'acme',
76
+ },
77
+ }
78
+ ```
79
+
80
+ > [!IMPORTANT]
81
+ > **Venix** (`venix`) is the brand theme of Venix Sistemas: keep its colors as shipped. For another identity, add a theme of your own (as above) and point `defaultColor` at it. Venix stays available in the switcher next to it. Overriding Venix's colors logs a `[jade]` warning at build time, unless `color.allowVenixOverride` is `true`.
82
+
83
+ See [Modules](#modules) for what each one does.
84
+
85
+ ### 2. Add the theme switcher
86
+
87
+ `<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:
88
+
89
+ <p align="center">
90
+ <picture>
91
+ <source media="(prefers-color-scheme: light)" srcset="./docs/images/readme/switcher-light.png">
92
+ <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">
93
+ </picture>
94
+ </p>
95
+
96
+ ```vue
97
+ <template>
98
+ <VenixThemeSwitcher label="Website color" />
99
+ </template>
100
+ ```
101
+
102
+ 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.
103
+
104
+ <br>
105
+
106
+ ## Modules
107
+
108
+ 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):
109
+
110
+ | Module | Key | Default | What it does |
111
+ | --------------------------- | ------------- | ------- | --------------------------------------------------------------------- |
112
+ | [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 |
113
+ | [Typography](#typography) | `typography` | `true` | Base font family, font size and `@font-face` rules |
114
+ | [Scrollbar](#scrollbar) | `scrollbar` | `true` | A custom scrollbar that follows the active theme |
115
+ | [Cursor](#cursor) | `cursor` | `true` | Custom cursor images |
116
+ | [Translation](#translation) | `translation` | `true` | Detects the user's locale and translates theme names and your own strings |
117
+ | [Icons](#icons) | `icon` | `true` | `<VenixIcon>`: emoji, Iconify (bundled offline) or inline SVG through one component |
118
+ | [Vuetify](#vuetify) | `vuetify` | `false` | Registers the color themes with Vuetify and keeps it in sync |
119
+ | [Experimental](#built-in-themes-and-experimental) | `experimental` | `false` | Experimental features to try on a project: today, the semantic color tokens on your own themes too, and on Vuetify |
120
+
121
+ <br>
122
+
123
+ ## Colors
124
+
125
+ <p align="center">
126
+ <img alt="venixTheme: color" src="https://img.shields.io/badge/venixTheme-color-00A86B?style=for-the-badge">
127
+ <img alt="default: on" src="https://img.shields.io/badge/default-on-2EA44F?style=for-the-badge">
128
+ <img alt="third-party: none" src="https://img.shields.io/badge/third--party-none-6E7781?style=for-the-badge">
129
+ </p>
130
+
131
+ Every theme has a light and a dark palette, exposed as CSS variables (`--color-primary`, `--color-background2`…):
132
+
133
+ <p align="center">
134
+ <img src="./docs/images/readme/palettes.png" alt="Color palettes: Venix dark and light, Halloween dark, Christmas light" width="800">
135
+ </p>
136
+
137
+ | Option | Type | Default | Description |
138
+ | ---------------- | --------------------------- | -------- | ------------------------------------------------------------- |
139
+ | `apply` | `boolean` | `true` | Apply the resolved theme to `<html>` (`data-theme` and class) |
140
+ | `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'`. A value that matches no available theme warns at build time and falls back to `'system'` |
141
+ | `themes` | `object` | `{}` | Override or add themes β€” see [Themes](#themes) |
142
+ | `iconFormat` | `'emote' \| 'css' \| 'svg'` | `'svg'` | Preferred theme icon variant β€” see [Theme icons](#theme-icons) |
143
+ | `requireConsent` | `boolean` | `true` | Only save the chosen theme after cookie consent β€” see [Saving preferences](#saving-preferences-cookie-consent) |
144
+ | `seasonal` | `boolean` | `true` | Seasonal themes β€” `false` removes them entirely, see [Seasonal themes](#seasonal-themes) |
145
+ | `allowVenixOverride` | `boolean` | `false` | Override the colors of the Venix brand theme without the build warning β€” see [Themes](#themes) |
146
+ | `contrast` | `'AA' \| 'AAA' \| false` | `'AA'` | Experimental. Contrast the [semantic tokens](#semantic-tokens-experimental) aim for, and what the build warns about; `false` skips the warning |
147
+ | `highContrast` | `boolean` | `false` | Experimental. Also write the AAA token values (text 7:1) inside `@media (prefers-contrast: more)`, so visitors who ask their system for more contrast get them with no setting on the site β€” see [Contrast](#semantic-tokens-experimental) |
148
+ | `themeColorMeta` | `boolean \| string` | `false` | Keep `<meta name="theme-color">` in step with the theme, so the browser bar on phones and installed apps follows it: `true` uses the variant's `background`, a color name (`'primary'`, `'background2'`…) uses that one. Written before the first paint and updated on each switch; remove a `theme-color` of your own, or there will be two |
149
+
150
+ ### Themes
151
+
152
+ 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:
153
+
154
+ - An **existing** name overrides only the properties you set; the rest of the theme (the other variant, other colors, translations, icon) stays as shipped. Venix's colors are the exception: they're the Venix Sistemas brand, so overriding them warns at build time unless `allowVenixOverride` is `true`. Add your own theme instead.
155
+ - 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.
156
+
157
+ ```typescript
158
+ color: {
159
+ themes: {
160
+ // Overrides only the name of a built-in seasonal theme
161
+ natal: {
162
+ translations: { 'en-US': 'Holidays', 'pt-BR': 'Festas' },
163
+ },
164
+
165
+ // Adds a project-specific theme
166
+ summerSale: {
167
+ translations: { 'en-US': 'Summer sale', 'pt-BR': 'LiquidaΓ§Γ£o de verΓ£o' },
168
+ icon: 'πŸ–οΈ',
169
+ light: { primary: '#FF8A00', background: '#FFF8EE' },
170
+ dark: { primary: '#FFB04C', background: '#1A1206' },
171
+ },
172
+ },
173
+ }
174
+ ```
175
+
176
+ 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). For colors that meet WCAG contrast by construction, the built-in themes also ship [semantic tokens](#semantic-tokens-experimental) (experimental), and your own themes can opt in.
177
+
178
+ 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`.
179
+
180
+ ### Seasonal themes
181
+
182
+ 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.
183
+
184
+ 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`):
185
+
186
+ ```typescript
187
+ color: {
188
+ themes: {
189
+ blackFriday: {
190
+ seasonal: true,
191
+ dateRange: { start: '11-24', end: '11-30' },
192
+ dark: { primary: '#FFD400', background: '#000000' },
193
+ light: { primary: '#111111', background: '#FFF8D6' },
194
+ },
195
+ corpusChristi: {
196
+ seasonal: true,
197
+ dateRange: { start: 'easter+60', end: 'easter+60' }, // a single day, every year
198
+ light: { primary: '#B8860B', background: '#FFFBEF' },
199
+ dark: { primary: '#F2C94C', background: '#17130A' },
200
+ },
201
+ },
202
+ }
203
+ ```
204
+
205
+ A seasonal theme with a single variant only takes over automatically when the mode matches it.
206
+
207
+ 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.
208
+
209
+ 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.
210
+
211
+ ### Semantic tokens (experimental)
212
+
213
+ > **Experimental.** Additive, and the names or steps may still change before it's declared stable. Everything above (`--color-primary`, `--color-background2`…) keeps working exactly as before, next to the tokens: the built-in themes ship both, and your own themes opt in per theme (or all at once with [`experimental`](#built-in-themes-and-experimental)).
214
+
215
+ A theme with `tokens: true` (the built-in themes have it already) also gets **semantic tokens**: CSS variables named for where the color goes (`--jade-text-primary`, `--jade-fill-primary`, `--jade-bg-subtle`…), generated from the variant's `primary`, `secondary` and `background`. Each token points at a step of a 12-step scale whose pairs are placed so they meet WCAG 2.1 contrast, so you don't have to guess which shade is readable on which background.
216
+
217
+ ```typescript
218
+ color: {
219
+ themes: {
220
+ brand: {
221
+ tokens: true,
222
+ translations: { 'en-US': 'Brand', 'pt-BR': 'Marca' },
223
+ light: { primary: '#FF0000', secondary: '#FF8800', background: '#FAFAFA' },
224
+ dark: { primary: '#FF6B6B', secondary: '#FFB96A', background: '#0C0C0C' },
225
+ },
226
+ },
227
+ contrast: 'AA', // 'AA' | 'AAA' | false
228
+ }
229
+ ```
230
+
231
+ ```css
232
+ .card {
233
+ background: var(--jade-bg-subtle);
234
+ color: var(--jade-text);
235
+ border: 1px solid var(--jade-border);
236
+ }
237
+
238
+ .button {
239
+ background: var(--jade-fill-primary);
240
+ color: var(--jade-on-primary);
241
+ }
242
+
243
+ .button:hover {
244
+ background: var(--jade-fill-primary-hover);
245
+ }
246
+ ```
247
+
248
+ The old variables stay: a token theme still emits `--color-primary` and `--color-secondary` (the seeds), so CSS written for the original model works on it too. A token theme should set `background`; without one the tokens are built on `#FFFFFF` (light) or `#121212` (dark).
249
+
250
+ **Names.** `--color-<property>[-<role>][-<variant>][-<state>]`: the property says what the color is for (`bg`, `text`, `fill`, `on`, `border`), the role is `primary`, `secondary`, `accent`, `error`, `info`, `success` or `warning`, the variant is `subtle`, `muted`, `strong` or `focus`, and the state is `hover` or `active`. None of them repeats a name from the original model, so both live side by side.
251
+
252
+ Neutral tokens, built from the theme's `background` (`--jade-bg` *is* the background, exactly). By default they lean very slightly toward the hue of `primary`, so the surfaces feel of one piece with the theme. A `background` that already has a color of its own (a peach `#FFF8F0`, say) is not pulled toward `primary`: its own hue is kept, and the surfaces and borders get more of it the farther they sit from the page, the way a hand-made palette does, so a card doesn't look grayer than the page behind it. A gray `background` (`#FAFAFA`, `#0C0C0C`) works as described above. Set `neutralTint: false` next to `tokens: true` for plain grays instead (contrast is the same either way):
253
+
254
+ | Token | Use |
255
+ | ----- | --- |
256
+ | `bg` | Page |
257
+ | `bg-subtle` | Card, sidebar, striped row |
258
+ | `bg-muted` | Neutral component at rest: chip, quiet button, disabled field |
259
+ | `bg-hover` / `bg-active` | Neutral item under the pointer / pressed or selected |
260
+ | `border` | Divider, decorative outline |
261
+ | `border-strong` | Outline that identifies a control, like a form field (3:1) |
262
+ | `border-focus` | Keyboard focus ring (3:1) |
263
+ | `text` | Main text |
264
+ | `text-muted` | Helper text, dates, captions |
265
+ | `text-disabled` | Disabled controls (WCAG exempts them) |
266
+
267
+ Tokens for each role (`primary`, `secondary`, `accent`, `error`, `info`, `success`, `warning`), shown for `primary`:
268
+
269
+ | Token | Use |
270
+ | ----- | --- |
271
+ | `fill-primary` | Main button, strong badge, toggle on. It is the seed, exactly |
272
+ | `fill-primary-hover` | The same under the pointer |
273
+ | `on-primary` | Text and icons on `fill-primary`: white or black, whichever contrasts more |
274
+ | `bg-primary` / `bg-primary-hover` / `bg-primary-active` | Soft tinted background: selected item, highlight box, soft badge |
275
+ | `text-primary` | Link, colored text on neutral backgrounds and on `bg-primary` |
276
+ | `text-primary-strong` | Colored text on `bg-primary-hover` and `bg-primary-active` |
277
+ | `border-primary` | Decorative outline of something on `bg-primary` |
278
+ | `border-primary-strong` | Outline that must be seen (3:1) |
279
+
280
+ **Status colors and `accent`.** They are roles like the others: `fill-error`, `on-error`, `bg-warning`, `text-success`, `border-info-strong`, `fill-accent`… (the UnoCSS classes are `jade-fill-error`, `jade-text-warning`…). `warning` shows why the tokens exist: a yellow seed stays vivid as `fill-warning` with black `on-warning`, while `text-warning` comes out a dark amber that is readable on the page.
281
+
282
+ <img src="./docs/images/readme/tokens.png" alt="The warning tokens of Venix, dark and light: the yellow fill and the dark amber text" width="800">
283
+
284
+ Set the seeds in the variant, or leave them out and they are derived from `primary`:
285
+
286
+ ```ts
287
+ color: {
288
+ themes: {
289
+ brand: {
290
+ light: { primary: '#0B6E8A', error: '#C62828', warning: '#F9A825', background: '#F4FAFC' },
291
+ dark: { primary: '#4FC3D9', background: '#08141A' }, // the rest is derived
292
+ },
293
+ },
294
+ }
295
+ ```
296
+
297
+ **The scale.** Each seed becomes 12 steps defined by their contrast ratio against the background, not by fixed lightness, so the same ratios work in light and dark mode: 1–2 area backgrounds, 3–5 component backgrounds (rest, hover, pressed), 6–8 borders, 9–10 solid fill (the seed and its hover), 11–12 text. The hover moves away from the text on it: lighter when `on-*` is black, darker when it's white, so the text never loses contrast. A seed that sits close to the background (orange on white) gets its steps squeezed to fit under it.
298
+
299
+ **Stronger or weaker surfaces.** `tokens` can also be an object that re-points individual tokens at another step (1–12) of the generated scales, instead of a fixed color. The reference is `neutral-<n>` or `<role>-<n>`, and the steps mean the same in light and dark, so one entry covers both modes and still follows the seeds. Handy when a surface reads too faint or too heavy for a theme:
300
+
301
+ ```ts
302
+ color: {
303
+ themes: {
304
+ brand: {
305
+ tokens: { 'bg-subtle': 'neutral-3', 'border-strong': 'neutral-10' }, // cards a step above the default
306
+ light: { primary: '#0B6E8A', background: '#F4FAFC' },
307
+ dark: { primary: '#4FC3D9', background: '#08141A' },
308
+ },
309
+ },
310
+ }
311
+ ```
312
+
313
+ The overridden tokens go through the same contrast check, and moving a surface moves what sits on it: `bg-subtle` at `neutral-3` warns that `border-strong` falls to 2.85:1 on it until that one moves too. `text-muted` is the exception: it is placed over the surfaces you moved (`bg-muted` at `neutral-4`), so it keeps its contrast and stays weaker than `text` without an override. Any token can be overridden except `on-<role>`, which is white or black. A token, step or role that doesn't exist is ignored, with a `[jade]` warning. A hex color isn't accepted: it would be the same in both modes.
314
+
315
+ **Contrast.** `color.contrast` sets the target: `'AA'` (default: text 4.5:1, outlines 3:1) or `'AAA'` (text 7:1). At build time each token variant is checked for these pairs, and one `[jade]` warning per variant lists every pair that falls short, with its ratio:
316
+
317
+ - `text` on `bg`, `bg-subtle`, `bg-muted`, `bg-hover`, `bg-active`; `text-muted` on `bg`, `bg-subtle`, `bg-muted`
318
+ - `border-strong` and `border-focus` on `bg` and `bg-subtle`
319
+ - per role: `on-<role>` on `fill-<role>` and `fill-<role>-hover`; `text-<role>` on `bg`, `bg-subtle`, `bg-muted` and `bg-<role>`; `text-<role>-strong` on `bg-<role>-hover` and `bg-<role>-active`; `text` on `bg-<role>` and `bg-<role>-active`; `border-<role>-strong` on `bg`
320
+
321
+ A warning usually means the seed itself can't get there, not that the scale is wrong. The Venix red (`#FF0000`) reaches 5.25:1 with black text, so at `'AAA'` the light variant warns about `on-primary`; pick a darker seed or stay on `'AA'`. `false` skips the warning but still generates the tokens, as AA. With `'AA'`, `on-*` can never fail: the better of black and white always reaches at least 4.58:1.
322
+
323
+ **Where the tokens show up.**
324
+
325
+ - **CSS:** in the variant's `[data-theme]` block, after the usual variables.
326
+ - **`useVenixTheme().tokens`:** `all` (every variant's tokens by `data-theme` id), `current` (the applied theme's, `undefined` when it has none) and `cssVar('text-primary')` β†’ `'var(--jade-text-primary)'`. See [`useVenixTheme()`](#usevenixtheme).
327
+ - **UnoCSS:** one class per token, with the `jade-` prefix: `jade-bg-subtle`, `jade-text-muted`, `jade-fill-primary`. See [UnoCSS preset](#unocss-preset).
328
+ - **Vuetify:** `on-primary`, `on-secondary`, `surface`, `on-surface` and `on-background`. See [Vuetify](#vuetify).
329
+ - **`<VenixThemeSwitcher>`:** its menu follows the tokens on token themes and keeps its fixed palette everywhere else.
330
+
331
+ **High contrast.** `color.highContrast: true` (experimental, off by default) also writes the AAA version of every token that changes, per variant, inside `@media (prefers-contrast: more)`: visitors who ask their system for more contrast get text at 7:1 with no setting on the site. With the built-in themes it adds about 7 kB of CSS (before compression) and under a second to the build. Seeds don't change (`fill-*` stays the exact seed), and a pair that can't reach 7:1 with black or white (`on-*` on a mid-tone seed) keeps the best the scale can do, with no build warning. The CSS variables follow the preference; `useVenixTheme().tokens` keeps reporting the regular values. There is nothing to add when `color.contrast` is already `'AAA'`.
332
+
333
+ The tokens are generated at build time with [Adobe Leonardo](https://github.com/adobe/leonardo) and never reach the client bundle; the client only receives the resulting hex values. The roles are `primary`, `secondary`, `accent` and the status colors `error`, `info`, `success` and `warning`: each gets the tokens below from the seed of the same name. A theme that sets only `primary` gets the rest derived from it: `secondary` is the primary's hue turned 30Β° and `accent` the opposite hue, calmer, both at the primary's lightness; `error`, `info`, `success` and `warning` use the usual red, blue, green and amber, deeper on a light page and lighter on a dark one. A seed the theme sets always wins over the derived one, and a gray `primary` (no hue to turn) derives only the status colors. Without a `primary` nothing is derived.
334
+
335
+ #### Built-in themes and `experimental`
336
+
337
+ Venix and the four seasonal themes ship with `tokens: true`, **next to** the old model: `--color-primary`, `--color-background2`… keep exactly the values they had, so nothing written for 1.x changes. Venix keeps plain gray surfaces (`neutralTint: false`); a seasonal theme keeps the hue of its own `background`.
338
+
339
+ Two things are left as they were for projects that already exist:
340
+
341
+ - **Vuetify.** The tokens of the built-in themes don't feed Vuetify's colors in 1.x: it keeps picking its own text color on `primary`, so buttons don't change. A theme you set `tokens` on yourself does feed it, with `on-primary` and `on-secondary` only: Vuetify keeps choosing the text color on its own `error`, `success`, `warning` and `info`, so `v-alert` and `v-btn color="error"` look as before.
342
+ - **The build's contrast check.** It skips the built-in themes: at `'AAA'` some of their seeds can't reach 7:1, and that isn't yours to fix.
343
+
344
+ Your own themes opt in per theme with `tokens`. To get the tokens on all of them at once, turn on the `experimental` option. It's **off by default**:
345
+
346
+ ```typescript
347
+ venixTheme: {
348
+ experimental: true, // or { enabled: true }
349
+ }
350
+ ```
351
+
352
+ Every theme that doesn't set `tokens` itself then gets them, built from its own `primary`, `secondary` and `background`, so `jade-bg-subtle`, `var(--jade-text-primary)` and `useVenixTheme().tokens` work on whichever theme is applied. A theme with `tokens: false` stays out, and one with its own `tokens` keeps them as written. The contrast check covers them, and asking for the tokens everywhere includes Vuetify's colors (see [Vuetify](#vuetify)), the built-in themes' too.
353
+
354
+ It is a build-time choice, equivalent to writing `tokens: true` on every theme: there is no switch for the visitor. Both models live side by side until 2.0.0, when the old `--color-*` variables and `background2`/`3` go and the tokens become the only model.
355
+
356
+ ### Theme transition
357
+
358
+ 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`.
359
+
360
+ ### Flat format (deprecated)
361
+
362
+ 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.
363
+
364
+ <br>
365
+
366
+ ## Typography
367
+
368
+ <p align="center">
369
+ <img alt="venixTheme: typography" src="https://img.shields.io/badge/venixTheme-typography-00A86B?style=for-the-badge">
370
+ <img alt="default: on" src="https://img.shields.io/badge/default-on-2EA44F?style=for-the-badge">
371
+ <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>
372
+ </p>
373
+
374
+ 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.
375
+
376
+ <p align="center">
377
+ <img src="./docs/images/readme/typography.png" alt="The Iceberg font at several sizes" width="800">
378
+ </p>
379
+
380
+ ```typescript
381
+ venixTheme: {
382
+ typography: {
383
+ defaultFonts: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif", // default
384
+ fontSize: '16px', // default
385
+ customFonts: [
386
+ { name: 'MyFont', sources: { woff2: '/fonts/MyFont.woff2' }, weight: 'normal', style: 'normal', preload: true },
387
+ ],
388
+ },
389
+ }
390
+ ```
391
+
392
+ `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.
393
+
394
+ 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.
395
+
396
+ 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).
397
+
398
+ <br>
399
+
400
+ ## Scrollbar
401
+
402
+ <p align="center">
403
+ <img alt="venixTheme: scrollbar" src="https://img.shields.io/badge/venixTheme-scrollbar-00A86B?style=for-the-badge">
404
+ <img alt="default: on" src="https://img.shields.io/badge/default-on-2EA44F?style=for-the-badge">
405
+ <img alt="third-party: OverlayScrollbars (optional)" src="https://img.shields.io/badge/third--party-OverlayScrollbars_(optional)-6E7781?style=for-the-badge">
406
+ </p>
407
+
408
+ A custom scrollbar whose colors follow the active theme. The values below are the defaults:
409
+
410
+ <p align="center">
411
+ <img src="./docs/images/readme/scrollbar.png" alt="Vertical and horizontal scrollbars in the theme colors" width="800">
412
+ </p>
413
+
414
+ ```typescript
415
+ venixTheme: {
416
+ scrollbar: {
417
+ // Draws the scrollbars with OverlayScrollbars, so the custom cursor shows over them (see below)
418
+ overlay: false,
419
+ width: 'auto', // 10px for the overlay scrollbar
420
+ borderRadius: '8px',
421
+ borderWidth: '3px', // native scrollbar only
422
+ // A theme color name (follows the active theme) or any CSS color; `border` is native only
423
+ colors: { thumb: 'primary', thumbHover: 'secondary', track: 'background2', border: 'background3' },
424
+ },
425
+ }
426
+ ```
427
+
428
+ 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.
429
+
430
+ 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.
431
+
432
+ ### Overlay scrollbar (optional)
433
+
434
+ 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.
435
+
436
+ 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.
437
+
438
+ ```bash
439
+ pnpm add overlayscrollbars
440
+ ```
441
+
442
+ ```typescript
443
+ venixTheme: {
444
+ scrollbar: { overlay: true },
445
+ }
446
+ ```
447
+
448
+ It covers:
449
+
450
+ - the page itself (`window.scrollTo` and the like keep working);
451
+ - Vuetify's scroll containers: navigation drawers, scrollable dialogs, `v-select` menus and tables, including the page and containers behind an open dialog staying locked;
452
+ - any element of yours that scrolls, marked with `data-venix-scroll`:
453
+
454
+ ```html
455
+ <div data-venix-scroll style="height: 300px; overflow: auto">…</div>
456
+ ```
457
+
458
+ 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.
459
+
460
+ <br>
461
+
462
+ ## Cursor
463
+
464
+ <p align="center">
465
+ <img alt="venixTheme: cursor" src="https://img.shields.io/badge/venixTheme-cursor-00A86B?style=for-the-badge">
466
+ <img alt="default: on" src="https://img.shields.io/badge/default-on-2EA44F?style=for-the-badge">
467
+ <img alt="third-party: none" src="https://img.shields.io/badge/third--party-none-6E7781?style=for-the-badge">
468
+ </p>
469
+
470
+ 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>`:
471
+
472
+ <p align="center">
473
+ <img src="./docs/images/readme/cursor.png" alt="The default, pointer and text cursors" width="800">
474
+ </p>
475
+
476
+ - **`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`.
477
+ - **`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.
478
+ - **`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.
479
+
480
+ <p align="center">
481
+ <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">
482
+ </p>
483
+
484
+ | `themeCursors` value | Cursor shown |
485
+ | --- | --- |
486
+ | `'base'` | the `defaultCursors` (the module's fire cursors, unless you set your own) |
487
+ | `'themed'` | drawn in the theme's `primary` |
488
+ | `'none'` | no custom cursor: the operating system's own |
489
+ | `{ pointer: { path, hotspot } }` | its own images; the cursors left out show as if the theme had no entry |
490
+
491
+ ```typescript
492
+ venixTheme: {
493
+ cursor: {
494
+ // `false` shows the default cursors in every theme without an entry in `themeCursors`
495
+ themed: true,
496
+ // Images served from `public/`; `hotspot` is the click point ("x y")
497
+ defaultCursors: {
498
+ default: { path: '/cursors/default.png', hotspot: '0 0' },
499
+ pointer: { path: '/cursors/pointer.png', hotspot: '0 0' },
500
+ text: { path: '/cursors/text.png', hotspot: '0 0' },
501
+ },
502
+ themeCursors: {
503
+ // Its own pointer; default and text are still drawn in its color
504
+ 'halloween': { pointer: { path: '/cursors/pumpkin.png', hotspot: '8 0' } },
505
+ 'natal': 'none',
506
+ // Drawn in its color, instead of the default cursors
507
+ 'venix': 'themed',
508
+ // Only the light variant of Carnival
509
+ 'carnaval-light': 'base',
510
+ },
511
+ },
512
+ }
513
+ ```
514
+
515
+ ### Cursors in your own CSS
516
+
517
+ The custom cursor is set on `<html>` and reaches the rest of the page by inheritance. Any element with a `cursor` of its own shows that one instead, so a fixed `cursor: pointer` in your CSS shows the **system's** hand. Use the module's variables:
518
+
519
+ ```css
520
+ .my-clickable { cursor: var(--cursor-pointer); }
521
+ .my-readonly { cursor: var(--cursor-default); }
522
+ .my-editor { cursor: var(--cursor-text); }
523
+ ```
524
+
525
+ They follow the color theme and switch to the system's cursors when the visitor turns the custom cursor off. The utility classes `cursor-default`, `cursor-pointer` and `cursor-text` (Vuetify's, and UnoCSS's with the [UnoCSS preset](#unocss-preset)) use them too.
526
+
527
+ The module already gives the variables to what browsers and Vuetify 4 style with a fixed cursor: links, buttons, form fields, and Vuetify's clickable components (table rows with `@click:row`, sortable headers, `v-card` with `hover`, chip close buttons, `v-select`, switches, sliders, menu activators and so on). Its CSS is outside any `@layer`, so it wins over Vuetify's, which is layered, without `!important`. Your own rules (outside a layer, too) still win over it when they are more specific. For a table with `@click:row` where only some rows do something:
528
+
529
+ ```css
530
+ .orders .v-data-table__tr--clickable.no-action { cursor: var(--cursor-default); }
531
+ ```
532
+
533
+ Or the class `cursor-default` on those rows (`:row-props="row => ({ class: row.item.locked && 'cursor-default' })"`). Links, buttons, `[role="button"]`, text fields and disabled elements keep `!important`, so the pointer shows over everything inside a link or button and the arrow over a disabled one; for these, change the cursor with `!important` too (`!cursor-default` in UnoCSS).
534
+
535
+ > [!NOTE]
536
+ > `defaultCursors` was called `cursors` up to 1.2. The old name still works, with a warning, until 2.0.
537
+
538
+ > [!NOTE]
539
+ > 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.
540
+ >
541
+ > 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.
542
+
543
+ <br>
544
+
545
+ ## Theme switcher
546
+
547
+ <p align="center">
548
+ <img alt="component: &lt;VenixThemeSwitcher&gt;" src="https://img.shields.io/badge/component-%3CVenixThemeSwitcher%3E-00A86B?style=for-the-badge">
549
+ <img alt="UI kit: none needed" src="https://img.shields.io/badge/UI_kit-none_needed-2EA44F?style=for-the-badge">
550
+ </p>
551
+
552
+ `<VenixThemeSwitcher>` (see [Quick Setup](#2-add-the-theme-switcher)) takes these props:
553
+
554
+ | Prop | Type | Default | Description |
555
+ | ----------- | --------- | ----------------------- | --------------------------------------------------- |
556
+ | `label` | `string` | translated, per locale | Accessible label for the button and the menu |
557
+ | `showLabel` | `boolean` | `false` | Show the theme and mode names next to the icon |
558
+ | `hideConsent` | `boolean` | `false` | Leave "Save changes" and the save reminder out, when your own cookie banner already asks |
559
+
560
+ And emits one event:
561
+
562
+ | Event | When |
563
+ | ---------------- | ------------------------------------------------------------------------------------------ |
564
+ | `consent-needed` | The visitor's first change on this visit that won't be remembered (no consent yet, with `color.requireConsent`) |
565
+
566
+ With your own cookie banner, use it to bring the banner up at the moment it matters:
567
+
568
+ ```vue
569
+ <VenixThemeSwitcher hide-consent @consent-needed="openCookieBanner()" />
570
+ ```
571
+
572
+ The gear next to the title opens the **settings**, a few switches for the visitor:
573
+
574
+ <p align="center">
575
+ <picture>
576
+ <source media="(prefers-color-scheme: light)" srcset="./docs/images/readme/switcher-settings-light.png">
577
+ <img src="./docs/images/readme/switcher-settings-dark.png" alt="VenixThemeSwitcher settings: Save changes, Custom scrollbar, Custom cursor and Custom font switches" width="800">
578
+ </picture>
579
+ </p>
580
+
581
+ - **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`.
582
+ - **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).
583
+
584
+ 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.
585
+
586
+ Since "Save changes" is easy to miss, a change that won't be remembered (a theme, a mode or one of the switches, without consent yet) opens a small reminder at the bottom of the menu: **Remember your choices? Β· Uses cookies**, with **Save** and **Γ—** (not now). **Save** grants consent right there (`persistence.grant()`) and briefly confirms; **Γ—** hides the reminder for the rest of the visit. Nothing is stored for "not now" (that would itself need consent), so it can come back on the next visit after another change. It never shows with `hideConsent`, once consent is recorded, or after the visitor revoked it on this visit.
587
+
588
+ - **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.
589
+ - **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.
590
+ - **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.
591
+ - **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.
592
+ - **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.
593
+ - **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.
594
+
595
+ 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), `.venix-theme-switcher__prompt` (the save reminder) and `.venix-theme-switcher__switch` (see [`VenixThemeSwitcher.vue`](./src/runtime/components/VenixThemeSwitcher.vue)).
596
+
597
+ <br>
598
+
599
+ ## `useVenixTheme()`
600
+
601
+ <p align="center">
602
+ <img alt="composable: useVenixTheme()" src="https://img.shields.io/badge/composable-useVenixTheme()-00A86B?style=for-the-badge">
603
+ <img alt="auto-imported: yes" src="https://img.shields.io/badge/auto--imported-yes-2EA44F?style=for-the-badge">
604
+ </p>
605
+
606
+ 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.
607
+
608
+ 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.
609
+
610
+ ```vue
611
+ <template>
612
+ <button @click="mode.set('dark')">Dark</button>
613
+ <button @click="mode.set('light')">Light</button>
614
+ <button @click="theme.set('natal')">Christmas</button>
615
+ </template>
616
+
617
+ <script setup lang="ts">
618
+ const { theme, mode } = useVenixTheme()
619
+ </script>
620
+ ```
621
+
622
+ It returns:
623
+
624
+ - `theme` β€” the theme choice:
625
+ - `preference`: the chosen theme (`'system'`, `'venix'`, `'carnaval'`…)
626
+ - `value`: the variant actually applied, as in `data-theme` (e.g. `'natal-light'`, or `'dark'` for Venix in dark mode)
627
+ - `data`: the chosen theme's `{ value, name, icon }`
628
+ - `set(name)`: picks a theme, keeping the mode
629
+ - `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
630
+ - `isSeasonalActive`, `activeSeasonalTheme`: whether a [seasonal theme](#seasonal-themes) is currently in effect, and which one
631
+ - `shouldApplyColors`, `colors`: whether the module applies colors, and the resolved color config
632
+ - `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`.
633
+ - `mode` β€” the mode choice: `preference` (`'system'`, `'light'`, `'dark'`), `value` (the mode applied, `'light'` or `'dark'`), `data`, `set(mode)` and `toggle()`.
634
+ - `modes` β€” the three mode options with names and icons, ready to render.
635
+ - `tokens` β€” the [semantic tokens](#semantic-tokens-experimental) (experimental) of the themes with `tokens: true` (the built-in ones included): `all` (every variant's tokens by `data-theme` id), `current` (a computed with the applied theme's tokens, `undefined` when it has none) and `cssVar('text-primary')`, which returns `'var(--jade-text-primary)'`.
636
+ - `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)`.
637
+ - `locale` β€” `current`, `set()` and `translate()` (see [Translation](#translation)).
638
+ - `persistence` β€” cookie consent controls (see [Saving preferences](#saving-preferences-cookie-consent)).
639
+
640
+ **Typed names.** The module writes your project's theme names and variant ids to `.nuxt/types/venix-theme.d.ts`, so `theme.set('')` and `theme.toggle('')` autocomplete the themes you really have (the built-in ones and your own), and `tokens.cssVar('')` the token names (`'fill-warning'`, `'text-error-strong'`…). The types stay open to any string, so a name built at runtime compiles; in development, `theme.set()` and `theme.toggle()` log a `[jade]` warning when a name matches no theme, instead of silently doing nothing. `ThemeName`, `ThemeOrVariantName` and `TokenName` are exported from `@venix-sistemas/jade` if you need the types.
641
+
642
+ 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.
643
+
644
+ <br>
645
+
646
+ ## Saving preferences (cookie consent)
647
+
648
+ <p align="center">
649
+ <img alt="venixTheme: color.requireConsent" src="https://img.shields.io/badge/venixTheme-color.requireConsent-00A86B?style=for-the-badge">
650
+ <img alt="default: waits for consent" src="https://img.shields.io/badge/default-waits_for_consent-2EA44F?style=for-the-badge">
651
+ </p>
652
+
653
+ These cookies remember the visitor's choices between visits, for a year:
654
+
655
+ | Cookie | Stores |
656
+ | ------------------------ | ------------------------------------------------------------------------------------------------------- |
657
+ | `venix-theme-preference` | The chosen theme (`'system'`, `'venix'`, a custom theme…) |
658
+ | `venix-theme-mode` | The chosen mode (`'system'`, `'light'`, `'dark'`) |
659
+ | `venix-theme-resolved` | The variant last applied (e.g. `'natal-light'`) β€” lets SSR guess light or dark when the mode is `'system'` |
660
+ | `venix-scrollbar`, `venix-cursor`, `venix-font` | `'off'` when the visitor turned the custom scrollbar, cursor or font off, `'on'` otherwise |
661
+
662
+ 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.
663
+
664
+ Open pages follow these cookies live: a choice saved in another tab, or by another site on the same host using this module (cookies are shared by host, not by port β€” e.g. two apps on `localhost`, or subdomains sharing a cookie domain), is applied without a reload. Browsers with the [Cookie Store API](https://developer.mozilla.org/docs/Web/API/Cookie_Store_API) apply it right away; the others when the page is focused again. A page only follows them while it can save its own choices (see consent below).
665
+
666
+ 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.
667
+
668
+ 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.
669
+
670
+ 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:
671
+
672
+ ```vue
673
+ <script setup lang="ts">
674
+ const { persistence } = useVenixTheme()
675
+ </script>
676
+
677
+ <template>
678
+ <p>Cookies: {{ persistence.hasConsent.value ? 'allowed' : 'not allowed' }}</p>
679
+ <button @click="persistence.grant()">Allow cookies</button>
680
+ <button @click="persistence.revoke()">Revoke cookies</button>
681
+ </template>
682
+ ```
683
+
684
+ - `persistence.required` β€” `color.requireConsent`: whether anything waits for consent at all.
685
+ - `persistence.hasConsent` β€” reactive `Ref<boolean>`, shared app-wide.
686
+ - `persistence.grant()` β€” records consent and saves the current theme to the cookies right away.
687
+ - `persistence.revoke()` β€” records the refusal and deletes the theme cookies right away.
688
+ - `persistence.enable()` / `persistence.disable()` β€” lower-level: write or delete the cookies directly (`enable()` still does nothing without consent).
689
+
690
+ 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:
691
+
692
+ ```ts
693
+ localStorage.setItem('venix-cookie-consent', JSON.stringify({ functionality: true }))
694
+ window.dispatchEvent(new Event('venix-cookie-preferences-updated'))
695
+ ```
696
+
697
+ For apps without a consent banner β€” e.g. an internal tool β€” turn the requirement off, and the theme is always saved:
698
+
699
+ ```typescript
700
+ venixTheme: {
701
+ color: {
702
+ requireConsent: false,
703
+ },
704
+ }
705
+ ```
706
+
707
+ 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.
708
+
709
+ <br>
710
+
711
+ ## Translation
712
+
713
+ <p align="center">
714
+ <img alt="venixTheme: translation" src="https://img.shields.io/badge/venixTheme-translation-00A86B?style=for-the-badge">
715
+ <img alt="default: on" src="https://img.shields.io/badge/default-on-2EA44F?style=for-the-badge">
716
+ <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>
717
+ </p>
718
+
719
+ Detects the user's locale to translate the theme names (each theme's `translations`), `<VenixThemeSwitcher>`'s own strings and, optionally, your own strings.
720
+
721
+ | Option | Type | Default | Description |
722
+ | ---------------- | --------- | ------------------- | -------------------------------------------------------- |
723
+ | `locale` | `string` | β€” | Force a locale, skipping detection |
724
+ | `defaultLocale` | `string` | `'en-US'` | Fallback when no locale can be detected |
725
+ | `cookieSync` | `string` | `'i18n_redirected'` | Cookie the locale is read from (and written by `locale.set()`) |
726
+ | `manageHtmlLang` | `boolean` | `false` | Keep `<html lang>` in sync β€” see [below](#integrating-with-a-routing-based-i18n-module-eg-nuxtjsi18n) |
727
+
728
+ The locale is detected in this order:
729
+
730
+ 1. `translation.locale`, if set (skips every other step)
731
+ 2. The locale cookie (`translation.cookieSync`)
732
+ 3. The URL's locale prefix (e.g. `/en/...`), if a theme has a translation for it
733
+ 4. The `Accept-Language` header (SSR) or `navigator.language` (client)
734
+ 5. `translation.defaultLocale`
735
+
736
+ 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`.
737
+
738
+ ### Using your own translations
739
+
740
+ `locale.translate()` applies the same matching and fallbacks to your own strings:
741
+
742
+ ```ts
743
+ const { locale } = useVenixTheme()
744
+
745
+ locale.translate({ 'en-US': 'Hello', 'pt-BR': 'OlΓ‘' }, 'Hello') // second argument: fallback
746
+ ```
747
+
748
+ ### Integrating with a routing-based i18n module (e.g. `@nuxtjs/i18n`)
749
+
750
+ `translation.cookieSync` defaults to `'i18n_redirected'`, the same cookie `@nuxtjs/i18n` uses, so theme names follow your app's locale with no extra setup. If you renamed the cookie on either side, point `cookieSync` at the same name.
751
+
752
+ `<html lang>` isn't touched by default. If your app has **no** routing i18n module, turn on `manageHtmlLang` so `lang` reflects the resolved locale (WCAG 3.1.1 β€” screen readers pronounce the theme names correctly):
753
+
754
+ ```ts
755
+ venixTheme: {
756
+ translation: {
757
+ manageHtmlLang: true,
758
+ },
759
+ }
760
+ ```
761
+
762
+ 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.
763
+
764
+ <br>
765
+
766
+ ## Icons
767
+
768
+ <p align="center">
769
+ <img alt="venixTheme: icon" src="https://img.shields.io/badge/venixTheme-icon-00A86B?style=for-the-badge">
770
+ <img alt="default: on" src="https://img.shields.io/badge/default-on-2EA44F?style=for-the-badge">
771
+ <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>
772
+ <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>
773
+ </p>
774
+
775
+ <p align="center">
776
+ <img src="./docs/images/readme/icons.png" alt="VenixIcon rendering an animated Iconify icon, an emoji, inline SVG and aliases" width="528">
777
+ </p>
778
+
779
+ Installs and configures [`@nuxt/icon`](https://github.com/nuxt/icon), so every [Iconify](https://icon-sets.iconify.design/) icon is available in your app.
780
+
781
+ **For regular icons, use `@nuxt/icon`'s own `<Icon>`** β€” Jade doesn't replace it, and the Iconify aliases from `icon.aliases` work there too:
782
+
783
+ ```vue
784
+ <template>
785
+ <Icon name="mdi:home" />
786
+ <Icon name="line-md:home" mode="svg" /> <!-- `mode="svg"` is needed for line-md's animations -->
787
+ </template>
788
+ ```
789
+
790
+ **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):
791
+
792
+ ```vue
793
+ <template>
794
+ <VenixIcon icon="line-md:home" />
795
+ <VenixIcon icon="<svg viewBox=&quot;0 0 24 24&quot;>...</svg>" />
796
+ <VenixIcon icon="🎨" />
797
+ </template>
798
+ ```
799
+
800
+ - **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.
801
+ - **Inline SVG** β€” a string starting with `<svg`, rendered with `v-html`. It isn't sanitized, so only pass SVGs you control, never user input.
802
+ - **Emoji or text** β€” anything else.
803
+
804
+ | Option | Type | Default | Description |
805
+ | ------------- | ------------------------ | ------------- | -------------------------------------------------- |
806
+ | `collections` | `string[]` | `['line-md']` | Iconify collections bundled whole β€” see [below](#offline-icon-collections) |
807
+ | `aliases` | `Record<string, string>` | `{}` | Short names for any icon value β€” see [below](#aliases) |
808
+
809
+ 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.
810
+
811
+ ### Aliases
812
+
813
+ `icon.aliases` gives short names to any of the three formats:
814
+
815
+ ```typescript
816
+ venixTheme: {
817
+ icon: {
818
+ aliases: {
819
+ home: 'line-md:home',
820
+ favorite: 'line-md:heart-filled',
821
+ brand: '🎨',
822
+ },
823
+ },
824
+ }
825
+ ```
826
+
827
+ ```vue
828
+ <VenixIcon icon="home" />
829
+ ```
830
+
831
+ ### Offline icon collections
832
+
833
+ Icons are bundled at build time, so they work offline instead of being fetched from the Iconify API:
834
+
835
+ - **`line-md`** is bundled whole by default.
836
+ - **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`.
837
+ - **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:
838
+
839
+ ```typescript
840
+ venixTheme: {
841
+ icon: {
842
+ collections: ['line-md', 'tabler'],
843
+ },
844
+ }
845
+ ```
846
+
847
+ If a referenced collection can't be found, `@nuxt/icon` fetches it from the Iconify API at runtime, which needs internet.
848
+
849
+ ### Theme icons
850
+
851
+ 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:
852
+
853
+ ```json
854
+ "natal": {
855
+ "icon": {
856
+ "emote": "πŸŽ„",
857
+ "css": "mdi:pine-tree-variant",
858
+ "svg": "line-md:star-filled"
859
+ }
860
+ }
861
+ ```
862
+
863
+ - `emote` β€” an emoji. Required, it's the fallback.
864
+ - `css` β€” an Iconify name rendered in CSS mode: lighter, but never animated.
865
+ - `svg` β€” an Iconify name rendered as a real `<svg>`, needed for animated icons like `line-md`'s.
866
+
867
+ `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>`:
868
+
869
+ ```vue
870
+ <VenixIcon
871
+ v-if="item.icon"
872
+ :icon="item.icon.value"
873
+ :mode="item.icon.format === 'emote' ? undefined : item.icon.format"
874
+ />
875
+ ```
876
+
877
+ <br>
878
+
879
+ ## Integrations
880
+
881
+ ### UnoCSS preset
882
+
883
+ <p align="center">
884
+ <img alt="import: @venix-sistemas/jade/unocss" src="https://img.shields.io/badge/import-%40venix--sistemas%2Fjade%2Funocss-00A86B?style=for-the-badge">
885
+ <a href="https://unocss.dev"><img alt="requires: UnoCSS" src="https://img.shields.io/badge/requires-UnoCSS-1F6FEB?style=for-the-badge"></a>
886
+ </p>
887
+
888
+ Add the preset to your `uno.config.ts` to use the theme colors as utilities (`text-primary`, `bg-background2`, `border-accent`, …):
889
+
890
+ ```typescript
891
+ // uno.config.ts
892
+ import { defineConfig } from 'unocss'
893
+ import { venixUnoPreset } from '@venix-sistemas/jade/unocss'
894
+
895
+ export default defineConfig({
896
+ presets: [
897
+ venixUnoPreset(),
898
+ // ...your other presets
899
+ ],
900
+ })
901
+ ```
902
+
903
+ It maps every [theme color](#themes), plus `inverse`, to its CSS variable (`primary: 'var(--color-primary)'`, …), so utilities follow the active theme. Colors you define yourself in `uno.config.ts` take precedence.
904
+
905
+ The [semantic tokens](#semantic-tokens-experimental) (experimental) are classes named after their CSS variable, with the `jade-` prefix: `--jade-bg-subtle` β†’ `jade-bg-subtle`, `jade-text-muted`, `jade-border-strong`, `jade-fill-primary`, `jade-on-primary`, `hover:jade-bg-hover`. Each sets the property the token is for (`bg-*` and `fill-*` the background, `text-*` and `on-*` the text color, `border-*` the border color). The prefix keeps them apart from other color systems' classes (Vuetify's `text-primary`, or the `text-muted` and `bg-muted` of Bootstrap and shadcn), and from the plain `bg-primary` / `text-primary` above. They are rules, not theme colors, so there is no `/50` opacity (it doesn't apply to a `var()` anyway) and no ring, divider or gradient version. They only have a value on themes with `tokens: true`. Pass `venixUnoPreset({ tokens: false })` to leave them out.
906
+
907
+ It also makes `cursor-default`, `cursor-pointer` and `cursor-text` use the [custom cursor](#cursors-in-your-own-css) (`cursor: var(--cursor-pointer, pointer)`, the system's when the module's cursor is off), with variants and `!` included (`hover:cursor-pointer`, `!cursor-default`). These replace `presetWind`'s rules of the same name wherever the preset sits in `presets`.
908
+
909
+ 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.
910
+
911
+ ### Vuetify
912
+
913
+ <p align="center">
914
+ <img alt="venixTheme: vuetify" src="https://img.shields.io/badge/venixTheme-vuetify-00A86B?style=for-the-badge">
915
+ <img alt="default: off" src="https://img.shields.io/badge/default-off-6E7781?style=for-the-badge">
916
+ <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>
917
+ </p>
918
+
919
+ 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:
920
+
921
+ ```typescript
922
+ export default defineNuxtConfig({
923
+ modules: [
924
+ '@venix-sistemas/jade', // must come before the Vuetify module
925
+ 'vuetify-nuxt-module',
926
+ ],
927
+ venixTheme: {
928
+ vuetify: true,
929
+ },
930
+ })
931
+ ```
932
+
933
+ - **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.
934
+ - **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, …).
935
+ - **Semantic tokens** (experimental): a theme you set `tokens: true` on (or every theme, with `experimental`) also gives Vuetify `on-primary` and `on-secondary` (it would otherwise pick its own, which prefers white on the Venix red, 4.0:1), `surface` from `bg-subtle` (unless the theme sets `background2`), and `on-surface` and `on-background` from `text`. The built-in themes carry tokens of their own, but in 1.x those stay out of Vuetify, so its colors don't change under existing projects. See [Semantic tokens](#semantic-tokens-experimental).
936
+ - **Your values win:** anything you set in `vuetify.vuetifyOptions.theme.themes` is merged per color on top of the generated themes.
937
+ - **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.
938
+ - **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.
939
+
940
+ **Known limit.** With SSR, the server doesn't know the visitor's system color scheme. When the theme is automatic (`defaultColor: 'system'`, or a theme name, whose mode follows the system) and the visitor has no saved cookie (always the case before consent, with `requireConsent` on), the server renders Vuetify with the dark theme. The page's own colors are corrected before the first paint, but Vuetify's components keep the dark colors until the page hydrates, so a visitor with a light system can see a short flash. With the default `defaultColor: 'dark'`, or once a visitor has saved a choice, the server already has the right theme and there is nothing to see.
941
+
942
+ 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.
943
+
944
+ ### Content-Security-Policy
945
+
946
+ <p align="center">
947
+ <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>
948
+ </p>
949
+
950
+ 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`).
951
+
952
+ <br>
953
+
954
+ ## Third-party packages
955
+
956
+ Colors, typography, scrollbar, cursor, translation and the switcher are Jade's own code, with no package behind them (the overlay scrollbar and the build-time color engine of the semantic tokens aside). These come from third parties:
957
+
958
+ | Package | Used for | How it's included | License |
959
+ | ------- | -------- | ----------------- | ------- |
960
+ | [`@adobe/leonardo-contrast-colors`](https://github.com/adobe/leonardo) | Generates the 12-step color scales behind the [semantic tokens](#semantic-tokens-experimental), at build time only: it never reaches the browser bundle | Installed with Jade | Apache 2.0 |
961
+ | [`@nuxt/icon`](https://github.com/nuxt/icon) | Renders Iconify icons for `<Icon>` and `<VenixIcon>` ([Icons](#icons)) | Installed with Jade; skipped with `icon: false` | MIT |
962
+ | [`@iconify/utils`](https://github.com/iconify/iconify) | Picks the icons to bundle offline ([Offline icon collections](#offline-icon-collections)) | Installed with Jade | MIT |
963
+ | [`@iconify-json/line-md`](https://github.com/cyberalien/line-md) | Animated Material Line Icons, by Vjacheslav Trushkin | Installed with Jade, bundled by default | MIT |
964
+ | [`@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 |
965
+ | [Iceberg](https://fonts.google.com/specimen/Iceberg) | The module's default custom font ([Typography](#typography)) | Shipped in the package | SIL OFL 1.1 |
966
+ | [OverlayScrollbars](https://github.com/KingSora/OverlayScrollbars) | Scrollbars the custom cursor shows over ([Overlay scrollbar](#overlay-scrollbar-optional)) | Optional, installed by you | MIT |
967
+ | [UnoCSS](https://unocss.dev) | Theme colors as utilities ([UnoCSS preset](#unocss-preset)) | Optional, installed by you | MIT |
968
+ | [Vuetify](https://vuetifyjs.com) + [`vuetify-nuxt-module`](https://nuxt.vuetifyjs.com) | Theme sync with Vuetify ([Vuetify](#vuetify)) | Optional, installed by you | MIT |
969
+ | [`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 |
970
+ | [`@nuxtjs/i18n`](https://i18n.nuxtjs.org) | Shares its locale cookie with [Translation](#translation) | Optional, installed by you | MIT |
971
+
972
+ <br>
973
+
974
+ ## Development
975
+
976
+ | Command | Description |
977
+ | -------------- | -------------------- |
978
+ | `pnpm install` | Install dependencies |
979
+ | `pnpm dev` | Start the [playground](./playground) |
980
+ | `pnpm test` | Run the tests |
981
+ | `pnpm lint` | Run the linter |
982
+ | `pnpm prepack` | Build the package |
983
+
984
+ ## Brand
985
+
986
+ The Jade logo, in the variants shipped with the repository (`docs/images`):
987
+
988
+ | Transparent | Dark background | Emblem |
989
+ | :---------: | :-------------: | :--------------: |
990
+ | <img src="./docs/images/jade-transparent.png" alt="Jade, transparent background" width="200"> | <img src="./docs/images/jade.png" alt="Jade, dark background" width="200"> | <img src="./docs/images/jade-emblem.png" alt="Jade emblem" width="200"> |
991
+
992
+ ## License
993
+
994
+ [MIT](./LICENSE)