Skip to main content

useTheme()

You're reading Identity & Access Management 7.1.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.mode sets the color scheme. It defaults to 'light'.
  • preferences.theme.inheritFromBranding applies the branding preference of your organization to the theme. It defaults to true.

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​

PropertyTypeDescription
themeReadonly<Ref<Theme>>The resolved theme that the SDK's components use.
colorSchemeReadonly<Ref<'light' | 'dark'>>The current color scheme.
directionReadonly<Ref<'ltr' | 'rtl'>>The text direction of the UI.
inheritFromBrandingbooleanWhether the theme inherits from the branding preference.
isBrandingLoadingReadonly<Ref<boolean>>Whether the branding theme is loading.
brandingErrorReadonly<Ref<Error | null>>The error from loading the branding theme, if any.
toggleTheme()() => voidToggles the color scheme between light and dark.

Was this page helpful?