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")
import { getDocumentTheme } from '@modelcontextprotocol/ext-apps';const theme = getDocumentTheme();console.log(`Current theme: ${theme}`); Copy
import { getDocumentTheme } from '@modelcontextprotocol/ext-apps';const theme = getDocumentTheme();console.log(`Current theme: ${theme}`);
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.