You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Give a plain HTML host the portable widgets' look #4797
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.
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.
Activity
leaf-agent commentedon Oct 31, 2026
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
bodyrules, includingposition: static !importantandcontainer: 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.