lustre/element

Types

pub external type Element(action)

Functions

pub fn a(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn abbr(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn address(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn area(attributes: List(Attribute(a))) -> Element(a)
pub fn article(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn aside(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn audio(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn b(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn base(attributes: List(Attribute(a))) -> Element(a)
pub fn bdi(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn bdo(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn blockquote(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn body(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn br(attributes: List(Attribute(a))) -> Element(a)
pub fn button(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn canvas(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn caption(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn cite(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn code(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn col(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn colgroup(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn datalist(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn dd(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn del(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn details(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn dfn(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn dialog(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn div(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn dl(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn dt(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn em(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn embed(attributes: List(Attribute(a))) -> Element(a)
pub fn fieldset(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn figcaption(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn figure(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn footer(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn form(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub external fn fragment(
  children: List(Element(action)),
) -> Element(action)

A fragment doesn’t appear in the DOM, but allows us to treat a list of elements as if it were a single one.

pub fn h1(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn h2(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn h3(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn h4(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn h5(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn h6(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn head(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn header(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn hr(attributes: List(Attribute(a))) -> Element(a)
pub fn html(attributes: List(Attribute(a)), head: Element(a), body: Element(
    a,
  )) -> Element(a)
pub fn i(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn iframe(attributes: List(Attribute(a))) -> Element(a)
pub fn img(attributes: List(Attribute(a))) -> Element(a)
pub fn input(attributes: List(Attribute(a))) -> Element(a)
pub fn ins(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn kbd(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn label(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn legend(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn li(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn main(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub external fn map(
  element: Element(a),
  f: fn(a) -> b,
) -> Element(b)

Transforms the actions produced by some element.

pub fn map_(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn mark(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn mathml(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn menu(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn meta(attributes: List(Attribute(a))) -> Element(a)
pub fn meter(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn nav(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub external fn node(
  tag: String,
  attributes: List(Attribute(action)),
  children: List(Element(action)),
) -> Element(action)

Construct a plain HTML element or registered Web Component by providing the tag name, a list of attributes (including event handlers), and a list of child elements.

pub fn noscript(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn object(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn ol(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn optgroup(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn option(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn output(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn p(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn param(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn picture(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn portal(attributes: List(Attribute(a))) -> Element(a)
pub fn pre(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn progress(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn rp(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn rt(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn ruby(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn s(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn samp(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn section(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn select(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn slot(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn small(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn source(attributes: List(Attribute(a))) -> Element(a)
pub fn span(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub external fn stateful(
  init: state,
  render: fn(state, fn(state) -> Nil) -> Element(action),
) -> Element(action)

A stateful element is exactly what it sounds like: some element with local encapsulated state! The render function we must provide is called with the element’s current state as well as a function to set a new state. Whenever that function is called, the element is re-rendered.

You might be wondering where the stateless version of this function is. Those are just regular Gleam functions that return Elements!

pub fn strong(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn style(attributes: List(Attribute(a)), css: String) -> Element(
  a,
)
pub fn sub(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn summary(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn sup(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn svg(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn table(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn tbody(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn td(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn template(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub external fn text(content: String) -> Element(action)

Render a Gleam string as an HTML text node.

pub fn textarea(attributes: List(Attribute(a))) -> Element(a)
pub fn tfoot(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn th(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn thead(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn time(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn title(attributes: List(Attribute(a)), name: String) -> Element(
  a,
)
pub fn tr(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn track(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn u(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn ul(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn var_(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn video(attributes: List(Attribute(a)), children: List(
    Element(a),
  )) -> Element(a)
pub fn wbr(attributes: List(Attribute(a))) -> Element(a)