pub trait Element<C>: 'static { }Expand description
An Element is anything that can produce a DOM node.
The most common examples include HtmlElement and types like String.
Additionally, closures with the appropriate signature also implement this trait. See the Reactivity chapter in the book for more examples.
🚨 You should generally NOT implement this trait manually.
Instead, prefer sub-components (for stateful elements) or stateless components
(which are simply functions returning an Element).
§❌ Don’t
Avoid manually implementing Element for custom components:
struct MyFancyButton(&'static str);
impl<C> Element<C> for MyFancyButton {/* ... */}§✅ Do
Instead, use a function-based stateless component:
fn my_fancy_button<C>(name: &'static str) -> impl Element<C> {
e::button() /* ... */
}This keeps your UI cleaner, more composable, and easier to maintain. 🚀✨