Skip to content

Give a plain HTML host the portable widgets' look #4797

Closed

Description

@max-sixty

What happens

Five display widgets now run on a plain HTML page (lf-chart, lf-code, lf-diagram, lf-motion, lf-timeline; #4542, #4574, #4611, #4616, #4626): a host maps /runtime/ and /vendor/ with an import map and loads a widget's module. Their look doesn't come with them. Their package stylesheets (packages/default/styles/chart.css and code.css, and defaults.css in the diagram, motion and timeline packages, 628 lines together) are loaded only by a Leaf page's layer, and they read 24 theme properties defined in browser/base.css, such as --ink, --paper, --muted, --accent, --sans and the --sp-* spacing, plus --lf-ground and --lf-line.

So on a plain page a widget draws with the browser's defaults, and the host has to size some widgets itself: tests/smoke/test_plain_page.py holds the chart's box and reserves the diagram's room, which Leaf's stylesheet does on a Leaf page.

Ways to give a host the look

  • A stylesheet a host links. Leaf publishes the theme's properties and each portable package's stylesheet as files a host loads with a <link>, beside the import map. A host restyles by overriding the properties.
  • Defaults inside each rule. Each package stylesheet writes a fallback for every property it reads, as in var(--ink, CanvasText), so it draws legibly with no theme at all; a host still has to load the package stylesheet.
  • Styles inside the widget. A widget adopts its stylesheet into its own shadow root, so it brings its look wherever it loads. That moves the five widgets from light DOM to shadow DOM, which changes how a page's own CSS and Leaf's comments, find and copy reach their words.

The first keeps one home for each rule and needs no change to the widgets; the third is the only one that needs no work from the host.

Part of #3833.

This was written by Claude Code on behalf of max-sixty

Activity

  1. added
    enhancement
    on Oct 31, 2026
  2. leaf-agent commented on Oct 31, 2026

    @leaf-agent
    Collaborator

    The linked-stylesheet approach needs a boundary below Leaf's page theme: widget defaults plus the properties they consume, without the page shell. Loading all of browser/base.css would also bring its unconditional body rules, including position: static !important and container: lf-shell / inline-size, into the host app.

    There is also a sizing dependency beyond the package stylesheets: browser/layouts.css reserves declared heights under html[data-lf-interactive]. A portable stylesheet would need to cover widget sizing without requiring that Leaf runtime marker. The existing plain-page test is the place to exercise that boundary and replace the host's widget-specific sizing workarounds.

    I’m treating this as an open design proposal rather than selecting one of the three delivery models in triage. My recommendation is the explicit stylesheet route, sharing the declarations used by Leaf pages; the remaining maintainer decision is whether an explicit host stylesheet is acceptable or importing a widget must bring its styles automatically. No implementation PR opened.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions