view!

The view! macro builds a View tree from JSX-like syntax — elements, text, and Rust expressions.

Basic syntax

view! {
    <main class="page">
        <h1>"Hello Resuma"</h1>
        <p>"Static text in quotes."</p>
    </main>
}

Dynamic bindings

Wrap Rust expressions in curly braces. Signals, strings, and numbers interpolate directly.

let title = "Docs".to_string();
let count = use_signal(0);

view! {
    <h1>{title}</h1>
    <p>"Count: " {count}</p>
}

Attributes

Static attributes use quoted strings. Dynamic values use braces.

view! {
    <a href="/docs" class={"card ".to_string() + &extra}>
        "Link"
    </a>
    <input type="text" value={name} disabled={is_loading} />
}

Fragments

Use <> to group siblings without a wrapper element.

view! {
    <>
        <h1>{title}</h1>
        <Slot />
    </>
}

Components

Capitalized tags invoke #[component] functions. Props are Rust struct fields.

view! {
    <Greeting name={"World".into()} />
    <Card>
        <h2 slot="header">"Title"</h2>
        <p>"Body content"</p>
    </Card>
}

Boolean attributes

view! {
    <button disabled={true}> "Save" </button>
    <input required={false} />
}

Trusted HTML (View::raw)

Text and attributes in view! are escaped. View::raw() skips escaping — static/trusted markup only, never user input.

View::raw("<div class=\"banner\">Trusted</div>")  // OK
    // View::raw(user_input)  // NEVER — XSS