Skip to content

h()

Create an element by tag name. Use h() for web components, SVG, custom tags, or any element not covered by the named element functions (div(), button(), etc.).

function h(
tag: string,
props?: Props,
...children: Child[]
): WhisqNode
ParamTypeDescription
tagstringTag name ("div", "my-component", "circle")
propsPropsOptional props object — same shape as named elements
childrenChild[]Child nodes, strings, or reactive getters
import { h, signal } from "@whisq/core";
// Web component
h("color-picker", {
value: () => selectedColor.value,
onchange: (e) => (selectedColor.value = e.target.value),
});
// SVG
h("svg", { viewBox: "0 0 24 24", width: "24", height: "24" },
h("circle", { cx: "12", cy: "12", r: "10", fill: "currentColor" }),
);
// Dynamic tag name
const tagName = "section";
h(tagName, { class: "card" }, "Hello");

See Custom Elements for web-component, SVG, and wrapper patterns.