pub struct Element {
pub tag: &'static str,
pub class: Option<String>,
pub attrs: HashMap<&'static str, String>,
pub text: Option<String>,
pub children: Vec<Element>,
pub handlers: Vec<EventHandler>,
}Expand description
The fundamental UI node. Every tag in a view! block becomes one of these.
Fields§
§tag: &'static strTag name: “h1”, “button”, “p”, “img”, “input”, “div”, etc.
class: Option<String>CSS class string, e.g. "title" or "btn primary-btn".
attrs: HashMap<&'static str, String>Arbitrary HTML-like attributes (src, alt, placeholder, …).
text: Option<String>Text content for leaf nodes.
children: Vec<Element>Child elements.
handlers: Vec<EventHandler>Registered event handlers.
Implementations§
Source§impl Element
impl Element
Sourcepub fn attr(self, key: &'static str, value: impl Into<String>) -> Self
pub fn attr(self, key: &'static str, value: impl Into<String>) -> Self
Set a generic attribute.
Sourcepub fn on(self, handler: EventHandler) -> Self
pub fn on(self, handler: EventHandler) -> Self
Attach an event handler.
<button>
Sourcepub fn debug_render(&self, indent: usize) -> String
pub fn debug_render(&self, indent: usize) -> String
Render this element tree as a human-readable string (for debugging).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Element
impl !RefUnwindSafe for Element
impl Send for Element
impl Sync for Element
impl Unpin for Element
impl UnsafeUnpin for Element
impl !UnwindSafe for Element
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more