Skip to content

[Feature request] Expose theme input on model-explorer-visualizer web component for external dark mode control #613

Closed

Description

@huasor

Summary

The model-explorer-visualizer web component (custom element) doesn't expose a way for host applications to control the theme (light/dark). When a host application switches to dark mode, the visualizer remains in light mode.

Additionally, the npm package ai-edge-model-explorer-visualizer (v0.1.2, published June 2025) is significantly outdated and missing features that exist in the latest source, including dark mode support.

Analysis

Looking at the source code, the theme system works internally:

  1. ModelGraphVisualizer has a theme = input<string>('light') and sets [attr.data-metheme] on its host element
  2. ThemeService manages theme state and sets document.body.dataset['metheme']
  3. CSS variables (--me-*) are applied via body[data-metheme='dark'] selectors in colors.scss

However, the Wrapper component (custom_element/wrapper.ts) that creates the web component:

  • Uses ViewEncapsulation.ShadowDom, which blocks body[data-metheme] CSS selectors from penetrating
  • Does not bind [theme] to ModelGraphVisualizer in its template (wrapper.ng.html)
  • Does not expose theme as an input on the custom element

This means external applications embedding <model-explorer-visualizer> have no way to:

  1. Pass a theme preference (light/dark) to the visualizer
  2. Have CSS variables propagate into the Shadow DOM
  3. Synchronize the visualizer's theme with the host application's theme

Suggested Solution

  1. Expose theme attribute on the model-explorer-visualizer custom element, so host applications can use it like:
<model-explorer-visualizer theme="dark"></model-explorer-visualizer>

Or dynamically via JavaScript:

  const visualizer = document.querySelector('model-explorer-visualizer');
  visualizer.theme = 'dark'; // or 'light'

This would require:

  • Adding theme as an @input() on Wrapper component
  • Binding [theme]="theme" to in wrapper.ng.html
  • Optionally reflecting the theme attribute on the custom element
  1. Publish a new version of the ai-edge-model-explorer-visualizer npm package. The current v0.1.2 is outdated and lacks many features available in the latest source (dark mode, updated visualizer config options, etc.).

Environment

  • ai-edge-model-explorer-visualizer npm package version: 0.1.2 (June 2025)
  • Source: latest main branch (April 2025)
  • Host application: React 19 + MUI v7, embedding via dynamic import

Workaround Attempted

Tried setting document.body.dataset['metheme'] = 'dark' from the host app, but it doesn't work due to Shadow DOM encapsulation. Also attempted using MutationObserver to set data-metheme on internal elements inside the shadow root, but Angular's internal effect cycle overrides it back.

Also tried building from source and replacing the npm package files manually, but even with the latest source build, the Wrapper component still doesn't expose theme as a configurable input.

Activity

  1. changed the title [-][Feature] Expose `theme` input on `model-explorer-visualizer` web component for external dark mode control[/-] [+][Feature request] Expose `theme` input on `model-explorer-visualizer` web component for external dark mode control[/+] on Apr 8, 2026
  2. self-assigned this
    on Apr 14, 2026
  3. sourcelite commented on Apr 14, 2026

    @sourcelite
    Member

    Hi @zhepoch, welcome here and thanks for providing such a detailed feature request + root cause analysis. we truly appreciate your efforts for digging deep with investigation into shadow dom encapsulation and also missing 'Input()' binding in wrapper component.

    we would like to know about following info -

    • while evaluating this model-explorer-visualizer wrapper, did you identify any other internal configurations or state controls that are currently missing from custom element external api that the host application required ?

    Thankyou!

  4. added
    status:awaiting user response
    on Apr 14, 2026
  5. github-actions commented on Apr 22, 2026

    @github-actions

    Marking this issue as stale since it has been open for 7 days with no activity. This issue will be closed if no further activity occurs.

  6. added
    status:stale
    on Apr 22, 2026
  7. github-actions commented on Apr 29, 2026

    @github-actions

    This issue was closed because it has been inactive for 14 days. Please post a new issue if you need further assistance. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

status:awaiting user responsestatus:staletype:feature

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions