useTheme()
You're reading Identity & Access Management 7.0.0. The newest release is 7.3.0, and Cloud has the newest features. Go to the newest release
useTheme() returns the theme that the WSO2 Identity Server Nuxt SDK (@asgardeo/nuxt) applies to its components, and a method that toggles the color scheme.
Overview
<AsgardeoRoot> builds the theme from two module options:
preferences.theme.modesets the color scheme. It defaults to'light'.preferences.theme.inheritFromBrandingapplies the branding preference of your organization to the theme. It defaults totrue.
See Module configuration. The module auto-imports useTheme().
note
Call useTheme() only in components that render inside <AsgardeoRoot>. Otherwise, it throws an error.
Usage
<script setup lang="ts">
const { colorScheme, toggleTheme } = useTheme();
</script>
<template>
<button @click="toggleTheme">
Switch to {{ colorScheme === 'light' ? 'dark' : 'light' }} mode
</button>
</template>
API
| Property | Type | Description |
|---|---|---|
theme | Readonly<Ref<Theme>> | The resolved theme that the SDK's components use. |
colorScheme | Readonly<Ref<'light' | 'dark'>> | The current color scheme. |
direction | Readonly<Ref<'ltr' | 'rtl'>> | The text direction of the UI. |
inheritFromBranding | boolean | Whether the theme inherits from the branding preference. |
isBrandingLoading | Readonly<Ref<boolean>> | Whether the branding theme is loading. |
brandingError | Readonly<Ref<Error | null>> | The error from loading the branding theme, if any. |
toggleTheme() | () => void | Toggles the color scheme between light and dark. |
Was this page helpful?