Macro dominator::html

source ·
macro_rules! html {
    ($($args:tt)+) => { ... };
}
Expand description

Creates an HTML Dom node.

The first argument is the HTML tag, and the second argument is a block of method calls.

Inside of the block you can use DomBuilder<web_sys::HtmlElement> methods:

html!("div", {
    .class("foo")
    .style("color", "green")
    .style_signal("width", ...)
})

The block uses the apply_methods! macro, see the docs for apply_methods! for more details.

You can also specify the static type of the HTML element:

html!("div" => web_sys::HtmlDivElement, {
    ...
})

If you don’t specify a type, it defaults to web_sys::HtmlElement.