brazier/element

Types

A node of the view tree.

pub opaque type Element(msg)

Values

pub fn element(
  tag: String,
  attributes: List(attribute.Attribute(msg)),
  children: List(Element(msg)),
) -> Element(msg)

An element with any tag.

A tag with characters outside a-z A-Z 0-9 - _ : . is a programming error and crashes.

pub fn keyed(key: String, child: Element(msg)) -> Element(msg)

Give an element a stable identity for the client morph, so it keeps its DOM node (focus, scroll, client state) when its siblings are reordered. The rendered element carries data-brazier-key.

pub fn map(element: Element(a), f: fn(a) -> b) -> Element(b)

Change the message type of every event listener in the tree.

pub fn none() -> Element(msg)

Renders nothing. Use it for the empty branch of a conditional.

pub fn text(content: String) -> Element(msg)

Text content, HTML-escaped when rendered.

pub fn to_string(element: Element(msg)) -> String

Render to an HTML string.

pub fn unsafe_raw_html(html: String) -> Element(msg)

HTML inserted as is: no escaping and no URL policy. Never pass it text that a user controls. For a whole document in an iframe, see attribute.unsafe_srcdoc.

✨ Search Document