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.
Auto Trait Implementations§
impl Freeze for ElementBuilder
impl !RefUnwindSafe for ElementBuilder
impl !Send for ElementBuilder
impl !Sync for ElementBuilder
impl Unpin for ElementBuilder
impl !UnwindSafe for ElementBuilder
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