CSS and SVG
Use the CSS cascade
Section titled “Use the CSS cascade”Load a stylesheet with <link rel="stylesheet" href="./styles.css"> in a plain HTML page. The elements returned by Mini Reactive participate in the usual cascade, including custom properties, media queries, and focus styles.
Use class: "card" for a class string. Use a map for independently reactive class tokens, with each value a boolean, signal, or function. Use CSS property names such as "border-color" and "--accent" in style. Inline style values are strings with explicit units. Setting a style value to null removes that property.
const active = signal(false);const color = signal<string | null>("#137455");
mount(root, () => section( { class: { card: true, highlighted: active }, style: { "--accent": color, "border-width": "2px" }, }, "Profile", ),);.card { border: solid var(--accent, #64756c);}
.card.highlighted { background: color-mix(in srgb, var(--accent, #64756c) 14%, transparent);}Use @scope to limit stylesheet selectors. To isolate a widget’s styles, attach a shadow root and pass it to mount. Put the widget’s styles inside the same shadow root.
Draw SVG with the typed builders
Section titled “Draw SVG with the typed builders”Import builders from min-reactive-framework/svg. They create elements in the SVG namespace and preserve attribute spelling such as viewBox. A foreignObject can contain elements from /html.
Loading the example…
View source
import { mount, signal } from "min-reactive-framework";import type { Dispose } from "min-reactive-framework";import { button, div, p } from "min-reactive-framework/html";import { circle, svg } from "min-reactive-framework/svg";import type { DemoLanguage } from "../example-language.js";
export function run(target: HTMLElement, lang: DemoLanguage): Dispose { const ru = lang === "ru"; const active = signal(false); const fill = () => (active.value ? "#13825d" : "#747f80");
return mount(target, () => div( { class: "mr-demo-stack" }, button( { type: "button", "aria-pressed": active, on: { click: () => { active.value = !active.value; }, }, }, ru ? "Сменить оформление" : "Toggle styling", ), div( { class: { "mr-demo-panel": true, "mr-styled-active": active }, style: { "--sample-fill": fill, "border-color": fill }, }, svg( { viewBox: "0 0 24 24", width: 24, height: 24, "aria-hidden": true, }, circle({ cx: 12, cy: 12, r: 8, fill }), ), p(() => active.value ? ru ? "Активное состояние" : "Active state" : ru ? "Обычное состояние" : "Default state", ), ), ), );}The tag reference lists HTML and SVG exports, attributes, and naming exceptions.