--- title: useTheme description: "`useTheme` is a custom hook that returns a function for retrieving and switching themes." links: - source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/core/system - storybook: https://yamada-ui.github.io/yamada-ui?path=/story/hooks-usetheme--basic --- # useTheme `useTheme` is a custom hook that returns a function for retrieving and switching themes. ```tsx const { theme } = useTheme() return {JSON.stringify(theme)} ``` ## Usage ```tsx import { useTheme } from "@yamada-ui/react" ``` ```tsx import { useTheme } from "@/components/ui" ``` ```tsx import { useTheme } from "@workspaces/ui" ``` ```tsx const { themeScheme, changeThemeScheme } = useTheme() ``` :::note For more on customizing tokens and styles, see [Theming](https://yamada-ui.com/docs/theming.md). ::: ### Switching Themes ```tsx const { themeScheme, changeThemeScheme } = useTheme() return ( The current scheme is "{themeScheme}" Primary Secondary Primary Secondary ) ``` :::warning In order to switch themes, you need to prepare multiple themes. For more details, see the [Switching Themes](https://yamada-ui.com/docs/theming/switching-themes.md). :::