Overview
TheuseTheme() composable provides access to Vuetify’s theme system, allowing you to read current theme values, switch between themes, and manage theme state reactively.
Import
Signature
Return Value
Returns aThemeInstance object with the following properties and methods:
The name of the currently active theme (e.g., ‘light’, ‘dark’, or custom theme name)
The complete current theme definition including colors and variables
All available theme definitions
Computed themes with variations and generated on-colors
Whether the theme system is disabled
Whether the theme is set to follow system preferences
CSS variable prefix (default: ‘v-’)
CSS classes to apply based on current theme
Generated CSS styles for the theme
Global theme reference with
name and current propertiesMethods
Switch to a different theme by nameParameters:
themeName- Name of the theme to activate (e.g., ‘light’, ‘dark’, ‘system’)
Cycle through an array of themesParameters:
themeArray- Optional array of theme names to cycle through (defaults to all themes)
Toggle between two themesParameters:
themeArray- Optional tuple of two theme names (defaults to [‘light’, ‘dark’])
Theme Definition
Usage Examples
Basic Usage
Switch Themes
Access Theme Colors
Cycle Through Custom Themes
Check System Theme Preference
Notes
- Must be called within a component setup function or composable
- Throws an error if the Vuetify theme provider is not found
- Theme changes are reactive and will update all dependent components
- The
systemtheme name will automatically follow OS preferences