[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M699GGVJHWCJNW68P08VWCMA":3,"skill-same:01M699GGVJHWCJNW68P08VWCMA":80},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":31,"publishedAt":52,"linkOnly":53,"markdownContent":54,"markdownBody":55,"frontMatter":56,"refName":57,"commitSha":58,"skillDirectory":59,"forksCount":60,"repositoryHtmlUrl":61,"repositoryHomepageUrl":6,"ownerHtmlUrl":62,"ownerBlogUrl":63,"ownerDescription":64,"updatedAt":65,"install":66,"resources":79},"01M699GGVJHWCJNW68P08VWCMA","ui-styling",null,"Guide for the visual style, structure, and shared building blocks used by Semantic Link Labs interactive UI tools (HTML widgets and anywidget-based widgets). Use this when adding a new interactive UI, modifying an existing one, or adding shared visual components.","microsoft\u002Fsemantic-link-labs","microsoft","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6154722?v=4","01M698VYDXZ6JW5WH3CRV650R8","Microsoft","01M699FKMT63C17BFNH8WHZN2K",600,"MIT","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fsemantic-link-labs\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fui-styling\u002FSKILL.md",[18,23,26],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000009","前端开发","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000015","视觉设计",{"categoryNo":27,"categoryName":28,"taxonomyType":29,"taxonomyTypeDesc":30},"01JBSEEDCAT000000000000032","设计师","PROFESSION","适用职业",[32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],"ui styling","ui","styling","when","components","Existing","for","blocks","visual style","style","widgets","shared","visual","structure","html","use","guide","interactive","Building Blocks","Tools","2026-11-10 10:12:30",false,"---\nname: ui-styling\ndescription: Guide for the visual style, structure, and shared building blocks used by Semantic Link Labs interactive UI tools (HTML widgets and anywidget-based widgets). Use this when adding a new interactive UI, modifying an existing one, or adding shared visual components.\n---\n\n# UI Styling for Interactive Tools\n\nThis skill describes the styling conventions, shared building blocks, and architectural patterns used by all interactive UI tools in Semantic Link Labs so that every tool has a consistent, elegant design.\n\n## When to Use This Skill\n\nUse this skill when you need to:\n\n- Add a **new interactive UI** function to the library.\n- Modify an existing interactive UI (e.g. `vertipaq_analyzer`, `delta_analyzer`, `perspective_editor`).\n- Add new **shared visual components** (icons, theme variables, headers, etc.) that should be reused across tools.\n- Decide between a **static-HTML** widget and an **anywidget**-based widget.\n\n---\n\n## The Two UI Patterns\n\nSemantic Link Labs has exactly two supported patterns for interactive UI tools. Always pick one based on whether the UI needs to call back into Python after the initial render.\n\n| Pattern | When to use | Reference implementations |\n|---------|-------------|---------------------------|\n| **Static-HTML widget** (the *Vertipaq style*) | The UI is fully driven by the data computed in Python *before* render. All interactivity (filtering, sorting, tab switching, theme toggle, column resizing, etc.) is done in **pure browser-side JavaScript**. No Python code runs after `display(HTML(...))`. | `sempy_labs.semantic_model._vertipaq_analyzer.vertipaq_analyzer`, `sempy_labs._delta_analyzer.delta_analyzer` |\n| **anywidget widget** (the *Perspective Editor style*) | The UI must run Python code in response to user actions (e.g. write back to a semantic model, refresh data from a REST API, perform long-running operations). State is synced between the JS frontend and the Python backend via `traitlets`. | `sempy_labs.semantic_model._perspective_editor.perspective_editor` |\n\n> **Rule of thumb:** if the only thing the user does is view, sort, filter, or switch between pre-computed data, use the **static-HTML** pattern. If they can *change* something that must persist (model edits, refresh triggers, server calls), use **anywidget**.\n\n---\n\n## Shared Building Blocks: `sempy_labs._ui_components`\n\n`src\u002Fsempy_labs\u002F_ui_components.py` is the single source of truth for everything visual that should be consistent across tools. **Both patterns must source their visual primitives from this module.** If you need a new shared visual component (a new icon, a new helper, a new themed control), add it here so every tool can pick it up.\n\n### What lives there today\n\n| Export | Purpose |\n|--------|---------|\n| `ICONS` | Dict of monochrome SVG icons. All use `stroke=\"currentColor\"` \u002F `fill=\"currentColor\"` so they adapt to light and dark themes automatically. Keys include tabular-object icons (`table`, `calculation_group`, `column`, `column_chunk`, `measure`, `hierarchy`, `calculation_item`, `partition`, `relationship`), tree\u002Fnavigation icons (`caret_right`, `folder`, `level`), and UI\u002Faction icons (`sun`, `moon`, `search`, `plus`, `play`, `stop`, `refresh`, `swap`, `sort_asc`, `sort_desc`, `panel_collapse`, `panel_expand`, `builder`, `close`, `fullscreen`, `fullscreen_exit`). |\n| `LIGHT_THEME_VARS`, `DARK_THEME_VARS` | CSS custom-property blocks defining the Apple-inspired light and dark palettes. Always reference colors via these `--ui-*` tokens, never hard-coded hex values. Includes semantic tokens for hover backgrounds (`--ui-bg-hover`), on-accent text (`--ui-on-accent`), and destructive\u002Ferror states (`--ui-danger*`). |\n| `SYNTAX_HIGHLIGHT_VARS` | Theme-independent `--ui-syntax-*` token block for colorizing DAX\u002Fcode in an editor. Inject once into the widget's base scope (it is the same in light and dark). |\n| `HEADER_CSS`, `scoped_header_css(root_selector)` | Standard widget header styles (title + dataset\u002Fworkspace subtitle) **and the four standard header controls** (`.sl-theme-btn`, `.sl-change-btn`, `.sl-reload-btn`). `scoped_header_css` prefixes every rule with the root selector so the styles win against notebook host CSS (e.g. Jupyter's `.jp-RenderedHTMLCommon button`). Every tool must inject this, even when it builds its own header markup. |\n| `render_header_html(title, dataset_name, workspace_name, theme_btn_id, dark_mode, fullscreen_btn_id)` | Renders the standard header markup. Pass `fullscreen_btn_id` to include a full-screen toggle button next to the theme toggle. |\n| `theme_toggle_script(btn_id, root_selector, dark_class)` | Returns a `\u003Cscript>` block that wires the theme toggle button to flip a `dark_class` on the root element and swap the sun\u002Fmoon icon. |\n| `fullscreen_css(root_selector, fullscreen_class, container_selector=None, bg_var)` | Returns the CSS for a widget's full-screen state (covers both the native `:fullscreen` pseudo-class and the `fullscreen_class` CSS-overlay fallback). Pass `container_selector` when an inner element carries the card styling; pass `bg_var` to match the widget's background token. |\n| `fullscreen_toggle_script(btn_id, root_selector, fullscreen_class)` | Returns a `\u003Cscript>` block that wires a full-screen toggle button for **static-HTML** widgets. Pair with `render_header_html(..., fullscreen_btn_id=...)` and `fullscreen_css`. |\n| `fullscreen_setup_js(func_name=\"sllsSetupFullscreen\")` | Returns a JS function definition that wires a full-screen toggle button for **anywidget** widgets. Embed once at the top of the ESM module, then call `func_name(root, btn, fullscreenClass, enterSvg, exitSvg)` after creating the button. |\n| `display_html_widget(html, fallback=True)` | Renders a self-contained HTML string (styles + markup + inline `\u003Cscript>`) via a lightweight anywidget so it lives in the notebook **webview's light DOM** instead of the sandboxed `srcdoc` iframe used for raw `display(HTML)`. Use this for static-HTML widgets so the full-screen toggle gets the native Fullscreen API (matching the anywidget tools). Falls back to `display(HTML(html))` when `anywidget` is unavailable. |\n| `TABLE_COLUMN_RESIZE_JS`, `scoped_table_column_resize_css(root_selector)` | Resizable table columns. Embed the JS in the widget's ESM module and call `sllsInstallColumnResizers(table, { widths, key })` after the table is in the DOM (drag a header border to resize, double-click to fit; pass a persistent `widths` Map so widths survive re-renders). Inject the scoped CSS for the default handle classes. Reference: `lakehouse._lakehouse_manager`. |\n| `ATTRIBUTION_CSS`, `scoped_attribution_css(root_selector)`, `render_attribution_html(extra_links=None)` | \"Powered by Semantic Link Labs\" attribution shown at the bottom of every widget, with an optional list of extra `(label, url)` links. |\n| `SEARCH_SELECT_CSS`, `SEARCH_SELECT_JS` | The standard **searchable single-select** picker (`createSearchSelect({ placeholder, searchPlaceholder, ariaLabel, emptyLabel, onChange })`). Every workspace \u002F semantic model \u002F item picker must use this control — never a plain `\u003Cselect>` — so long lists can always be filtered by typing. Inject the CSS into the widget stylesheet and the JS into the widget's ESM module, then drive the returned controller with `setOptions(items, value)`, `setEmptyLabel(text)` and `setDisabled(flag)`. Reference implementations: `semantic_model._find_unused_objects`, `semantic_model._bpa`. |\n\n### When to extend `_ui_components`\n\nAdd a new export to `_ui_components.py` whenever the same visual element appears (or *should* appear) in more than one tool. Typical candidates: a new icon, a shared button style, a status-pill style, a confirmation-dialog component, a toast\u002Fnotification helper. Do **not** copy-paste CSS or SVGs between widgets — promote them to `_ui_components` instead.\n\n---\n\n## Standard Header Controls (mandatory)\n\nFour controls recur in nearly every tool. They must look and behave identically\neverywhere, so both their icon and their chrome come from `_ui_components` — a\ntool never defines its own size, radius, border or icon for them. The\n`sempy_labs.semantic_model.test` (DAX Perf Optimizer) widget is the reference\nimplementation.\n\n| Control | Class | Icon | Footprint |\n|---------|-------|------|-----------|\n| Light\u002Fdark mode | `sl-theme-btn` | `ICONS[\"sun\"]` \u002F `ICONS[\"moon\"]` | 32×32 circle, 18px icon |\n| Full screen | `sl-theme-btn` | `ICONS[\"fullscreen\"]` \u002F `ICONS[\"fullscreen_exit\"]` | 32×32 circle, 18px icon |\n| Change model \u002F workspace | `sl-change-btn` | `ICONS[\"swap\"]` | 32×32, 8px radius, 18px icon |\n| Reload (workspaces, models, lists) | `sl-reload-btn` | `ICONS[\"refresh\"]` | 32×32 circle, 14px icon |\n\nRules:\n\n- Inject `scoped_header_css(root_selector)` into the widget stylesheet, and use\n  the class names above. Do **not** re-declare `.sl-theme-btn`,\n  `.sl-change-btn` or `.sl-reload-btn` in a tool — `tests\u002Ftest_ui_header_controls.py`\n  fails if a tool restyles them.\n- While a reload is in flight, add `sl-spinning` to the reload button; the\n  shared CSS animates the icon.\n- If the tool uses `--slls-*` (or other) palette names, alias the `--ui-*`\n  tokens the shared CSS reads: `--ui-surface`, `--ui-surface-2`,\n  `--ui-border-strong`, `--ui-text`, `--ui-text-secondary`,\n  `--ui-text-tertiary`, `--ui-accent`, `--ui-accent-soft`.\n- Tools rendering their header with `render_header_html` get these for free via\n  `theme_btn_id`, `fullscreen_btn_id` and `picker_btn_id`. For an extra button\n  that changes the model\u002Fworkspace, pass `\"base\": \"sl-change-btn\"` in\n  `extra_buttons`.\n- Buttons that are *not* one of these four (e.g. expand\u002Fcollapse, delete,\n  tool-specific actions) keep their own tool-scoped classes.\n\n### Workspace \u002F semantic model pickers\n\nAlways resolve the workspace with `resolve_workspace_name_and_id(workspace)`\n**even when the caller passed nothing**, and seed the picker with the result, so\nthe workspace dropdown opens pre-selected on the current workspace. Passing\n`None` resolves to the attached lakehouse's workspace, or the notebook's.\n\n---\n\n## Design Tokens (the visual language)\n\nAll interactive UIs share one visual language. Stick to these tokens — do not introduce one-off colors, fonts, radii, or shadows.\n\n### Typography\n\n- Font stack: `-apple-system, BlinkMacSystemFont, \"SF Pro Display\", \"SF Pro Text\", \"Helvetica Neue\", Helvetica, Arial, sans-serif`.\n- Enable font smoothing: `-webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;`.\n- Title (22px \u002F 600 \u002F `-0.01em` letter-spacing) and subtitle (≈12.5px \u002F `--ui-text-secondary`) are produced by `render_header_html` — do not re-implement them.\n- Use `font-variant-numeric: tabular-nums` for any numeric column or large numeric value.\n\n### Color tokens (from `LIGHT_THEME_VARS` \u002F `DARK_THEME_VARS`)\n\n| Token | Use for |\n|-------|---------|\n| `--ui-bg`, `--ui-bg-secondary`, `--ui-bg-tertiary`, `--ui-bg-solid` | Surfaces, in increasing emphasis levels |\n| `--ui-bg-hover` | Solid hover background for controls\u002Fbuttons whose base is `--ui-bg` |\n| `--ui-surface`, `--ui-surface-2` | Translucent overlays \u002F hover backgrounds |\n| `--ui-border`, `--ui-border-strong` | Subtle and strong borders |\n| `--ui-text`, `--ui-text-secondary`, `--ui-text-tertiary` | Primary, secondary, tertiary text |\n| `--ui-accent`, `--ui-accent-hover`, `--ui-accent-soft` | Brand accent (links, focus rings, active tab indicator, primary buttons, data bars) |\n| `--ui-on-accent` | Text\u002Ficon color placed on top of an `--ui-accent` (or `--ui-danger`) fill — i.e. \"white\" |\n| `--ui-danger`, `--ui-danger-hover` | Destructive button fill + hover (e.g. a Stop button) |\n| `--ui-danger-bg`, `--ui-danger-border`, `--ui-danger-text` | Inline error\u002Falert box background, border, and text (themed for light + dark) |\n| `--ui-shadow-sm`, `--ui-shadow-md`, `--ui-shadow-lg` | Elevation |\n\nNever hard-code `#fff`, red error colors, or any other literal — always go through a token. If a destructive action, error banner, or white-on-accent label is needed, use the danger \u002F on-accent tokens above rather than inlining hex values.\n\n### Code \u002F DAX syntax-highlight palette (`SYNTAX_HIGHLIGHT_VARS`)\n\nFor colorizing DAX (or similar code) inside an editor\u002Fhighlighter, inject the\ntheme-independent `SYNTAX_HIGHLIGHT_VARS` block once into the widget's **base**\nscope (it intentionally renders the same in light and dark, so do not override\nit in the dark block). Reference these `--ui-syntax-*` tokens — never the raw\nhex values.\n\n| Token | Token class it colors |\n|-------|-----------------------|\n| `--ui-syntax-keyword`, `--ui-syntax-function` | Keywords and function names |\n| `--ui-syntax-variable` | Variables |\n| `--ui-syntax-number` | Numeric literals |\n| `--ui-syntax-virtual-column` | Virtual \u002F measure-ref columns |\n| `--ui-syntax-string` | String literals |\n| `--ui-syntax-operator`, `--ui-syntax-punctuation` | Operators and punctuation |\n\nSee `sempy_labs.semantic_model._test_dax.test` for the reference usage (it\ninjects `SYNTAX_HIGHLIGHT_VARS` into its `.dtx` base block alongside\n`LIGHT_THEME_VARS`).\n\nIf a tool needs its own derived names (e.g. `--vpx-text`), alias them to the `--ui-*` tokens inside the tool's scoped block — see `_vertipaq_analyzer.py` for the pattern. This keeps the palette centralized while letting tools use short, local names.\n\n### Shape and motion\n\n- Radii: `12px` (containers), `8px` (controls\u002Fcards) — exposed as `--vpx-radius` \u002F `--vpx-radius-sm` style aliases when needed.\n- Transitions: `0.25s cubic-bezier(0.4, 0, 0.2, 1)` for color\u002Fborder\u002Fbackground; `120ms ease` for small button state changes; `80ms` for press scale.\n- Subtle hover\u002Factive states only — no heavy animations.\n\n---\n\n## Anatomy of a Widget\n\nEvery interactive UI, regardless of pattern, should be composed of these regions in this order:\n\n1. **Root container** with a per-instance unique class (e.g. `vpx-\u003Cuid>`) and an optional dark-mode modifier class (e.g. `vpx-dark`). The unique id (`uid = uuid.uuid4().hex[:8]`) keeps multiple widgets on the same page from colliding.\n2. **Standard header** rendered via `render_header_html(...)` — title + dataset\u002Fworkspace subtitle + theme toggle button.\n3. **Summary cards** (optional) — a horizontal row of `(label, value)` cards summarizing the result set.\n4. **Tab bar** (optional) — for multi-section views; active tab uses `--ui-accent` text + a 2px accent underline.\n5. **Toolbar** (optional) — search box (using `ICONS[\"search\"]`), row count, view toggles (e.g. data-bars on\u002Foff).\n6. **Main content** — table, tree, form, etc.\n7. **Attribution** rendered via `render_attribution_html(...)` at the bottom, with optional `extra_links` for upstream credit (e.g. SQLBI's Vertipaq Analyzer).\n\n---\n\n## Pattern A: Static-HTML Widget (Vertipaq \u002F Delta Analyzer style)\n\nUse this for **read-only \u002F pre-computed** UIs. End-to-end recipe:\n\n### 1. Compute data in Python, then render\n\nBuild the `pandas.DataFrame`(s) or dict of dataframes in Python. Pass them to a private `visualize_*` \u002F `_render_*` helper that assembles HTML and JS strings and calls `IPython.display.display(HTML(...))`.\n\n### 2. Generate a per-instance uid\n\n```python\nuid = uuid.uuid4().hex[:8]\nroot_selector = f\".vpx-{uid}\"            # used for scoping CSS + JS lookups\ntheme_btn_id = f\"vpx-theme-{uid}\"\n```\n\nEvery CSS class, every DOM id, and every global JS function name **must** include `uid` so multiple instances on one notebook page never clash.\n\n### 3. Import the shared building blocks\n\nPull from `sempy_labs._ui_components` — do not re-define icons, colors, headers, theme-toggle JS, or the attribution footer.\n\n```python\nfrom sempy_labs._ui_components import (\n    ICONS as _UI_ICONS,\n    LIGHT_THEME_VARS as _UI_LIGHT_VARS,\n    DARK_THEME_VARS as _UI_DARK_VARS,\n    scoped_header_css as _ui_scoped_header_css,\n    scoped_attribution_css as _ui_scoped_attribution_css,\n    render_header_html as _ui_render_header_html,\n    render_attribution_html as _ui_render_attribution_html,\n    theme_toggle_script as _ui_theme_toggle_script,\n)\n```\n\n### 4. Scope all CSS under the root selector\n\nInline the light palette inside `.vpx-\u003Cuid> { ... }` and the dark palette inside `.vpx-\u003Cuid>.vpx-dark { ... }`, so dark mode is a class toggle on the root. Include `_ui_scoped_header_css(root_selector)` and `_ui_scoped_attribution_css(root_selector)` in your `\u003Cstyle>` block. Scoping is required so that high-specificity notebook host styles (Jupyter, VS Code, Fabric) do not override your widget.\n\n### 5. Build the markup in order: header → cards → tabs → toolbar → content → attribution\n\nUse `render_header_html(...)` for the header and `render_attribution_html(...)` for the footer. Re-use icons from `_UI_ICONS` (apply your own class via `.replace(\"\u003Csvg \", '\u003Csvg class=\"vpx-tab-icon\" ', 1)` for sizing).\n\n### 6. Wire all interactivity in inline JavaScript\n\nFilter\u002Fsort\u002Fresize\u002Ftab-switch\u002Fbar-toggle logic lives in a `\u003Cscript>` block whose function names are also uid-suffixed (e.g. `window.vpxSort_\u003Cuid>`). The theme toggle button is wired by appending `_ui_theme_toggle_script(btn_id=theme_btn_id, root_selector=root_selector, dark_class=\"vpx-dark\")`.\n\n### 7. Render\n\n```python\ndisplay(HTML(styles + \"\\n\".join(html_parts) + script + theme_script))\n```\n\n### Reference\n\n- `src\u002Fsempy_labs\u002Fsemantic_model\u002F_vertipaq_analyzer.py` — `visualize_vertipaq` (full implementation: cards, tabs, toolbar, sortable\u002Ffilterable\u002Fresizable table with optional data bars).\n- `src\u002Fsempy_labs\u002F_delta_analyzer.py` — same pattern applied to delta-table analysis output.\n\n---\n\n## Pattern B: anywidget Widget (Perspective Editor style)\n\nUse this when the UI must call back into Python after render (e.g. to edit a semantic model, trigger a refresh, run an API call). The widget is implemented as a subclass of `anywidget.AnyWidget` with state synced via `traitlets`.\n\n### 1. Guard the optional dependency\n\n`anywidget` is **not** a hard dependency of the library — keep it that way. Import lazily inside the public function and raise a friendly `ImportError` if missing:\n\n```python\ntry:\n    import anywidget\n    import traitlets\nexcept ImportError as e:\n    raise ImportError(\n        \"The '\u003Cmy_tool>' function requires the 'anywidget' package. \"\n        \"Install it with: pip install anywidget\"\n    ) from e\n```\n\n### 2. Subclass `anywidget.AnyWidget`\n\nDefine the widget with class attributes `_esm` (the JS module string — typically a top-level `function render({ model, el }) { ... }` block) and `_css` (the CSS string). Declare every piece of state that must cross the Python\u002FJS boundary as a synced traitlet:\n\n```python\nclass MyWidget(anywidget.AnyWidget):\n    _esm = _WIDGET_JS\n    _css = _WIDGET_CSS\n\n    data = traitlets.Dict().tag(sync=True)\n    selected = traitlets.Unicode(\"\").tag(sync=True)\n    status = traitlets.Dict().tag(sync=True)         # { \"message\": ..., \"kind\": \"success\"|\"error\" }\n    pending_action = traitlets.Dict().tag(sync=True) # what JS asked Python to do\n    run = traitlets.Int(0).tag(sync=True)            # bump to trigger the Python callback\n    dataset_name = traitlets.Unicode(\"\").tag(sync=True)\n    workspace_name = traitlets.Unicode(\"\").tag(sync=True)\n    dark_mode = traitlets.Bool(False).tag(sync=True)\n```\n\n### 3. Use the \"bump `run` + observe\" callback pattern\n\nJS triggers Python work by setting `pending_action` (a dict describing what to do) and then incrementing `run` and calling `model.save_changes()`. Python observes `run` and dispatches based on `pending_action[\"action\"]`. On completion it writes results back to other traitlets (including a user-visible `status`) which the JS observer renders.\n\n```python\ndef _on_run(change):\n    data = dict(widget.pending_action or {})\n    action = data.get(\"action\")\n    if not action:\n        return\n    try:\n        ...  # do Python work, then update widget.status \u002F other traitlets\n    except Exception as e:\n        widget.status = {\"message\": f\"Error: {e}\", \"kind\": \"error\"}\n\nwidget.observe(_on_run, names=[\"run\"])\n```\n\n### 4. Display once, keep the reference alive\n\nAfter `display(widget)`, keep the local `widget` reference inside the closure (Python's GC must not collect it, or observers stop firing). **Do not also `return widget`** — that causes Jupyter to render it a second time.\n\n### 5. Visual conventions on the JS side\n\nThe frontend `render({ model, el })` function should:\n\n- Create a root `\u003Cdiv>` with a stable namespace class (e.g. `slls-pe` for the perspective editor). Add `slls-pe-dark` when `dark_mode === true` and `slls-pe-auto` (which uses `@media (prefers-color-scheme: dark)`) when `dark_mode` is null\u002Fundefined.\n- Build the header with the same title + dataset\u002Fworkspace subtitle + sun\u002Fmoon theme-toggle button shape used by the static widgets. The theme button toggles the `dark_mode` traitlet (`model.set(\"dark_mode\", ...); model.save_changes();`) so the preference round-trips to Python.\n- Use the **same color\u002Ftypography\u002Fradius tokens** as `_ui_components` (light + dark palettes, Apple font stack, 12px \u002F 8px radii). When you need an icon also used elsewhere, embed the SVG from `ICONS` (e.g. via a Python-side template-substitution placeholder like `__SLLS_ICON_TABLE__`) so there is one source of truth.\n- Always render the \"Powered by Semantic Link Labs\" attribution at the bottom via the shared component — never hand-write the markup or its CSS. Insert it with a placeholder (e.g. `root.insertAdjacentHTML(\"beforeend\", \\`__SLLS_ATTRIBUTION__\\`)`), substitute `render_attribution_html()` for it at import time, and add `scoped_attribution_css(root_selector)` to the widget CSS. The shared CSS reads `--ui-text-tertiary` and `--ui-accent`, so alias them if the tool uses its own palette names. `tests\u002Ftest_ui_attribution.py` fails if a tool writes its own attribution.\n\n> If you need a new visual primitive in an anywidget tool (a new icon, a new button style, a new theme token), add it to `_ui_components` and substitute it into the `_WIDGET_JS`\u002F`_WIDGET_CSS` strings — do not fork the design.\n\n### Reference\n\n- `src\u002Fsempy_labs\u002Fsemantic_model\u002F_perspective_editor.py` — `perspective_editor`. Full implementation showing widget class definition, traitlets, the `pending_action` + `run` callback pattern, dark-mode round-trip, and lazy-import guard.\n- `src\u002Fsempy_labs\u002Fsemantic_model\u002F_direct_lake_manager.py` — `direct_lake_manager`. Multi-screen anywidget with model-selection \u002F model-management screens, popover menus, modals, pending-change tracking, and a save bar. Demonstrates icon-template-substitution from `_ui_components.ICONS`.\n\n### 6. Icon template-substitution recipe (anywidget)\n\nBecause `_WIDGET_JS` is a raw string passed to anywidget's `_esm`, you cannot directly call Python at JS render time. To keep icons centralized in `_ui_components.ICONS`, use **placeholder substitution at module-import time**:\n\n1. In `_WIDGET_JS`, refer to icons through uppercase placeholders, e.g.:\n\n    ```javascript\n    const SUN_SVG = `__SLLS_ICON_SUN__`;\n    const ICON_SVG = {\n        table: `__SLLS_ICON_TABLE__`,\n        column: `__SLLS_ICON_COLUMN__`,\n        \u002F\u002F ...\n    };\n    ```\n\n2. Immediately after `_WIDGET_JS = r\"\"\"...\"\"\"\"`, substitute each placeholder from `ICONS`:\n\n    ```python\n    from sempy_labs._ui_components import ICONS as _UI_ICONS\n\n    _WIDGET_JS = (\n        _WIDGET_JS\n        .replace(\"__SLLS_ICON_SUN__\", _UI_ICONS[\"sun\"])\n        .replace(\"__SLLS_ICON_MOON__\", _UI_ICONS[\"moon\"])\n        .replace(\"__SLLS_ICON_TABLE__\", _UI_ICONS[\"table\"])\n        .replace(\"__SLLS_ICON_COLUMN__\", _UI_ICONS[\"column\"])\n        # ...one .replace per icon used\n    )\n    ```\n\nDo **not** inline raw SVG strings inside `_WIDGET_JS`. If you need an icon that isn't in `ICONS` yet, add it to `_ui_components.ICONS` first, then substitute it in.\n\n### 7. Minimal anywidget template\n\n```python\nfrom typing import Optional\nfrom uuid import UUID\nfrom sempy._utils._log import log\n\n_WIDGET_CSS = \"\"\"\n.my-widget { \u002F* root container styles, using --ui-* tokens *\u002F }\n.my-widget.my-widget-dark { \u002F* DARK_THEME_VARS-equivalent overrides *\u002F }\n\"\"\"\n\n_WIDGET_JS = r\"\"\"\nfunction render({ model, el }) {\n    const root = document.createElement(\"div\");\n    root.className = \"my-widget\";\n\n    function applyTheme() {\n        root.classList.remove(\"my-widget-dark\", \"my-widget-auto\");\n        const dm = model.get(\"dark_mode\");\n        if (dm === true) root.classList.add(\"my-widget-dark\");\n        else if (dm == null) root.classList.add(\"my-widget-auto\");\n    }\n    applyTheme();\n    model.on(\"change:dark_mode\", applyTheme);\n    el.appendChild(root);\n\n    const SUN = `__SLLS_ICON_SUN__`;\n    const MOON = `__SLLS_ICON_MOON__`;\n\n    \u002F\u002F ... build header, body, attribution ...\n\n    \u002F\u002F Trigger a Python action:\n    function runAction(payload) {\n        model.set(\"pending_action\", payload);\n        model.set(\"run\", model.get(\"run\") + 1);\n        model.save_changes();\n    }\n}\nexport default { render };\n\"\"\"\n\nfrom sempy_labs._ui_components import ICONS as _UI_ICONS  # noqa: E402\n\n_WIDGET_JS = (\n    _WIDGET_JS\n    .replace(\"__SLLS_ICON_SUN__\", _UI_ICONS[\"sun\"])\n    .replace(\"__SLLS_ICON_MOON__\", _UI_ICONS[\"moon\"])\n)\n\n\n@log\ndef my_widget_function(\n    dataset: str | UUID,\n    workspace: Optional[str | UUID] = None,\n    dark_mode: bool = False,\n):\n    \"\"\"One-line description.\n\n    Parameters\n    ----------\n    dataset : str | uuid.UUID\n        ...\n    workspace : str | uuid.UUID, default=None\n        The Fabric workspace name or ID. Defaults to the attached lakehouse\n        workspace or the notebook workspace.\n    dark_mode : bool, default=False\n        If True, renders with a dark color theme.\n    \"\"\"\n    try:\n        import anywidget\n        import traitlets\n    except ImportError as e:\n        raise ImportError(\n            \"The 'my_widget_function' function requires the 'anywidget' \"\n            \"package. Install it with: pip install anywidget\"\n        ) from e\n\n    from IPython.display import display\n    from sempy_labs._helper_functions import (\n        resolve_workspace_name_and_id,\n        resolve_dataset_name_and_id,\n    )\n\n    ws_name, ws_id = resolve_workspace_name_and_id(workspace)\n    ds_name, ds_id = resolve_dataset_name_and_id(dataset, ws_id)\n\n    class _Widget(anywidget.AnyWidget):\n        _esm = _WIDGET_JS\n        _css = _WIDGET_CSS\n        dataset_name = traitlets.Unicode(\"\").tag(sync=True)\n        workspace_name = traitlets.Unicode(\"\").tag(sync=True)\n        dark_mode = traitlets.Bool(False).tag(sync=True)\n        status = traitlets.Dict().tag(sync=True)\n        pending_action = traitlets.Dict().tag(sync=True)\n        run = traitlets.Int(0).tag(sync=True)\n\n    widget = _Widget(\n        dataset_name=ds_name,\n        workspace_name=ws_name or \"\",\n        dark_mode=bool(dark_mode),\n    )\n\n    def _on_run(_change):\n        action = (widget.pending_action or {}).get(\"action\")\n        if not action:\n            return\n        try:\n            # ... dispatch on action, mutate traitlets ...\n            widget.status = {\"message\": \"Done.\", \"kind\": \"success\"}\n        except Exception as e:\n            widget.status = {\"message\": f\"Error: {e}\", \"kind\": \"error\"}\n\n    widget.observe(_on_run, names=[\"run\"])\n    display(widget)  # do NOT return widget\n```\n\n---\n\n## The Full-Screen Toggle\n\nEvery interactive widget should offer a **full-screen button** in its header\n(next to the theme toggle) that expands the tool to fill the screen and toggles\nback. The behavior is centralized in `sempy_labs._ui_components` so all widgets\nstay in sync — never re-implement it.\n\nThe toggle is host-aware because notebook hosts constrain what \"full screen\" can\nmean. The native [Fullscreen API](https:\u002F\u002Fdeveloper.mozilla.org\u002Fdocs\u002FWeb\u002FAPI\u002FFullscreen_API)\nonly works for an element in the top-level document or in an `\u003Ciframe>` carrying\n`allowfullscreen`. Notebook output **webviews** (where `anywidget` content and\nanything rendered via `display_html_widget` live) permit it, so the toggle gets\ntrue edge-to-edge fullscreen there. By contrast, raw `display(HTML(...))` with a\n`\u003Cscript>` is isolated in a nested, **sandboxed `srcdoc` iframe without\n`allowfullscreen`**, where `requestFullscreen()` is rejected and a `position:\nfixed` overlay collapses the content-sized iframe into an unreadable strip. This\nis exactly why static-HTML widgets should render via `display_html_widget`\n(see below) rather than `display(HTML(...))`.\n\nThe shared logic in `_FULLSCREEN_BODY` is a faithful port of the reference\nimplementation in `sempy_labs.semantic_model._test_dax.test`, and is intentionally\nsimple — two states:\n\n1. **Native fullscreen** — try `root.requestFullscreen()`. This gives true\n   edge-to-edge fullscreen, and the native `:fullscreen` CSS rules style it. This\n   is the normal path for every tool, since they all render in the webview\n   (anywidget content directly, static-HTML widgets via `display_html_widget`).\n2. **CSS-overlay fallback** — if `requestFullscreen()` rejects or is unavailable,\n   apply the `fullscreenClass` fixed overlay (`position: fixed; inset: 0`), which\n   fills the viewport. This only matters in degraded hosts (e.g. the\n   `display(HTML(...))` fallback when `anywidget` isn't installed).\n\nThe button stays in sync when the user leaves native full screen via the `Esc`\nkey (a `fullscreenchange` listener re-renders it). The button icon swaps between\n`ICONS[\"fullscreen\"]` (enter) and `ICONS[\"fullscreen_exit\"]` (exit). The behavior\nis exposed via `fullscreen_setup_js` (anywidget) \u002F `fullscreen_toggle_script`\n(static HTML) — never re-implement it.\n\n### Static-HTML widgets (Vertipaq \u002F Delta style)\n\n1. Allocate a button id and a fullscreen class alongside the other per-instance ids:\n   ```python\n   fullscreen_btn_id = f\"vpx-fullscreen-{uid}\"\n   fullscreen_class = \"vpx-fullscreen\"   # scoped under the uid'd root\n   ```\n2. Include the full-screen CSS in your `\u003Cstyle>` block, pointing at the root, the\n   fullscreen class, the inner container (if any), and the widget's background token:\n   ```python\n   ui_fullscreen_css = fullscreen_css(\n       root_selector, fullscreen_class,\n       container_selector=\".vpx-container\", bg_var=\"var(--vpx-bg)\",\n   )\n   ```\n3. Render the header with `fullscreen_btn_id=` so the button appears next to the theme toggle:\n   ```python\n   header_html = render_header_html(..., theme_btn_id=theme_btn_id,\n                                     fullscreen_btn_id=fullscreen_btn_id)\n   ```\n4. Append the wiring script alongside the theme script, and render through\n   `display_html_widget` (not `display(HTML(...))`). The helper hosts the markup\n   in a lightweight anywidget so it lives in the notebook **webview's light DOM**\n   rather than the nested, sandboxed `srcdoc` iframe used for raw HTML output.\n   That sandbox blocks the native Fullscreen API and collapses fixed overlays;\n   the webview permits real fullscreen, so the toggle expands edge-to-edge just\n   like the anywidget tools. It falls back to `display(HTML(...))` automatically\n   when `anywidget` isn't installed.\n   ```python\n   fullscreen_script = fullscreen_toggle_script(\n       btn_id=fullscreen_btn_id, root_selector=root_selector,\n       fullscreen_class=fullscreen_class,\n   )\n   display_html_widget(styles + html + script + theme_script + fullscreen_script)\n   ```\n\n### anywidget widgets (Perspective Editor \u002F Direct Lake Manager style)\n\n1. Prepend the shared helper to the ESM module and append the full-screen CSS\n   (the root usually carries the card styling itself, so no `container_selector`):\n   ```python\n   _WIDGET_JS = fullscreen_setup_js() + _WIDGET_JS.replace(\n       \"__SLLS_ICON_FULLSCREEN__\", ICONS[\"fullscreen\"]\n   ).replace(\"__SLLS_ICON_FULLSCREEN_EXIT__\", ICONS[\"fullscreen_exit\"])\n   _WIDGET_CSS = _WIDGET_CSS + \"\\n\" + fullscreen_css(\n       \".slls-pe\", \"slls-pe-fullscreen\", bg_var=\"var(--slls-bg-solid)\"\n   )\n   ```\n2. In the JS `render`, create the button next to the theme button and call the helper:\n   ```js\n   const fullscreenBtn = document.createElement(\"button\");\n   fullscreenBtn.className = \"slls-pe-btn slls-pe-btn-icon\";\n   fullscreenBtn.type = \"button\";\n   header.appendChild(fullscreenBtn);\n   sllsSetupFullscreen(root, fullscreenBtn, \"slls-pe-fullscreen\",\n                       `__SLLS_ICON_FULLSCREEN__`, `__SLLS_ICON_FULLSCREEN_EXIT__`);\n   ```\n\n### Reference\n\n- `src\u002Fsempy_labs\u002Fsemantic_model\u002F_test_dax.py` — original full-screen implementation.\n- `src\u002Fsempy_labs\u002Fsemantic_model\u002F_vertipaq_analyzer.py`, `src\u002Fsempy_labs\u002F_delta_analyzer.py` — static-HTML usage.\n- `src\u002Fsempy_labs\u002Fsemantic_model\u002F_perspective_editor.py`, `src\u002Fsempy_labs\u002Fsemantic_model\u002F_direct_lake_manager.py` — anywidget usage.\n\n---\n\n## Public API Conventions for Interactive Tools\n\nAll interactive UI functions follow the same Python signature conventions as the rest of the library (see the [Add Function](..\u002Fadd-function\u002FSKILL.md) skill), with these additions:\n\n- Apply the `@log` decorator and write a numpydoc docstring.\n- Accept a `dark_mode: bool = False` parameter so users can opt into dark on first render. Document it.\n- Accept the standard `workspace: Optional[str | UUID] = None` parameter and resolve it via `resolve_workspace_name_and_id`.\n- For functions that operate on a semantic model, accept `dataset: str | UUID` and use `connect_semantic_model` (read-only when the UI is view-only, read-write only when it actually needs to mutate the model).\n- The function's job is to *display* the widget, not return it. Do not return the widget object (it causes double-rendering in Jupyter).\n\n---\n\n## Checklist for a New Interactive UI\n\n- [ ] Picked the correct pattern: static-HTML if no Python callbacks are needed, anywidget if they are.\n- [ ] All icons come from `sempy_labs._ui_components.ICONS` (no inlined one-off SVGs). For anywidget tools, icons are injected into `_WIDGET_JS` via `__SLLS_ICON_*__` placeholder substitution at module-import time.\n- [ ] All colors come from `LIGHT_THEME_VARS` \u002F `DARK_THEME_VARS` (no hard-coded hex values).\n- [ ] Standard header rendered via `render_header_html` (static) or built in JS using the same layout\u002Ftokens (anywidget).\n- [ ] Standard \"Powered by Semantic Link Labs\" attribution rendered at the bottom.\n- [ ] Theme toggle wired via `theme_toggle_script` (static) or via a synced `dark_mode` traitlet (anywidget).\n- [ ] Full-screen toggle wired via `render_header_html(..., fullscreen_btn_id=...)` + `fullscreen_css` + `fullscreen_toggle_script` (static) or `fullscreen_setup_js` + `fullscreen_css` (anywidget).\n- [ ] CSS is scoped under a per-instance `uid` (static) or under a stable namespace class (anywidget) so multiple instances on one page do not collide and notebook host styles do not bleed in.\n- [ ] Apple-inspired font stack and antialiasing are applied to the root.\n- [ ] Public function accepts `dark_mode: bool = False`, resolves workspace, has `@log` + numpydoc docstring, and calls `display(...)` (does not return the widget).\n- [ ] Any genuinely reusable new component was promoted to `_ui_components` rather than duplicated.\n- [ ] For anywidget tools: `anywidget` is imported lazily with a friendly `ImportError`.\n","# UI Styling for Interactive Tools\n\nThis skill describes the styling conventions, shared building blocks, and architectural patterns used by all interactive UI tools in Semantic Link Labs so that every tool has a consistent, elegant design.\n\n## When to Use This Skill\n\nUse this skill when you need to:\n\n- Add a **new interactive UI** function to the library.\n- Modify an existing interactive UI (e.g. `vertipaq_analyzer`, `delta_analyzer`, `perspective_editor`).\n- Add new **shared visual components** (icons, theme variables, headers, etc.) that should be reused across tools.\n- Decide between a **static-HTML** widget and an **anywidget**-based widget.\n\n---\n\n## The Two UI Patterns\n\nSemantic Link Labs has exactly two supported patterns for interactive UI tools. Always pick one based on whether the UI needs to call back into Python after the initial render.\n\n| Pattern | When to use | Reference implementations |\n|---------|-------------|---------------------------|\n| **Static-HTML widget** (the *Vertipaq style*) | The UI is fully driven by the data computed in Python *before* render. All interactivity (filtering, sorting, tab switching, theme toggle, column resizing, etc.) is done in **pure browser-side JavaScript**. No Python code runs after `display(HTML(...))`. | `sempy_labs.semantic_model._vertipaq_analyzer.vertipaq_analyzer`, `sempy_labs._delta_analyzer.delta_analyzer` |\n| **anywidget widget** (the *Perspective Editor style*) | The UI must run Python code in response to user actions (e.g. write back to a semantic model, refresh data from a REST API, perform long-running operations). State is synced between the JS frontend and the Python backend via `traitlets`. | `sempy_labs.semantic_model._perspective_editor.perspective_editor` |\n\n> **Rule of thumb:** if the only thing the user does is view, sort, filter, or switch between pre-computed data, use the **static-HTML** pattern. If they can *change* something that must persist (model edits, refresh triggers, server calls), use **anywidget**.\n\n---\n\n## Shared Building Blocks: `sempy_labs._ui_components`\n\n`src\u002Fsempy_labs\u002F_ui_components.py` is the single source of truth for everything visual that should be consistent across tools. **Both patterns must source their visual primitives from this module.** If you need a new shared visual component (a new icon, a new helper, a new themed control), add it here so every tool can pick it up.\n\n### What lives there today\n\n| Export | Purpose |\n|--------|---------|\n| `ICONS` | Dict of monochrome SVG icons. All use `stroke=\"currentColor\"` \u002F `fill=\"currentColor\"` so they adapt to light and dark themes automatically. Keys include tabular-object icons (`table`, `calculation_group`, `column`, `column_chunk`, `measure`, `hierarchy`, `calculation_item`, `partition`, `relationship`), tree\u002Fnavigation icons (`caret_right`, `folder`, `level`), and UI\u002Faction icons (`sun`, `moon`, `search`, `plus`, `play`, `stop`, `refresh`, `swap`, `sort_asc`, `sort_desc`, `panel_collapse`, `panel_expand`, `builder`, `close`, `fullscreen`, `fullscreen_exit`). |\n| `LIGHT_THEME_VARS`, `DARK_THEME_VARS` | CSS custom-property blocks defining the Apple-inspired light and dark palettes. Always reference colors via these `--ui-*` tokens, never hard-coded hex values. Includes semantic tokens for hover backgrounds (`--ui-bg-hover`), on-accent text (`--ui-on-accent`), and destructive\u002Ferror states (`--ui-danger*`). |\n| `SYNTAX_HIGHLIGHT_VARS` | Theme-independent `--ui-syntax-*` token block for colorizing DAX\u002Fcode in an editor. Inject once into the widget's base scope (it is the same in light and dark). |\n| `HEADER_CSS`, `scoped_header_css(root_selector)` | Standard widget header styles (title + dataset\u002Fworkspace subtitle) **and the four standard header controls** (`.sl-theme-btn`, `.sl-change-btn`, `.sl-reload-btn`). `scoped_header_css` prefixes every rule with the root selector so the styles win against notebook host CSS (e.g. Jupyter's `.jp-RenderedHTMLCommon button`). Every tool must inject this, even when it builds its own header markup. |\n| `render_header_html(title, dataset_name, workspace_name, theme_btn_id, dark_mode, fullscreen_btn_id)` | Renders the standard header markup. Pass `fullscreen_btn_id` to include a full-screen toggle button next to the theme toggle. |\n| `theme_toggle_script(btn_id, root_selector, dark_class)` | Returns a `\u003Cscript>` block that wires the theme toggle button to flip a `dark_class` on the root element and swap the sun\u002Fmoon icon. |\n| `fullscreen_css(root_selector, fullscreen_class, container_selector=None, bg_var)` | Returns the CSS for a widget's full-screen state (covers both the native `:fullscreen` pseudo-class and the `fullscreen_class` CSS-overlay fallback). Pass `container_selector` when an inner element carries the card styling; pass `bg_var` to match the widget's background token. |\n| `fullscreen_toggle_script(btn_id, root_selector, fullscreen_class)` | Returns a `\u003Cscript>` block that wires a full-screen toggle button for **static-HTML** widgets. Pair with `render_header_html(..., fullscreen_btn_id=...)` and `fullscreen_css`. |\n| `fullscreen_setup_js(func_name=\"sllsSetupFullscreen\")` | Returns a JS function definition that wires a full-screen toggle button for **anywidget** widgets. Embed once at the top of the ESM module, then call `func_name(root, btn, fullscreenClass, enterSvg, exitSvg)` after creating the button. |\n| `display_html_widget(html, fallback=True)` | Renders a self-contained HTML string (styles + markup + inline `\u003Cscript>`) via a lightweight anywidget so it lives in the notebook **webview's light DOM** instead of the sandboxed `srcdoc` iframe used for raw `display(HTML)`. Use this for static-HTML widgets so the full-screen toggle gets the native Fullscreen API (matching the anywidget tools). Falls back to `display(HTML(html))` when `anywidget` is unavailable. |\n| `TABLE_COLUMN_RESIZE_JS`, `scoped_table_column_resize_css(root_selector)` | Resizable table columns. Embed the JS in the widget's ESM module and call `sllsInstallColumnResizers(table, { widths, key })` after the table is in the DOM (drag a header border to resize, double-click to fit; pass a persistent `widths` Map so widths survive re-renders). Inject the scoped CSS for the default handle classes. Reference: `lakehouse._lakehouse_manager`. |\n| `ATTRIBUTION_CSS`, `scoped_attribution_css(root_selector)`, `render_attribution_html(extra_links=None)` | \"Powered by Semantic Link Labs\" attribution shown at the bottom of every widget, with an optional list of extra `(label, url)` links. |\n| `SEARCH_SELECT_CSS`, `SEARCH_SELECT_JS` | The standard **searchable single-select** picker (`createSearchSelect({ placeholder, searchPlaceholder, ariaLabel, emptyLabel, onChange })`). Every workspace \u002F semantic model \u002F item picker must use this control — never a plain `\u003Cselect>` — so long lists can always be filtered by typing. Inject the CSS into the widget stylesheet and the JS into the widget's ESM module, then drive the returned controller with `setOptions(items, value)`, `setEmptyLabel(text)` and `setDisabled(flag)`. Reference implementations: `semantic_model._find_unused_objects`, `semantic_model._bpa`. |\n\n### When to extend `_ui_components`\n\nAdd a new export to `_ui_components.py` whenever the same visual element appears (or *should* appear) in more than one tool. Typical candidates: a new icon, a shared button style, a status-pill style, a confirmation-dialog component, a toast\u002Fnotification helper. Do **not** copy-paste CSS or SVGs between widgets — promote them to `_ui_components` instead.\n\n---\n\n## Standard Header Controls (mandatory)\n\nFour controls recur in nearly every tool. They must look and behave identically\neverywhere, so both their icon and their chrome come from `_ui_components` — a\ntool never defines its own size, radius, border or icon for them. The\n`sempy_labs.semantic_model.test` (DAX Perf Optimizer) widget is the reference\nimplementation.\n\n| Control | Class | Icon | Footprint |\n|---------|-------|------|-----------|\n| Light\u002Fdark mode | `sl-theme-btn` | `ICONS[\"sun\"]` \u002F `ICONS[\"moon\"]` | 32×32 circle, 18px icon |\n| Full screen | `sl-theme-btn` | `ICONS[\"fullscreen\"]` \u002F `ICONS[\"fullscreen_exit\"]` | 32×32 circle, 18px icon |\n| Change model \u002F workspace | `sl-change-btn` | `ICONS[\"swap\"]` | 32×32, 8px radius, 18px icon |\n| Reload (workspaces, models, lists) | `sl-reload-btn` | `ICONS[\"refresh\"]` | 32×32 circle, 14px icon |\n\nRules:\n\n- Inject `scoped_header_css(root_selector)` into the widget stylesheet, and use\n  the class names above. Do **not** re-declare `.sl-theme-btn`,\n  `.sl-change-btn` or `.sl-reload-btn` in a tool — `tests\u002Ftest_ui_header_controls.py`\n  fails if a tool restyles them.\n- While a reload is in flight, add `sl-spinning` to the reload button; the\n  shared CSS animates the icon.\n- If the tool uses `--slls-*` (or other) palette names, alias the `--ui-*`\n  tokens the shared CSS reads: `--ui-surface`, `--ui-surface-2`,\n  `--ui-border-strong`, `--ui-text`, `--ui-text-secondary`,\n  `--ui-text-tertiary`, `--ui-accent`, `--ui-accent-soft`.\n- Tools rendering their header with `render_header_html` get these for free via\n  `theme_btn_id`, `fullscreen_btn_id` and `picker_btn_id`. For an extra button\n  that changes the model\u002Fworkspace, pass `\"base\": \"sl-change-btn\"` in\n  `extra_buttons`.\n- Buttons that are *not* one of these four (e.g. expand\u002Fcollapse, delete,\n  tool-specific actions) keep their own tool-scoped classes.\n\n### Workspace \u002F semantic model pickers\n\nAlways resolve the workspace with `resolve_workspace_name_and_id(workspace)`\n**even when the caller passed nothing**, and seed the picker with the result, so\nthe workspace dropdown opens pre-selected on the current workspace. Passing\n`None` resolves to the attached lakehouse's workspace, or the notebook's.\n\n---\n\n## Design Tokens (the visual language)\n\nAll interactive UIs share one visual language. Stick to these tokens — do not introduce one-off colors, fonts, radii, or shadows.\n\n### Typography\n\n- Font stack: `-apple-system, BlinkMacSystemFont, \"SF Pro Display\", \"SF Pro Text\", \"Helvetica Neue\", Helvetica, Arial, sans-serif`.\n- Enable font smoothing: `-webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;`.\n- Title (22px \u002F 600 \u002F `-0.01em` letter-spacing) and subtitle (≈12.5px \u002F `--ui-text-secondary`) are produced by `render_header_html` — do not re-implement them.\n- Use `font-variant-numeric: tabular-nums` for any numeric column or large numeric value.\n\n### Color tokens (from `LIGHT_THEME_VARS` \u002F `DARK_THEME_VARS`)\n\n| Token | Use for |\n|-------|---------|\n| `--ui-bg`, `--ui-bg-secondary`, `--ui-bg-tertiary`, `--ui-bg-solid` | Surfaces, in increasing emphasis levels |\n| `--ui-bg-hover` | Solid hover background for controls\u002Fbuttons whose base is `--ui-bg` |\n| `--ui-surface`, `--ui-surface-2` | Translucent overlays \u002F hover backgrounds |\n| `--ui-border`, `--ui-border-strong` | Subtle and strong borders |\n| `--ui-text`, `--ui-text-secondary`, `--ui-text-tertiary` | Primary, secondary, tertiary text |\n| `--ui-accent`, `--ui-accent-hover`, `--ui-accent-soft` | Brand accent (links, focus rings, active tab indicator, primary buttons, data bars) |\n| `--ui-on-accent` | Text\u002Ficon color placed on top of an `--ui-accent` (or `--ui-danger`) fill — i.e. \"white\" |\n| `--ui-danger`, `--ui-danger-hover` | Destructive button fill + hover (e.g. a Stop button) |\n| `--ui-danger-bg`, `--ui-danger-border`, `--ui-danger-text` | Inline error\u002Falert box background, border, and text (themed for light + dark) |\n| `--ui-shadow-sm`, `--ui-shadow-md`, `--ui-shadow-lg` | Elevation |\n\nNever hard-code `#fff`, red error colors, or any other literal — always go through a token. If a destructive action, error banner, or white-on-accent label is needed, use the danger \u002F on-accent tokens above rather than inlining hex values.\n\n### Code \u002F DAX syntax-highlight palette (`SYNTAX_HIGHLIGHT_VARS`)\n\nFor colorizing DAX (or similar code) inside an editor\u002Fhighlighter, inject the\ntheme-independent `SYNTAX_HIGHLIGHT_VARS` block once into the widget's **base**\nscope (it intentionally renders the same in light and dark, so do not override\nit in the dark block). Reference these `--ui-syntax-*` tokens — never the raw\nhex values.\n\n| Token | Token class it colors |\n|-------|-----------------------|\n| `--ui-syntax-keyword`, `--ui-syntax-function` | Keywords and function names |\n| `--ui-syntax-variable` | Variables |\n| `--ui-syntax-number` | Numeric literals |\n| `--ui-syntax-virtual-column` | Virtual \u002F measure-ref columns |\n| `--ui-syntax-string` | String literals |\n| `--ui-syntax-operator`, `--ui-syntax-punctuation` | Operators and punctuation |\n\nSee `sempy_labs.semantic_model._test_dax.test` for the reference usage (it\ninjects `SYNTAX_HIGHLIGHT_VARS` into its `.dtx` base block alongside\n`LIGHT_THEME_VARS`).\n\nIf a tool needs its own derived names (e.g. `--vpx-text`), alias them to the `--ui-*` tokens inside the tool's scoped block — see `_vertipaq_analyzer.py` for the pattern. This keeps the palette centralized while letting tools use short, local names.\n\n### Shape and motion\n\n- Radii: `12px` (containers), `8px` (controls\u002Fcards) — exposed as `--vpx-radius` \u002F `--vpx-radius-sm` style aliases when needed.\n- Transitions: `0.25s cubic-bezier(0.4, 0, 0.2, 1)` for color\u002Fborder\u002Fbackground; `120ms ease` for small button state changes; `80ms` for press scale.\n- Subtle hover\u002Factive states only — no heavy animations.\n\n---\n\n## Anatomy of a Widget\n\nEvery interactive UI, regardless of pattern, should be composed of these regions in this order:\n\n1. **Root container** with a per-instance unique class (e.g. `vpx-\u003Cuid>`) and an optional dark-mode modifier class (e.g. `vpx-dark`). The unique id (`uid = uuid.uuid4().hex[:8]`) keeps multiple widgets on the same page from colliding.\n2. **Standard header** rendered via `render_header_html(...)` — title + dataset\u002Fworkspace subtitle + theme toggle button.\n3. **Summary cards** (optional) — a horizontal row of `(label, value)` cards summarizing the result set.\n4. **Tab bar** (optional) — for multi-section views; active tab uses `--ui-accent` text + a 2px accent underline.\n5. **Toolbar** (optional) — search box (using `ICONS[\"search\"]`), row count, view toggles (e.g. data-bars on\u002Foff).\n6. **Main content** — table, tree, form, etc.\n7. **Attribution** rendered via `render_attribution_html(...)` at the bottom, with optional `extra_links` for upstream credit (e.g. SQLBI's Vertipaq Analyzer).\n\n---\n\n## Pattern A: Static-HTML Widget (Vertipaq \u002F Delta Analyzer style)\n\nUse this for **read-only \u002F pre-computed** UIs. End-to-end recipe:\n\n### 1. Compute data in Python, then render\n\nBuild the `pandas.DataFrame`(s) or dict of dataframes in Python. Pass them to a private `visualize_*` \u002F `_render_*` helper that assembles HTML and JS strings and calls `IPython.display.display(HTML(...))`.\n\n### 2. Generate a per-instance uid\n\n```python\nuid = uuid.uuid4().hex[:8]\nroot_selector = f\".vpx-{uid}\"            # used for scoping CSS + JS lookups\ntheme_btn_id = f\"vpx-theme-{uid}\"\n```\n\nEvery CSS class, every DOM id, and every global JS function name **must** include `uid` so multiple instances on one notebook page never clash.\n\n### 3. Import the shared building blocks\n\nPull from `sempy_labs._ui_components` — do not re-define icons, colors, headers, theme-toggle JS, or the attribution footer.\n\n```python\nfrom sempy_labs._ui_components import (\n    ICONS as _UI_ICONS,\n    LIGHT_THEME_VARS as _UI_LIGHT_VARS,\n    DARK_THEME_VARS as _UI_DARK_VARS,\n    scoped_header_css as _ui_scoped_header_css,\n    scoped_attribution_css as _ui_scoped_attribution_css,\n    render_header_html as _ui_render_header_html,\n    render_attribution_html as _ui_render_attribution_html,\n    theme_toggle_script as _ui_theme_toggle_script,\n)\n```\n\n### 4. Scope all CSS under the root selector\n\nInline the light palette inside `.vpx-\u003Cuid> { ... }` and the dark palette inside `.vpx-\u003Cuid>.vpx-dark { ... }`, so dark mode is a class toggle on the root. Include `_ui_scoped_header_css(root_selector)` and `_ui_scoped_attribution_css(root_selector)` in your `\u003Cstyle>` block. Scoping is required so that high-specificity notebook host styles (Jupyter, VS Code, Fabric) do not override your widget.\n\n### 5. Build the markup in order: header → cards → tabs → toolbar → content → attribution\n\nUse `render_header_html(...)` for the header and `render_attribution_html(...)` for the footer. Re-use icons from `_UI_ICONS` (apply your own class via `.replace(\"\u003Csvg \", '\u003Csvg class=\"vpx-tab-icon\" ', 1)` for sizing).\n\n### 6. Wire all interactivity in inline JavaScript\n\nFilter\u002Fsort\u002Fresize\u002Ftab-switch\u002Fbar-toggle logic lives in a `\u003Cscript>` block whose function names are also uid-suffixed (e.g. `window.vpxSort_\u003Cuid>`). The theme toggle button is wired by appending `_ui_theme_toggle_script(btn_id=theme_btn_id, root_selector=root_selector, dark_class=\"vpx-dark\")`.\n\n### 7. Render\n\n```python\ndisplay(HTML(styles + \"\\n\".join(html_parts) + script + theme_script))\n```\n\n### Reference\n\n- `src\u002Fsempy_labs\u002Fsemantic_model\u002F_vertipaq_analyzer.py` — `visualize_vertipaq` (full implementation: cards, tabs, toolbar, sortable\u002Ffilterable\u002Fresizable table with optional data bars).\n- `src\u002Fsempy_labs\u002F_delta_analyzer.py` — same pattern applied to delta-table analysis output.\n\n---\n\n## Pattern B: anywidget Widget (Perspective Editor style)\n\nUse this when the UI must call back into Python after render (e.g. to edit a semantic model, trigger a refresh, run an API call). The widget is implemented as a subclass of `anywidget.AnyWidget` with state synced via `traitlets`.\n\n### 1. Guard the optional dependency\n\n`anywidget` is **not** a hard dependency of the library — keep it that way. Import lazily inside the public function and raise a friendly `ImportError` if missing:\n\n```python\ntry:\n    import anywidget\n    import traitlets\nexcept ImportError as e:\n    raise ImportError(\n        \"The '\u003Cmy_tool>' function requires the 'anywidget' package. \"\n        \"Install it with: pip install anywidget\"\n    ) from e\n```\n\n### 2. Subclass `anywidget.AnyWidget`\n\nDefine the widget with class attributes `_esm` (the JS module string — typically a top-level `function render({ model, el }) { ... }` block) and `_css` (the CSS string). Declare every piece of state that must cross the Python\u002FJS boundary as a synced traitlet:\n\n```python\nclass MyWidget(anywidget.AnyWidget):\n    _esm = _WIDGET_JS\n    _css = _WIDGET_CSS\n\n    data = traitlets.Dict().tag(sync=True)\n    selected = traitlets.Unicode(\"\").tag(sync=True)\n    status = traitlets.Dict().tag(sync=True)         # { \"message\": ..., \"kind\": \"success\"|\"error\" }\n    pending_action = traitlets.Dict().tag(sync=True) # what JS asked Python to do\n    run = traitlets.Int(0).tag(sync=True)            # bump to trigger the Python callback\n    dataset_name = traitlets.Unicode(\"\").tag(sync=True)\n    workspace_name = traitlets.Unicode(\"\").tag(sync=True)\n    dark_mode = traitlets.Bool(False).tag(sync=True)\n```\n\n### 3. Use the \"bump `run` + observe\" callback pattern\n\nJS triggers Python work by setting `pending_action` (a dict describing what to do) and then incrementing `run` and calling `model.save_changes()`. Python observes `run` and dispatches based on `pending_action[\"action\"]`. On completion it writes results back to other traitlets (including a user-visible `status`) which the JS observer renders.\n\n```python\ndef _on_run(change):\n    data = dict(widget.pending_action or {})\n    action = data.get(\"action\")\n    if not action:\n        return\n    try:\n        ...  # do Python work, then update widget.status \u002F other traitlets\n    except Exception as e:\n        widget.status = {\"message\": f\"Error: {e}\", \"kind\": \"error\"}\n\nwidget.observe(_on_run, names=[\"run\"])\n```\n\n### 4. Display once, keep the reference alive\n\nAfter `display(widget)`, keep the local `widget` reference inside the closure (Python's GC must not collect it, or observers stop firing). **Do not also `return widget`** — that causes Jupyter to render it a second time.\n\n### 5. Visual conventions on the JS side\n\nThe frontend `render({ model, el })` function should:\n\n- Create a root `\u003Cdiv>` with a stable namespace class (e.g. `slls-pe` for the perspective editor). Add `slls-pe-dark` when `dark_mode === true` and `slls-pe-auto` (which uses `@media (prefers-color-scheme: dark)`) when `dark_mode` is null\u002Fundefined.\n- Build the header with the same title + dataset\u002Fworkspace subtitle + sun\u002Fmoon theme-toggle button shape used by the static widgets. The theme button toggles the `dark_mode` traitlet (`model.set(\"dark_mode\", ...); model.save_changes();`) so the preference round-trips to Python.\n- Use the **same color\u002Ftypography\u002Fradius tokens** as `_ui_components` (light + dark palettes, Apple font stack, 12px \u002F 8px radii). When you need an icon also used elsewhere, embed the SVG from `ICONS` (e.g. via a Python-side template-substitution placeholder like `__SLLS_ICON_TABLE__`) so there is one source of truth.\n- Always render the \"Powered by Semantic Link Labs\" attribution at the bottom via the shared component — never hand-write the markup or its CSS. Insert it with a placeholder (e.g. `root.insertAdjacentHTML(\"beforeend\", \\`__SLLS_ATTRIBUTION__\\`)`), substitute `render_attribution_html()` for it at import time, and add `scoped_attribution_css(root_selector)` to the widget CSS. The shared CSS reads `--ui-text-tertiary` and `--ui-accent`, so alias them if the tool uses its own palette names. `tests\u002Ftest_ui_attribution.py` fails if a tool writes its own attribution.\n\n> If you need a new visual primitive in an anywidget tool (a new icon, a new button style, a new theme token), add it to `_ui_components` and substitute it into the `_WIDGET_JS`\u002F`_WIDGET_CSS` strings — do not fork the design.\n\n### Reference\n\n- `src\u002Fsempy_labs\u002Fsemantic_model\u002F_perspective_editor.py` — `perspective_editor`. Full implementation showing widget class definition, traitlets, the `pending_action` + `run` callback pattern, dark-mode round-trip, and lazy-import guard.\n- `src\u002Fsempy_labs\u002Fsemantic_model\u002F_direct_lake_manager.py` — `direct_lake_manager`. Multi-screen anywidget with model-selection \u002F model-management screens, popover menus, modals, pending-change tracking, and a save bar. Demonstrates icon-template-substitution from `_ui_components.ICONS`.\n\n### 6. Icon template-substitution recipe (anywidget)\n\nBecause `_WIDGET_JS` is a raw string passed to anywidget's `_esm`, you cannot directly call Python at JS render time. To keep icons centralized in `_ui_components.ICONS`, use **placeholder substitution at module-import time**:\n\n1. In `_WIDGET_JS`, refer to icons through uppercase placeholders, e.g.:\n\n    ```javascript\n    const SUN_SVG = `__SLLS_ICON_SUN__`;\n    const ICON_SVG = {\n        table: `__SLLS_ICON_TABLE__`,\n        column: `__SLLS_ICON_COLUMN__`,\n        \u002F\u002F ...\n    };\n    ```\n\n2. Immediately after `_WIDGET_JS = r\"\"\"...\"\"\"\"`, substitute each placeholder from `ICONS`:\n\n    ```python\n    from sempy_labs._ui_components import ICONS as _UI_ICONS\n\n    _WIDGET_JS = (\n        _WIDGET_JS\n        .replace(\"__SLLS_ICON_SUN__\", _UI_ICONS[\"sun\"])\n        .replace(\"__SLLS_ICON_MOON__\", _UI_ICONS[\"moon\"])\n        .replace(\"__SLLS_ICON_TABLE__\", _UI_ICONS[\"table\"])\n        .replace(\"__SLLS_ICON_COLUMN__\", _UI_ICONS[\"column\"])\n        # ...one .replace per icon used\n    )\n    ```\n\nDo **not** inline raw SVG strings inside `_WIDGET_JS`. If you need an icon that isn't in `ICONS` yet, add it to `_ui_components.ICONS` first, then substitute it in.\n\n### 7. Minimal anywidget template\n\n```python\nfrom typing import Optional\nfrom uuid import UUID\nfrom sempy._utils._log import log\n\n_WIDGET_CSS = \"\"\"\n.my-widget { \u002F* root container styles, using --ui-* tokens *\u002F }\n.my-widget.my-widget-dark { \u002F* DARK_THEME_VARS-equivalent overrides *\u002F }\n\"\"\"\n\n_WIDGET_JS = r\"\"\"\nfunction render({ model, el }) {\n    const root = document.createElement(\"div\");\n    root.className = \"my-widget\";\n\n    function applyTheme() {\n        root.classList.remove(\"my-widget-dark\", \"my-widget-auto\");\n        const dm = model.get(\"dark_mode\");\n        if (dm === true) root.classList.add(\"my-widget-dark\");\n        else if (dm == null) root.classList.add(\"my-widget-auto\");\n    }\n    applyTheme();\n    model.on(\"change:dark_mode\", applyTheme);\n    el.appendChild(root);\n\n    const SUN = `__SLLS_ICON_SUN__`;\n    const MOON = `__SLLS_ICON_MOON__`;\n\n    \u002F\u002F ... build header, body, attribution ...\n\n    \u002F\u002F Trigger a Python action:\n    function runAction(payload) {\n        model.set(\"pending_action\", payload);\n        model.set(\"run\", model.get(\"run\") + 1);\n        model.save_changes();\n    }\n}\nexport default { render };\n\"\"\"\n\nfrom sempy_labs._ui_components import ICONS as _UI_ICONS  # noqa: E402\n\n_WIDGET_JS = (\n    _WIDGET_JS\n    .replace(\"__SLLS_ICON_SUN__\", _UI_ICONS[\"sun\"])\n    .replace(\"__SLLS_ICON_MOON__\", _UI_ICONS[\"moon\"])\n)\n\n\n@log\ndef my_widget_function(\n    dataset: str | UUID,\n    workspace: Optional[str | UUID] = None,\n    dark_mode: bool = False,\n):\n    \"\"\"One-line description.\n\n    Parameters\n    ----------\n    dataset : str | uuid.UUID\n        ...\n    workspace : str | uuid.UUID, default=None\n        The Fabric workspace name or ID. Defaults to the attached lakehouse\n        workspace or the notebook workspace.\n    dark_mode : bool, default=False\n        If True, renders with a dark color theme.\n    \"\"\"\n    try:\n        import anywidget\n        import traitlets\n    except ImportError as e:\n        raise ImportError(\n            \"The 'my_widget_function' function requires the 'anywidget' \"\n            \"package. Install it with: pip install anywidget\"\n        ) from e\n\n    from IPython.display import display\n    from sempy_labs._helper_functions import (\n        resolve_workspace_name_and_id,\n        resolve_dataset_name_and_id,\n    )\n\n    ws_name, ws_id = resolve_workspace_name_and_id(workspace)\n    ds_name, ds_id = resolve_dataset_name_and_id(dataset, ws_id)\n\n    class _Widget(anywidget.AnyWidget):\n        _esm = _WIDGET_JS\n        _css = _WIDGET_CSS\n        dataset_name = traitlets.Unicode(\"\").tag(sync=True)\n        workspace_name = traitlets.Unicode(\"\").tag(sync=True)\n        dark_mode = traitlets.Bool(False).tag(sync=True)\n        status = traitlets.Dict().tag(sync=True)\n        pending_action = traitlets.Dict().tag(sync=True)\n        run = traitlets.Int(0).tag(sync=True)\n\n    widget = _Widget(\n        dataset_name=ds_name,\n        workspace_name=ws_name or \"\",\n        dark_mode=bool(dark_mode),\n    )\n\n    def _on_run(_change):\n        action = (widget.pending_action or {}).get(\"action\")\n        if not action:\n            return\n        try:\n            # ... dispatch on action, mutate traitlets ...\n            widget.status = {\"message\": \"Done.\", \"kind\": \"success\"}\n        except Exception as e:\n            widget.status = {\"message\": f\"Error: {e}\", \"kind\": \"error\"}\n\n    widget.observe(_on_run, names=[\"run\"])\n    display(widget)  # do NOT return widget\n```\n\n---\n\n## The Full-Screen Toggle\n\nEvery interactive widget should offer a **full-screen button** in its header\n(next to the theme toggle) that expands the tool to fill the screen and toggles\nback. The behavior is centralized in `sempy_labs._ui_components` so all widgets\nstay in sync — never re-implement it.\n\nThe toggle is host-aware because notebook hosts constrain what \"full screen\" can\nmean. The native [Fullscreen API](https:\u002F\u002Fdeveloper.mozilla.org\u002Fdocs\u002FWeb\u002FAPI\u002FFullscreen_API)\nonly works for an element in the top-level document or in an `\u003Ciframe>` carrying\n`allowfullscreen`. Notebook output **webviews** (where `anywidget` content and\nanything rendered via `display_html_widget` live) permit it, so the toggle gets\ntrue edge-to-edge fullscreen there. By contrast, raw `display(HTML(...))` with a\n`\u003Cscript>` is isolated in a nested, **sandboxed `srcdoc` iframe without\n`allowfullscreen`**, where `requestFullscreen()` is rejected and a `position:\nfixed` overlay collapses the content-sized iframe into an unreadable strip. This\nis exactly why static-HTML widgets should render via `display_html_widget`\n(see below) rather than `display(HTML(...))`.\n\nThe shared logic in `_FULLSCREEN_BODY` is a faithful port of the reference\nimplementation in `sempy_labs.semantic_model._test_dax.test`, and is intentionally\nsimple — two states:\n\n1. **Native fullscreen** — try `root.requestFullscreen()`. This gives true\n   edge-to-edge fullscreen, and the native `:fullscreen` CSS rules style it. This\n   is the normal path for every tool, since they all render in the webview\n   (anywidget content directly, static-HTML widgets via `display_html_widget`).\n2. **CSS-overlay fallback** — if `requestFullscreen()` rejects or is unavailable,\n   apply the `fullscreenClass` fixed overlay (`position: fixed; inset: 0`), which\n   fills the viewport. This only matters in degraded hosts (e.g. the\n   `display(HTML(...))` fallback when `anywidget` isn't installed).\n\nThe button stays in sync when the user leaves native full screen via the `Esc`\nkey (a `fullscreenchange` listener re-renders it). The button icon swaps between\n`ICONS[\"fullscreen\"]` (enter) and `ICONS[\"fullscreen_exit\"]` (exit). The behavior\nis exposed via `fullscreen_setup_js` (anywidget) \u002F `fullscreen_toggle_script`\n(static HTML) — never re-implement it.\n\n### Static-HTML widgets (Vertipaq \u002F Delta style)\n\n1. Allocate a button id and a fullscreen class alongside the other per-instance ids:\n   ```python\n   fullscreen_btn_id = f\"vpx-fullscreen-{uid}\"\n   fullscreen_class = \"vpx-fullscreen\"   # scoped under the uid'd root\n   ```\n2. Include the full-screen CSS in your `\u003Cstyle>` block, pointing at the root, the\n   fullscreen class, the inner container (if any), and the widget's background token:\n   ```python\n   ui_fullscreen_css = fullscreen_css(\n       root_selector, fullscreen_class,\n       container_selector=\".vpx-container\", bg_var=\"var(--vpx-bg)\",\n   )\n   ```\n3. Render the header with `fullscreen_btn_id=` so the button appears next to the theme toggle:\n   ```python\n   header_html = render_header_html(..., theme_btn_id=theme_btn_id,\n                                     fullscreen_btn_id=fullscreen_btn_id)\n   ```\n4. Append the wiring script alongside the theme script, and render through\n   `display_html_widget` (not `display(HTML(...))`). The helper hosts the markup\n   in a lightweight anywidget so it lives in the notebook **webview's light DOM**\n   rather than the nested, sandboxed `srcdoc` iframe used for raw HTML output.\n   That sandbox blocks the native Fullscreen API and collapses fixed overlays;\n   the webview permits real fullscreen, so the toggle expands edge-to-edge just\n   like the anywidget tools. It falls back to `display(HTML(...))` automatically\n   when `anywidget` isn't installed.\n   ```python\n   fullscreen_script = fullscreen_toggle_script(\n       btn_id=fullscreen_btn_id, root_selector=root_selector,\n       fullscreen_class=fullscreen_class,\n   )\n   display_html_widget(styles + html + script + theme_script + fullscreen_script)\n   ```\n\n### anywidget widgets (Perspective Editor \u002F Direct Lake Manager style)\n\n1. Prepend the shared helper to the ESM module and append the full-screen CSS\n   (the root usually carries the card styling itself, so no `container_selector`):\n   ```python\n   _WIDGET_JS = fullscreen_setup_js() + _WIDGET_JS.replace(\n       \"__SLLS_ICON_FULLSCREEN__\", ICONS[\"fullscreen\"]\n   ).replace(\"__SLLS_ICON_FULLSCREEN_EXIT__\", ICONS[\"fullscreen_exit\"])\n   _WIDGET_CSS = _WIDGET_CSS + \"\\n\" + fullscreen_css(\n       \".slls-pe\", \"slls-pe-fullscreen\", bg_var=\"var(--slls-bg-solid)\"\n   )\n   ```\n2. In the JS `render`, create the button next to the theme button and call the helper:\n   ```js\n   const fullscreenBtn = document.createElement(\"button\");\n   fullscreenBtn.className = \"slls-pe-btn slls-pe-btn-icon\";\n   fullscreenBtn.type = \"button\";\n   header.appendChild(fullscreenBtn);\n   sllsSetupFullscreen(root, fullscreenBtn, \"slls-pe-fullscreen\",\n                       `__SLLS_ICON_FULLSCREEN__`, `__SLLS_ICON_FULLSCREEN_EXIT__`);\n   ```\n\n### Reference\n\n- `src\u002Fsempy_labs\u002Fsemantic_model\u002F_test_dax.py` — original full-screen implementation.\n- `src\u002Fsempy_labs\u002Fsemantic_model\u002F_vertipaq_analyzer.py`, `src\u002Fsempy_labs\u002F_delta_analyzer.py` — static-HTML usage.\n- `src\u002Fsempy_labs\u002Fsemantic_model\u002F_perspective_editor.py`, `src\u002Fsempy_labs\u002Fsemantic_model\u002F_direct_lake_manager.py` — anywidget usage.\n\n---\n\n## Public API Conventions for Interactive Tools\n\nAll interactive UI functions follow the same Python signature conventions as the rest of the library (see the [Add Function](..\u002Fadd-function\u002FSKILL.md) skill), with these additions:\n\n- Apply the `@log` decorator and write a numpydoc docstring.\n- Accept a `dark_mode: bool = False` parameter so users can opt into dark on first render. Document it.\n- Accept the standard `workspace: Optional[str | UUID] = None` parameter and resolve it via `resolve_workspace_name_and_id`.\n- For functions that operate on a semantic model, accept `dataset: str | UUID` and use `connect_semantic_model` (read-only when the UI is view-only, read-write only when it actually needs to mutate the model).\n- The function's job is to *display* the widget, not return it. Do not return the widget object (it causes double-rendering in Jupyter).\n\n---\n\n## Checklist for a New Interactive UI\n\n- [ ] Picked the correct pattern: static-HTML if no Python callbacks are needed, anywidget if they are.\n- [ ] All icons come from `sempy_labs._ui_components.ICONS` (no inlined one-off SVGs). For anywidget tools, icons are injected into `_WIDGET_JS` via `__SLLS_ICON_*__` placeholder substitution at module-import time.\n- [ ] All colors come from `LIGHT_THEME_VARS` \u002F `DARK_THEME_VARS` (no hard-coded hex values).\n- [ ] Standard header rendered via `render_header_html` (static) or built in JS using the same layout\u002Ftokens (anywidget).\n- [ ] Standard \"Powered by Semantic Link Labs\" attribution rendered at the bottom.\n- [ ] Theme toggle wired via `theme_toggle_script` (static) or via a synced `dark_mode` traitlet (anywidget).\n- [ ] Full-screen toggle wired via `render_header_html(..., fullscreen_btn_id=...)` + `fullscreen_css` + `fullscreen_toggle_script` (static) or `fullscreen_setup_js` + `fullscreen_css` (anywidget).\n- [ ] CSS is scoped under a per-instance `uid` (static) or under a stable namespace class (anywidget) so multiple instances on one page do not collide and notebook host styles do not bleed in.\n- [ ] Apple-inspired font stack and antialiasing are applied to the root.\n- [ ] Public function accepts `dark_mode: bool = False`, resolves workspace, has `@log` + numpydoc docstring, and calls `display(...)` (does not return the widget).\n- [ ] Any genuinely reusable new component was promoted to `_ui_components` rather than duplicated.\n- [ ] For anywidget tools: `anywidget` is imported lazily with a friendly `ImportError`.\n",{"name":5,"description":7},"main","2ddf46109c1209ceffa88149f4631e7b2275f9a1",".claude\u002Fskills\u002Fui-styling",204,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fsemantic-link-labs","https:\u002F\u002Fgithub.com\u002Fmicrosoft","https:\u002F\u002Fopensource.microsoft.com","Open source projects and samples from Microsoft","2026-11-13 04:54:42",{"source":8,"skillName":5,"commands":67,"prompt":77,"zipAvailable":78},[68,71,74],{"tool":69,"command":70},"npx","npx skills add microsoft\u002Fsemantic-link-labs --skill ui-styling",{"tool":72,"command":73},"bunx","bunx skills add microsoft\u002Fsemantic-link-labs --skill ui-styling",{"tool":75,"command":76},"pnpm","pnpm dlx skills add microsoft\u002Fsemantic-link-labs --skill ui-styling","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fsemantic-link-labs\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fui-styling\u002FSKILL.md",true,[],[81,106,123,140,154,175],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":96,"publishedAt":52},"01M699GKE0WWT6YVHBS06KM8AH","write-tests","Guide for writing unit tests. Use this when creating tests to verify Python logic.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fsemantic-link-labs\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fwrite-tests\u002FSKILL.md",[87,90,93],{"categoryNo":88,"categoryName":89,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量",{"categoryNo":91,"categoryName":92,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":94,"categoryName":95,"taxonomyType":29,"taxonomyTypeDesc":30},"01JBSEEDCAT000000000000036","内容创作者",[97,98,99,38,100,35,101,47,102,103,48,104,105],"write","write tests","tests","unit","logic","writing","python","verify","unit tests",{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":52},"01M699GEZ3YRK8PCPVZF4NEEWF","tom-operations","Guide for working with the TOM (Tabular Object Model) wrapper. Use this when modifying semantic models programmatically.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fsemantic-link-labs\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Ftom-operations\u002FSKILL.md",[],[113,114,47,48,115,116,117,118,119,120,121,38,122,35],"tom operations","operations","model","semantic models","models","Wrapper","semantic","with","object","tabular",{"skillNo":124,"name":125,"nameZh":6,"description":126,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":127,"categories":128,"keywords":135,"publishedAt":52},"01M699GCWWBZM2XFNW5PTGRFJP","sql_to_dax","Guide for translating SQL aggregation expressions into DAX measures.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fsemantic-link-labs\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fsql_to_dax\u002FSKILL.md",[129,132],{"categoryNo":130,"categoryName":131,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口",{"categoryNo":133,"categoryName":134,"taxonomyType":29,"taxonomyTypeDesc":30},"01JBSEEDCAT000000000000033","数据分析师",[136,137,138,38,48,139],"sql","sql to dax","dax","aggregation",{"skillNo":141,"name":142,"nameZh":6,"description":143,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":144,"categories":145,"keywords":146,"publishedAt":52},"01M699GAY10VVK66E4QGT94A93","run-tests","Guide for running pytest tests locally. Use this when running tests to verify code changes.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fsemantic-link-labs\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frun-tests\u002FSKILL.md",[],[99,147,148,149,150,151,104,48,47,152,38,153,35],"run","run tests","running","code","running tests","pytest","changes",{"skillNo":155,"name":156,"nameZh":6,"description":157,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":158,"categories":159,"keywords":164,"publishedAt":52},"01M699G8V718EXYE8BR7NX734G","rest-api-patterns","Guide for implementing REST API wrapper functions. Use this when adding new API wrappers or troubleshooting API calls.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fsemantic-link-labs\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frest-api-patterns\u002FSKILL.md",[160,161],{"categoryNo":130,"categoryName":131,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":162,"categoryName":163,"taxonomyType":29,"taxonomyTypeDesc":30},"01JBSEEDCAT000000000000030","开发工程师",[165,166,167,168,169,170,118,171,48,47,172,173,174,38,35],"rest api","patterns","api","api patterns","REST","rest api patterns","troubleshooting","functions","calls","implementing",{"skillNo":176,"name":177,"nameZh":6,"description":178,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":179,"categories":180,"keywords":181,"publishedAt":52},"01M699G6XY1WTG7ESA1Y7YYCKT","query-builder-dax","Guide for the DAX query shape produced by the Query Builder in the DAX test widget. Use this when modifying how the Query Builder generates DAX, or when generating an EVALUATE query from columns, measures, filters and sorting.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fsemantic-link-labs\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fquery-builder-dax\u002FSKILL.md",[],[138,182,183,184,185,186,187,48,47,188,189,190,191,192,38,193,35],"builder","query builder dax","query builder","query","test","how","shape","filters","widget","columns","sorting","evaluate"]