TheDocumentation Index
Fetch the complete documentation index at: https://docs.mcp-use.com/llms.txt
Use this file to discover all available pages before exploring further.
ThemeProvider component manages dark mode by setting the dark class on the document root. It prioritizes the widget theme from OpenAI Apps SDK, falling back to system preference if the widget API is not available.
Import
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | required | The widget content to wrap |
Theme Priority
The provider uses the following priority:- Widget theme (from
window.openai.theme) - When Apps SDK is available - System preference (
prefers-color-scheme: dark) - Fallback when widget API is not available
Basic Usage
Theme Synchronization
The provider:- Syncs with ChatGPT: Automatically matches ChatGPT’s theme when running in Apps SDK
- Listens to system changes: Updates when user changes system theme preference
- Prevents flash: Uses
useLayoutEffectto apply theme synchronously before browser paint
Related Components
McpUseProvider- Includes ThemeProvider automaticallyuseWidget- Hook for accessing theme and other widget data