pub struct Element<M> { /* private fields */ }Expand description
An element waiting to be mounted: a widget, its attributes, handlers and children.
Built by the ui! macro or by hand from the constructors
in elements, then handed to Ui::set_root or
Ui::mount.
Implementations§
Source§impl<M: 'static> Element<M>
impl<M: 'static> Element<M>
Sourcepub fn new(tag: &'static str, widget: impl Widget<M>) -> Self
pub fn new(tag: &'static str, widget: impl Widget<M>) -> Self
An element of your own widget type. tag is what selectors match it
by, so use something distinct like color-picker.
Sourcepub fn attr(self, name: &str, value: impl ToString) -> Self
pub fn attr(self, name: &str, value: impl ToString) -> Self
Sets an attribute, the way name="value" does in the macro.
id, class, style, grow, align, disabled, shortcut and
state are understood by the framework; anything else goes to the
widget (containers take align_items and justify, for example). An attribute nobody understands, an inline style that does
not parse or a bad shortcut is a mistake in the template, and panics
with a message saying which.
§Panics
On an attribute the element does not accept, or a value it cannot parse.
Sourcepub fn child(self, child: impl IntoChildren<M>) -> Self
pub fn child(self, child: impl IntoChildren<M>) -> Self
Appends children: an element, a list of them, an option, or text.
Text goes to the widget if it takes a text attribute (a label does)
and otherwise becomes a child label, so <button>"Save"</button> is a
button containing a label.