Struct silkenweb_dom::ElementBuilder
source · pub struct ElementBuilder { /* private fields */ }
Expand description
Build an HTML element.
Implementations§
source§impl ElementBuilder
impl ElementBuilder
pub fn new(tag: impl AsRef<str>) -> Self
sourcepub fn attribute<T>(
self,
name: impl AsRef<str>,
value: impl AttributeValue<T>
) -> Self
pub fn attribute<T>(
self,
name: impl AsRef<str>,
value: impl AttributeValue<T>
) -> Self
Set an attribute. Attribute values can be reactive.
sourcepub fn child(self, child: impl Into<Element>) -> Self
pub fn child(self, child: impl Into<Element>) -> Self
Add a child element after existing children. The child element can be reactive.
sourcepub fn text(self, child: impl Text) -> Self
pub fn text(self, child: impl Text) -> Self
Add a text node after existing children. The text node can be reactive.
sourcepub fn effect<T>(self, child: impl Effect<T>) -> Self
pub fn effect<T>(self, child: impl Effect<T>) -> Self
Apply an effect after the next render. For example, to set the focus of an element:
element.effect(|elem: &HtmlInputElement| elem.focus().unwrap());
Effects can be reactive. For example, to set the visibibilty of an item
based on a hidden
boolean signal:
let hidden = Signal::new(false);
let is_hidden = hidden.read();
element.effect(is_hidden.map(|&hidden| move |elem: &HtmlInputElement| elem.set_hidden(hidden)));
Trait Implementations§
source§impl Builder for ElementBuilder
impl Builder for ElementBuilder
source§impl DomElement for ElementBuilder
impl DomElement for ElementBuilder
source§impl From<ElementBuilder> for Element
impl From<ElementBuilder> for Element
source§fn from(builder: ElementBuilder) -> Self
fn from(builder: ElementBuilder) -> Self
Converts to this type from the input type.