[]previous and next page

h

Creates an element.

Creates an element. h("div", { style: { display: "flex" } }, "Hello") is the same as <div style=...>Hello</div>.

Import#

ts
import { h } from "@shadow-js/dusk";

Signature#

ts
function h(
  type: string | OgComponent,
  props: Readonly<Record<string, unknown>> | null = null,
  ...children: readonly OgNode[]
): OgElement

Parameters#

Name Description
type A lower-case tag name, or a function component.
props The props (style and any others).
children The children (strings, numbers, elements, arrays).

Returns#

The element.

Throws#

  • TypeError for a tag name satori cannot draw.

Examples#

ts
h("div", { style: { display: "flex", fontSize: 48 } }, "Example");