Get the current document theme from the root HTML element.
Reads the theme from the data-theme attribute on document.documentElement. Falls back to checking for a dark class for compatibility with Tailwind CSS dark mode conventions.
data-theme
document.documentElement
dark
The current theme ("light" or "dark")
const theme = getDocumentTheme();document.body.classList.toggle("dark", theme === "dark"); Copy
const theme = getDocumentTheme();document.body.classList.toggle("dark", theme === "dark");
applyDocumentTheme
McpUiTheme
Get the current document theme from the root HTML element.
Reads the theme from the
data-themeattribute ondocument.documentElement. Falls back to checking for adarkclass for compatibility with Tailwind CSS dark mode conventions.