Struct ElementBuilder

Source
pub struct ElementBuilder { /* private fields */ }
Expand description

Build an HTML element.

Implementations§

Source§

impl ElementBuilder

Source

pub fn new(tag: impl AsRef<str>) -> ElementBuilder

Source

pub fn attribute<T>( self, name: impl AsRef<str>, value: impl AttributeValue<T>, ) -> ElementBuilder

Set an attribute. Attribute values can be reactive.

Source

pub fn child(self, child: impl Into<Element>) -> ElementBuilder

Add a child element after existing children. The child element can be reactive.

Source

pub fn text(self, child: impl Text) -> ElementBuilder

Add a text node after existing children. The text node can be reactive.

Source

pub fn effect<T>(self, child: impl Effect<T>) -> ElementBuilder

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)));
Source

pub fn on( self, name: &'static str, f: impl FnMut(JsValue) + 'static, ) -> ElementBuilder

Register an event handler.

name is the name of the event. See the MDN Events page for a list.

f is the callback when the event fires and will be passed the javascript Event object.

Trait Implementations§

Source§

impl Builder for ElementBuilder

Source§

impl DomElement for ElementBuilder

Source§

impl From<ABuilder> for ElementBuilder

Source§

fn from(builder: ABuilder) -> Self

Converts to this type from the input type.
Source§

impl From<AbbrBuilder> for ElementBuilder

Source§

fn from(builder: AbbrBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<AddressBuilder> for ElementBuilder

Source§

fn from(builder: AddressBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<AreaBuilder> for ElementBuilder

Source§

fn from(builder: AreaBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<ArticleBuilder> for ElementBuilder

Source§

fn from(builder: ArticleBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<AsideBuilder> for ElementBuilder

Source§

fn from(builder: AsideBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<AudioBuilder> for ElementBuilder

Source§

fn from(builder: AudioBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<BBuilder> for ElementBuilder

Source§

fn from(builder: BBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<BaseBuilder> for ElementBuilder

Source§

fn from(builder: BaseBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<BdiBuilder> for ElementBuilder

Source§

fn from(builder: BdiBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<BdoBuilder> for ElementBuilder

Source§

fn from(builder: BdoBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<BlockquoteBuilder> for ElementBuilder

Source§

fn from(builder: BlockquoteBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<BrBuilder> for ElementBuilder

Source§

fn from(builder: BrBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<ButtonBuilder> for ElementBuilder

Source§

fn from(builder: ButtonBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<CanvasBuilder> for ElementBuilder

Source§

fn from(builder: CanvasBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<CaptionBuilder> for ElementBuilder

Source§

fn from(builder: CaptionBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<CiteBuilder> for ElementBuilder

Source§

fn from(builder: CiteBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<CodeBuilder> for ElementBuilder

Source§

fn from(builder: CodeBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<ColBuilder> for ElementBuilder

Source§

fn from(builder: ColBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<ColgroupBuilder> for ElementBuilder

Source§

fn from(builder: ColgroupBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<DataBuilder> for ElementBuilder

Source§

fn from(builder: DataBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<DatalistBuilder> for ElementBuilder

Source§

fn from(builder: DatalistBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<DdBuilder> for ElementBuilder

Source§

fn from(builder: DdBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<DelBuilder> for ElementBuilder

Source§

fn from(builder: DelBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<DetailsBuilder> for ElementBuilder

Source§

fn from(builder: DetailsBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<DfnBuilder> for ElementBuilder

Source§

fn from(builder: DfnBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<DialogBuilder> for ElementBuilder

Source§

fn from(builder: DialogBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<DivBuilder> for ElementBuilder

Source§

fn from(builder: DivBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<DlBuilder> for ElementBuilder

Source§

fn from(builder: DlBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<DtBuilder> for ElementBuilder

Source§

fn from(builder: DtBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<ElementBuilder> for Element

Source§

fn from(builder: ElementBuilder) -> Element

Converts to this type from the input type.
Source§

impl From<EmBuilder> for ElementBuilder

Source§

fn from(builder: EmBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<EmbedBuilder> for ElementBuilder

Source§

fn from(builder: EmbedBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<FieldsetBuilder> for ElementBuilder

Source§

fn from(builder: FieldsetBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<FigcaptionBuilder> for ElementBuilder

Source§

fn from(builder: FigcaptionBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<FigureBuilder> for ElementBuilder

Source§

fn from(builder: FigureBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<FooterBuilder> for ElementBuilder

Source§

fn from(builder: FooterBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<FormBuilder> for ElementBuilder

Source§

fn from(builder: FormBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<H1Builder> for ElementBuilder

Source§

fn from(builder: H1Builder) -> Self

Converts to this type from the input type.
Source§

impl From<H2Builder> for ElementBuilder

Source§

fn from(builder: H2Builder) -> Self

Converts to this type from the input type.
Source§

impl From<H3Builder> for ElementBuilder

Source§

fn from(builder: H3Builder) -> Self

Converts to this type from the input type.
Source§

impl From<H4Builder> for ElementBuilder

Source§

fn from(builder: H4Builder) -> Self

Converts to this type from the input type.
Source§

impl From<H5Builder> for ElementBuilder

Source§

fn from(builder: H5Builder) -> Self

Converts to this type from the input type.
Source§

impl From<H6Builder> for ElementBuilder

Source§

fn from(builder: H6Builder) -> Self

Converts to this type from the input type.
Source§

impl From<HeadBuilder> for ElementBuilder

Source§

fn from(builder: HeadBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<HeaderBuilder> for ElementBuilder

Source§

fn from(builder: HeaderBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<HgroupBuilder> for ElementBuilder

Source§

fn from(builder: HgroupBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<HrBuilder> for ElementBuilder

Source§

fn from(builder: HrBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<IBuilder> for ElementBuilder

Source§

fn from(builder: IBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<IframeBuilder> for ElementBuilder

Source§

fn from(builder: IframeBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<ImgBuilder> for ElementBuilder

Source§

fn from(builder: ImgBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<InputBuilder> for ElementBuilder

Source§

fn from(builder: InputBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<InsBuilder> for ElementBuilder

Source§

fn from(builder: InsBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<KbdBuilder> for ElementBuilder

Source§

fn from(builder: KbdBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<LabelBuilder> for ElementBuilder

Source§

fn from(builder: LabelBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<LegendBuilder> for ElementBuilder

Source§

fn from(builder: LegendBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<LiBuilder> for ElementBuilder

Source§

fn from(builder: LiBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<LinkBuilder> for ElementBuilder

Source§

fn from(builder: LinkBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<MainBuilder> for ElementBuilder

Source§

fn from(builder: MainBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<MapBuilder> for ElementBuilder

Source§

fn from(builder: MapBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<MarkBuilder> for ElementBuilder

Source§

fn from(builder: MarkBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<MenuBuilder> for ElementBuilder

Source§

fn from(builder: MenuBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<MetaBuilder> for ElementBuilder

Source§

fn from(builder: MetaBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<MeterBuilder> for ElementBuilder

Source§

fn from(builder: MeterBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<NavBuilder> for ElementBuilder

Source§

fn from(builder: NavBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<NoscriptBuilder> for ElementBuilder

Source§

fn from(builder: NoscriptBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<ObjectBuilder> for ElementBuilder

Source§

fn from(builder: ObjectBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<OlBuilder> for ElementBuilder

Source§

fn from(builder: OlBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<OptgroupBuilder> for ElementBuilder

Source§

fn from(builder: OptgroupBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<OptionBuilder> for ElementBuilder

Source§

fn from(builder: OptionBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<OutputBuilder> for ElementBuilder

Source§

fn from(builder: OutputBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<PBuilder> for ElementBuilder

Source§

fn from(builder: PBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<ParamBuilder> for ElementBuilder

Source§

fn from(builder: ParamBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<PictureBuilder> for ElementBuilder

Source§

fn from(builder: PictureBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<PreBuilder> for ElementBuilder

Source§

fn from(builder: PreBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<ProgressBuilder> for ElementBuilder

Source§

fn from(builder: ProgressBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<QBuilder> for ElementBuilder

Source§

fn from(builder: QBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<RbBuilder> for ElementBuilder

Source§

fn from(builder: RbBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<RpBuilder> for ElementBuilder

Source§

fn from(builder: RpBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<RtBuilder> for ElementBuilder

Source§

fn from(builder: RtBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<RtcBuilder> for ElementBuilder

Source§

fn from(builder: RtcBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<RubyBuilder> for ElementBuilder

Source§

fn from(builder: RubyBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<SBuilder> for ElementBuilder

Source§

fn from(builder: SBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<SampBuilder> for ElementBuilder

Source§

fn from(builder: SampBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<ScriptBuilder> for ElementBuilder

Source§

fn from(builder: ScriptBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<SectionBuilder> for ElementBuilder

Source§

fn from(builder: SectionBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<SelectBuilder> for ElementBuilder

Source§

fn from(builder: SelectBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<SmallBuilder> for ElementBuilder

Source§

fn from(builder: SmallBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<SourceBuilder> for ElementBuilder

Source§

fn from(builder: SourceBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<SpanBuilder> for ElementBuilder

Source§

fn from(builder: SpanBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<StrongBuilder> for ElementBuilder

Source§

fn from(builder: StrongBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<StyleBuilder> for ElementBuilder

Source§

fn from(builder: StyleBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<SubBuilder> for ElementBuilder

Source§

fn from(builder: SubBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<SummaryBuilder> for ElementBuilder

Source§

fn from(builder: SummaryBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<SupBuilder> for ElementBuilder

Source§

fn from(builder: SupBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<TableBuilder> for ElementBuilder

Source§

fn from(builder: TableBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<TbodyBuilder> for ElementBuilder

Source§

fn from(builder: TbodyBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<TdBuilder> for ElementBuilder

Source§

fn from(builder: TdBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<TextareaBuilder> for ElementBuilder

Source§

fn from(builder: TextareaBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<TfootBuilder> for ElementBuilder

Source§

fn from(builder: TfootBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<ThBuilder> for ElementBuilder

Source§

fn from(builder: ThBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<TheadBuilder> for ElementBuilder

Source§

fn from(builder: TheadBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<TimeBuilder> for ElementBuilder

Source§

fn from(builder: TimeBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<TitleBuilder> for ElementBuilder

Source§

fn from(builder: TitleBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<TrBuilder> for ElementBuilder

Source§

fn from(builder: TrBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<TrackBuilder> for ElementBuilder

Source§

fn from(builder: TrackBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<UBuilder> for ElementBuilder

Source§

fn from(builder: UBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<UlBuilder> for ElementBuilder

Source§

fn from(builder: UlBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<VarBuilder> for ElementBuilder

Source§

fn from(builder: VarBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<VideoBuilder> for ElementBuilder

Source§

fn from(builder: VideoBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<WbrBuilder> for ElementBuilder

Source§

fn from(builder: WbrBuilder) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.