Reference

Element

A custom element a script defines, placed by its tag: Element("stripe-pricing-table", publishableKey: key) { on ready { … } }. Every named argument is an attribute, every on handler an event it fires, and the block its children.

Element(_ tag: String) { … }

Before 5.0

No preview for this one: the example below shows how it is written.

Example

wf

state loaded = false Element("stripe-pricing-table", pricingTableId: "prctbl_1Pq", publishableKey: "pk_test_51Hx") { on ready { loaded = true } if !loaded { Text("Loading the prices…").muted } }

Children and a class

wf

Element("relative-time", datetime: "2026-03-14T09:30:00Z", class: "muted") { Text("March 14, 2026") }

Props

Props of Element
PropTypeUnsetMeaning

tag

String (positional)

—

The custom element's tag: lower case, with a hyphen, as every custom element's is (E116 otherwise)

Attribute families: any. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.

Flags and cases

A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.

No flags of its own.

Events

Every element also takes the props, the events and the attribute families listed on every element.

Slots

children

These controls list the props' cases; the example below shows them written.