@modelcontextprotocol/ext-apps - v1.1.2
    Preparing search index...

    Function applyDocumentTheme

    • Apply a theme to the document root element.

      Sets the data-theme attribute and CSS color-scheme property on document.documentElement. This enables CSS selectors like [data-theme="dark"] and ensures native elements (scrollbars, form controls) respect the theme.

      Parameters

      • theme: McpUiTheme

        The theme to apply ("light" or "dark")

      Returns void

      // Apply when host context changes
      app.onhostcontextchanged = (ctx) => {
      if (ctx.theme) {
      applyDocumentTheme(ctx.theme);
      }
      };

      // Apply initial theme after connecting
      app.connect().then(() => {
      const ctx = app.getHostContext();
      if (ctx?.theme) {
      applyDocumentTheme(ctx.theme);
      }
      });
      [data-theme="dark"] {
      --bg-color: #1a1a1a;
      }
      [data-theme="light"] {
      --bg-color: #ffffff;
      }