Expand description
§view! Procedural Macro
Transforms declarative JSX-like UI syntax into Rust [Element] builder calls.
§Input (what you write)
ⓘ
view! {
<h1 class="title">"Welcome to Bubba"</h1>
<button class="primary-btn" onclick=alert("Tapped!")>
"Tap me"
</button>
<input class="text-input" oninput=log("Typing...") />
}§Output (what it expands to)
ⓘ
{
use bubba_core::ui::Element;
use bubba_core::events::EventHandler;
let mut __root = Element::div();
__root = __root.child(
Element::h1()
.class("title")
.text("Welcome to Bubba")
);
__root = __root.child(
Element::button()
.class("primary-btn")
.text("Tap me")
.on(EventHandler::onclick(|_| { alert("Tapped!") }))
);
__root = __root.child(
Element::input()
.class("text-input")
.on(EventHandler::oninput(|_| { log("Typing...") }))
);
bubba_core::ui::Screen::new(__root)
}Macros§
- view
- Declare a screen’s UI declaratively using JSX-like syntax.