Theme V0 Adapter (Vuetify0ThemeAdapter)
TheVuetify0ThemeAdapter is the default theme adapter for Vuetify Zero, generating and injecting CSS custom properties for dynamic theme switching.
Import
Basic Usage
The
Vuetify0ThemeAdapter is the default adapter when no adapter is specified:Using in Components
CSS Custom Properties
The adapter generates CSS custom properties with a prefix:Configuration Options
Custom Prefix
CSP Nonce
For Content Security Policy compliance:Custom Stylesheet ID
Theme Structure
Basic Theme
Nested Colors
Dynamic Theme Switching
Data Attribute
The adapter sets adata-theme attribute on the target element:
Target Element
By default, the theme is applied to the app container or#app:
Custom Target
SSR Support
The adapter supports server-side rendering with head integration:Adopted Stylesheets
In browser, the adapter uses Constructable Stylesheets:<style> tags.
TypeScript
Custom Theme Adapter
Create custom adapters by extendingThemeAdapter:
API Reference
Constructor
Options
| Option | Type | Default | Description |
|---|---|---|---|
prefix | string | 'v0' | CSS variable prefix |
cspNonce | string | undefined | CSP nonce for stylesheet |
stylesheetId | string | Auto-generated | Stylesheet element ID |
Methods
| Method | Description |
|---|---|
setup(app, context, target) | Initialize theme system |
update(colors, isDark) | Update theme colors |
upsert(styles) | Inject/update stylesheet |
generate(colors, isDark) | Generate CSS string |
Setup Context
Generated CSS
The adapter generates flat CSS custom properties:Performance
The adapter is optimized for performance:
- Constructable Stylesheets - Uses browser-native API for fast updates
- No DOM manipulation - Direct stylesheet replacement, no element creation
- Minimal re-renders - Only updates when colors change
- SSR-optimized - Injects styles synchronously to prevent FOUC
Browser Support
| Feature | Chrome | Firefox | Safari | Edge |
|---|---|---|---|---|
| CSS Custom Properties | ✓ | ✓ | ✓ | ✓ |
| Constructable Stylesheets | ✓ 73+ | ✓ 101+ | ✓ 16.4+ | ✓ 79+ |
See Also
- useTheme - Theme composable
- createTokens - Token system for color aliases
- CSS Custom Properties - MDN documentation
- Constructable Stylesheets - MDN documentation