useTheme

View source
Read and write theme state (color, radius, font, icon set, dark mode) and export CSS variables or configuration code.

Introduction

useTheme exposes the reactive theme state and export methods. It is the underlying logic for the ThemePicker component and can be used to build custom theme panels or read/write theme values in business logic.

Return Values

const {
  // Color
  color, primary, primaryColors, neutral, neutralColors,
  blackAsPrimary, setBlackAsPrimary,
  // Radius / Font / Icon / Mode
  radius, radiuses, font, fonts, icon, icons, mode, modes,
  // Injection and state
  style, link, hasCSSChanges, hasConfigChanges,
  // Export
  exportCSS, exportConfig, resetTheme
} = useTheme()
GroupMembersDescription
Colorcolor / primary / primaryColorsPrimary color and available options
Colorneutral / neutralColorsNeutral color and available options
ColorblackAsPrimary / setBlackAsPrimaryToggle for using black as the primary color
Radiusradius / radiusesCurrent border radius and available presets
Fontfont / fontsCurrent font and available options
Iconicon / iconsCurrent icon set and available options
Modemode / modesDark mode (light/dark/system) and available options
Injectionstyle / linkCSS variables and font link to inject into the page
StatehasCSSChanges / hasConfigChangesWhether there are changes relative to the defaults
For a ready-to-use visual theme panel, see the ThemePicker component.
Copyright © 2025 - 2026 YiXuan - MIT License