useTheme API
API reference for the useTheme composable.
Related
Explore these related pages for additional context and usage patterns.
| Page | Category |
|---|---|
| useTheme | Plugins |
| Theme | Providers |
| useMediaQuery | System |
| createTokens | Registration |
| Theming | Features |
Functions
createTheme
(_options?: ThemeOptions<ThemeRecord>) => ThemeContext<ThemeTicketInput, ThemeTicket<ThemeTicketInput>>Creates a new theme instance.
createThemeContext
<_E>(_options?: ThemePluginOptions | undefined) => ContextTrinity<_E>createThemePlugin
(_options?: ThemePluginOptions | undefined) => PluginuseTheme
<_E>(namespace?: string) => _EOptions
foreground
boolean | undefinedAutomatically generate `on-*` foreground colors for each theme color using APCA contrast analysis.
rgb
boolean | undefinedOutput CSS variable values as decomposed RGB channels (`R, G, B`) instead of hex strings.
target
string | HTMLElement | null | undefinedThe target element or selector to apply theme classes to.
Properties
selectedValues
ComputedRef<Set<E["value"] extends Ref<infer U, infer U> ? U : E["value"]>>Computed Set of selected ticket values
selectedId
ComputedRef<ID | undefined>selectedIndex
ComputedRef<number>selectedItem
ComputedRef<E | undefined>selectedValue
ComputedRef<E["value"] | undefined>colors
ComputedRef<Record<string, Colors>>A computed reference to the resolved colors of all registered themes.
Methods
seek
(direction?: "first" | "last", from?: number, predicate?: (ticket) => boolean) => E | undefinedSeek for a ticket based on direction and optional predicate
on
<K extends Extensible<RegistryEventName>>(event: K, cb: RegistryEventCallback<E, K>) => voidListen for registry events
off
<K extends Extensible<RegistryEventName>>(event: K, cb: RegistryEventCallback<E, K>) => voidStop listening for registry events
emit
<K extends Extensible<RegistryEventName>>(event: K, data: EventPayload<E, K>) => voidEmit an event with data
offboard
(ids: ID[]) => Partial<Z>[]Offboard multiple tickets at once, returning the input shapes that were removed.
batch
<R>(fn: () => R) => RExecute operations in a batch, deferring cache invalidation and event emission until complete
register
(registration?: Partial<Z>) => ERegister a theme with optional colors. When `colors` is provided, onboards them as flat tokens for alias resolution and stores them as the ticket value.