Theme
Used to force a part of the tree to light or dark mode.
AI TipWant to skip the docs? Use the MCP Server
Usage
import { Theme } from "@chakra-ui/react"<Theme appearance="dark">
<div />
</Theme>Examples
Nested
The theme can be nested to apply different appearances to different parts of the tree. This is useful for applying a global appearance and then overriding some parts of it.
Good to know: We use native CSS selectors to achieve this.
Hello Normal
Hello Dark
Hello Light
Portalled
Use the asChild prop to force the appearance of portalled elements like the
popover and modal content.
Naruto Form
Naruto is a Japanese manga series written and illustrated by Masashi Kishimoto.
Page Specific Color Mode
To lock a page to a specific color mode (light or dark), wrap the entire page
with the Theme component.
You can also combine it with the ColorModeProvider if you use the
useColorMode hook.
import { ColorModeProvider } from "@/components/ui/color-mode"
import { Theme } from "@chakra-ui/react"
export const ForcedColorMode = ({ children }) => {
return (
<ColorModeProvider forcedTheme="dark">
<Theme appearance="dark">{/* Rest of the page */}</Theme>
</ColorModeProvider>
)
}