Change presentation reactively without replacing the styled DOM node.
A styled definition can be shared across instances. Its dynamic values and active theme belong to a render/session. This separation keeps reusable style rules from becoming a process-global theme toggle for every learner.
Use inherited native or callable styles for common surfaces. CSS variables carry reactive values through those rules; named themes provide a coherent set of tokens. Literal property lists avoid raw CSS braces in t-strings.
Understand the moving parts
The preview below uses the course's own shared theme definitions, while its spacing is local to this demo. A theme switch updates computed appearance; it should not remount the input or discard its draft.
Empty dynamic variable values remove the local override, allowing the declared fallback to apply. css() is for validated flat snapshot CSS text; it is not an unrestricted live stylesheet or a way to execute submitted source.
spacing starts at 16px and supplies --preview-space; Change spacing toggles it to 8px. The theme button switches the named light/dark themes. Both updates retain the input and its draft. The course uses its full shared palette; this standalone version keeps the same paper/ink tokens and native controls.
Try it live
Change spacing and switch theme. Type into the preview before another theme switch.
What to observe
Computed spacing/colors change while the preview input and its draft remain intact.
Take this with you
Share definitions; keep dynamic themes and values scoped to the learner.