Struct silkenweb_html::macros::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>) -> ElementBuilder
sourcepub fn attribute<T>(
self,
name: impl AsRef<str>,
value: impl AttributeValue<T>
) -> ElementBuilder
pub fn attribute<T>(
self,
name: impl AsRef<str>,
value: impl AttributeValue<T>
) -> ElementBuilder
Set an attribute. Attribute values can be reactive.
sourcepub fn child(self, child: impl Into<Element>) -> ElementBuilder
pub fn child(self, child: impl Into<Element>) -> ElementBuilder
Add a child element after existing children. The child element can be reactive.
sourcepub fn text(self, child: impl Text) -> ElementBuilder
pub fn text(self, child: impl Text) -> ElementBuilder
Add a text node after existing children. The text node can be reactive.
sourcepub fn effect<T>(self, child: impl Effect<T>) -> ElementBuilder
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)));
sourcepub fn on(
self,
name: &'static str,
f: impl FnMut(JsValue) + 'static
) -> ElementBuilder
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
impl Builder for ElementBuilder
source§impl DomElement for ElementBuilder
impl DomElement for ElementBuilder
type Target = Element
fn dom_element(&self) -> <ElementBuilder as DomElement>::Target
source§impl From<ABuilder> for ElementBuilder
impl From<ABuilder> for ElementBuilder
source§impl From<AbbrBuilder> for ElementBuilder
impl From<AbbrBuilder> for ElementBuilder
source§fn from(builder: AbbrBuilder) -> Self
fn from(builder: AbbrBuilder) -> Self
Converts to this type from the input type.
source§impl From<AddressBuilder> for ElementBuilder
impl From<AddressBuilder> for ElementBuilder
source§fn from(builder: AddressBuilder) -> Self
fn from(builder: AddressBuilder) -> Self
Converts to this type from the input type.
source§impl From<AreaBuilder> for ElementBuilder
impl From<AreaBuilder> for ElementBuilder
source§fn from(builder: AreaBuilder) -> Self
fn from(builder: AreaBuilder) -> Self
Converts to this type from the input type.
source§impl From<ArticleBuilder> for ElementBuilder
impl From<ArticleBuilder> for ElementBuilder
source§fn from(builder: ArticleBuilder) -> Self
fn from(builder: ArticleBuilder) -> Self
Converts to this type from the input type.
source§impl From<AsideBuilder> for ElementBuilder
impl From<AsideBuilder> for ElementBuilder
source§fn from(builder: AsideBuilder) -> Self
fn from(builder: AsideBuilder) -> Self
Converts to this type from the input type.
source§impl From<AudioBuilder> for ElementBuilder
impl From<AudioBuilder> for ElementBuilder
source§fn from(builder: AudioBuilder) -> Self
fn from(builder: AudioBuilder) -> Self
Converts to this type from the input type.
source§impl From<BBuilder> for ElementBuilder
impl From<BBuilder> for ElementBuilder
source§impl From<BaseBuilder> for ElementBuilder
impl From<BaseBuilder> for ElementBuilder
source§fn from(builder: BaseBuilder) -> Self
fn from(builder: BaseBuilder) -> Self
Converts to this type from the input type.
source§impl From<BdiBuilder> for ElementBuilder
impl From<BdiBuilder> for ElementBuilder
source§fn from(builder: BdiBuilder) -> Self
fn from(builder: BdiBuilder) -> Self
Converts to this type from the input type.
source§impl From<BdoBuilder> for ElementBuilder
impl From<BdoBuilder> for ElementBuilder
source§fn from(builder: BdoBuilder) -> Self
fn from(builder: BdoBuilder) -> Self
Converts to this type from the input type.
source§impl From<BlockquoteBuilder> for ElementBuilder
impl From<BlockquoteBuilder> for ElementBuilder
source§fn from(builder: BlockquoteBuilder) -> Self
fn from(builder: BlockquoteBuilder) -> Self
Converts to this type from the input type.
source§impl From<BrBuilder> for ElementBuilder
impl From<BrBuilder> for ElementBuilder
source§impl From<ButtonBuilder> for ElementBuilder
impl From<ButtonBuilder> for ElementBuilder
source§fn from(builder: ButtonBuilder) -> Self
fn from(builder: ButtonBuilder) -> Self
Converts to this type from the input type.
source§impl From<CanvasBuilder> for ElementBuilder
impl From<CanvasBuilder> for ElementBuilder
source§fn from(builder: CanvasBuilder) -> Self
fn from(builder: CanvasBuilder) -> Self
Converts to this type from the input type.
source§impl From<CaptionBuilder> for ElementBuilder
impl From<CaptionBuilder> for ElementBuilder
source§fn from(builder: CaptionBuilder) -> Self
fn from(builder: CaptionBuilder) -> Self
Converts to this type from the input type.
source§impl From<CiteBuilder> for ElementBuilder
impl From<CiteBuilder> for ElementBuilder
source§fn from(builder: CiteBuilder) -> Self
fn from(builder: CiteBuilder) -> Self
Converts to this type from the input type.
source§impl From<CodeBuilder> for ElementBuilder
impl From<CodeBuilder> for ElementBuilder
source§fn from(builder: CodeBuilder) -> Self
fn from(builder: CodeBuilder) -> Self
Converts to this type from the input type.
source§impl From<ColBuilder> for ElementBuilder
impl From<ColBuilder> for ElementBuilder
source§fn from(builder: ColBuilder) -> Self
fn from(builder: ColBuilder) -> Self
Converts to this type from the input type.
source§impl From<ColgroupBuilder> for ElementBuilder
impl From<ColgroupBuilder> for ElementBuilder
source§fn from(builder: ColgroupBuilder) -> Self
fn from(builder: ColgroupBuilder) -> Self
Converts to this type from the input type.
source§impl From<DataBuilder> for ElementBuilder
impl From<DataBuilder> for ElementBuilder
source§fn from(builder: DataBuilder) -> Self
fn from(builder: DataBuilder) -> Self
Converts to this type from the input type.
source§impl From<DatalistBuilder> for ElementBuilder
impl From<DatalistBuilder> for ElementBuilder
source§fn from(builder: DatalistBuilder) -> Self
fn from(builder: DatalistBuilder) -> Self
Converts to this type from the input type.
source§impl From<DdBuilder> for ElementBuilder
impl From<DdBuilder> for ElementBuilder
source§impl From<DelBuilder> for ElementBuilder
impl From<DelBuilder> for ElementBuilder
source§fn from(builder: DelBuilder) -> Self
fn from(builder: DelBuilder) -> Self
Converts to this type from the input type.
source§impl From<DetailsBuilder> for ElementBuilder
impl From<DetailsBuilder> for ElementBuilder
source§fn from(builder: DetailsBuilder) -> Self
fn from(builder: DetailsBuilder) -> Self
Converts to this type from the input type.
source§impl From<DfnBuilder> for ElementBuilder
impl From<DfnBuilder> for ElementBuilder
source§fn from(builder: DfnBuilder) -> Self
fn from(builder: DfnBuilder) -> Self
Converts to this type from the input type.
source§impl From<DialogBuilder> for ElementBuilder
impl From<DialogBuilder> for ElementBuilder
source§fn from(builder: DialogBuilder) -> Self
fn from(builder: DialogBuilder) -> Self
Converts to this type from the input type.
source§impl From<DivBuilder> for ElementBuilder
impl From<DivBuilder> for ElementBuilder
source§fn from(builder: DivBuilder) -> Self
fn from(builder: DivBuilder) -> Self
Converts to this type from the input type.
source§impl From<DlBuilder> for ElementBuilder
impl From<DlBuilder> for ElementBuilder
source§impl From<DtBuilder> for ElementBuilder
impl From<DtBuilder> for ElementBuilder
source§impl From<ElementBuilder> for Element
impl From<ElementBuilder> for Element
source§fn from(builder: ElementBuilder) -> Element
fn from(builder: ElementBuilder) -> Element
Converts to this type from the input type.
source§impl From<EmBuilder> for ElementBuilder
impl From<EmBuilder> for ElementBuilder
source§impl From<EmbedBuilder> for ElementBuilder
impl From<EmbedBuilder> for ElementBuilder
source§fn from(builder: EmbedBuilder) -> Self
fn from(builder: EmbedBuilder) -> Self
Converts to this type from the input type.
source§impl From<FieldsetBuilder> for ElementBuilder
impl From<FieldsetBuilder> for ElementBuilder
source§fn from(builder: FieldsetBuilder) -> Self
fn from(builder: FieldsetBuilder) -> Self
Converts to this type from the input type.
source§fn from(builder: FigcaptionBuilder) -> Self
fn from(builder: FigcaptionBuilder) -> Self
Converts to this type from the input type.
source§impl From<FigureBuilder> for ElementBuilder
impl From<FigureBuilder> for ElementBuilder
source§fn from(builder: FigureBuilder) -> Self
fn from(builder: FigureBuilder) -> Self
Converts to this type from the input type.
source§fn from(builder: FooterBuilder) -> Self
fn from(builder: FooterBuilder) -> Self
Converts to this type from the input type.
source§impl From<FormBuilder> for ElementBuilder
impl From<FormBuilder> for ElementBuilder
source§fn from(builder: FormBuilder) -> Self
fn from(builder: FormBuilder) -> Self
Converts to this type from the input type.
source§impl From<H1Builder> for ElementBuilder
impl From<H1Builder> for ElementBuilder
source§impl From<H2Builder> for ElementBuilder
impl From<H2Builder> for ElementBuilder
source§impl From<H3Builder> for ElementBuilder
impl From<H3Builder> for ElementBuilder
source§impl From<H4Builder> for ElementBuilder
impl From<H4Builder> for ElementBuilder
source§impl From<H5Builder> for ElementBuilder
impl From<H5Builder> for ElementBuilder
source§impl From<H6Builder> for ElementBuilder
impl From<H6Builder> for ElementBuilder
source§impl From<HeadBuilder> for ElementBuilder
impl From<HeadBuilder> for ElementBuilder
source§fn from(builder: HeadBuilder) -> Self
fn from(builder: HeadBuilder) -> Self
Converts to this type from the input type.
source§impl From<HeaderBuilder> for ElementBuilder
impl From<HeaderBuilder> for ElementBuilder
source§fn from(builder: HeaderBuilder) -> Self
fn from(builder: HeaderBuilder) -> Self
Converts to this type from the input type.
source§impl From<HgroupBuilder> for ElementBuilder
impl From<HgroupBuilder> for ElementBuilder
source§fn from(builder: HgroupBuilder) -> Self
fn from(builder: HgroupBuilder) -> Self
Converts to this type from the input type.
source§impl From<HrBuilder> for ElementBuilder
impl From<HrBuilder> for ElementBuilder
source§impl From<IBuilder> for ElementBuilder
impl From<IBuilder> for ElementBuilder
source§impl From<IframeBuilder> for ElementBuilder
impl From<IframeBuilder> for ElementBuilder
source§fn from(builder: IframeBuilder) -> Self
fn from(builder: IframeBuilder) -> Self
Converts to this type from the input type.
source§impl From<ImgBuilder> for ElementBuilder
impl From<ImgBuilder> for ElementBuilder
source§fn from(builder: ImgBuilder) -> Self
fn from(builder: ImgBuilder) -> Self
Converts to this type from the input type.
source§impl From<InputBuilder> for ElementBuilder
impl From<InputBuilder> for ElementBuilder
source§fn from(builder: InputBuilder) -> Self
fn from(builder: InputBuilder) -> Self
Converts to this type from the input type.
source§impl From<InsBuilder> for ElementBuilder
impl From<InsBuilder> for ElementBuilder
source§fn from(builder: InsBuilder) -> Self
fn from(builder: InsBuilder) -> Self
Converts to this type from the input type.
source§impl From<KbdBuilder> for ElementBuilder
impl From<KbdBuilder> for ElementBuilder
source§fn from(builder: KbdBuilder) -> Self
fn from(builder: KbdBuilder) -> Self
Converts to this type from the input type.
source§impl From<LabelBuilder> for ElementBuilder
impl From<LabelBuilder> for ElementBuilder
source§fn from(builder: LabelBuilder) -> Self
fn from(builder: LabelBuilder) -> Self
Converts to this type from the input type.
source§impl From<LegendBuilder> for ElementBuilder
impl From<LegendBuilder> for ElementBuilder
source§fn from(builder: LegendBuilder) -> Self
fn from(builder: LegendBuilder) -> Self
Converts to this type from the input type.
source§impl From<LiBuilder> for ElementBuilder
impl From<LiBuilder> for ElementBuilder
source§impl From<LinkBuilder> for ElementBuilder
impl From<LinkBuilder> for ElementBuilder
source§fn from(builder: LinkBuilder) -> Self
fn from(builder: LinkBuilder) -> Self
Converts to this type from the input type.
source§impl From<MainBuilder> for ElementBuilder
impl From<MainBuilder> for ElementBuilder
source§fn from(builder: MainBuilder) -> Self
fn from(builder: MainBuilder) -> Self
Converts to this type from the input type.
source§impl From<MapBuilder> for ElementBuilder
impl From<MapBuilder> for ElementBuilder
source§fn from(builder: MapBuilder) -> Self
fn from(builder: MapBuilder) -> Self
Converts to this type from the input type.
source§impl From<MarkBuilder> for ElementBuilder
impl From<MarkBuilder> for ElementBuilder
source§fn from(builder: MarkBuilder) -> Self
fn from(builder: MarkBuilder) -> Self
Converts to this type from the input type.
source§impl From<MenuBuilder> for ElementBuilder
impl From<MenuBuilder> for ElementBuilder
source§fn from(builder: MenuBuilder) -> Self
fn from(builder: MenuBuilder) -> Self
Converts to this type from the input type.
source§impl From<MetaBuilder> for ElementBuilder
impl From<MetaBuilder> for ElementBuilder
source§fn from(builder: MetaBuilder) -> Self
fn from(builder: MetaBuilder) -> Self
Converts to this type from the input type.
source§impl From<MeterBuilder> for ElementBuilder
impl From<MeterBuilder> for ElementBuilder
source§fn from(builder: MeterBuilder) -> Self
fn from(builder: MeterBuilder) -> Self
Converts to this type from the input type.
source§fn from(builder: NavBuilder) -> Self
fn from(builder: NavBuilder) -> Self
Converts to this type from the input type.
source§impl From<NoscriptBuilder> for ElementBuilder
impl From<NoscriptBuilder> for ElementBuilder
source§fn from(builder: NoscriptBuilder) -> Self
fn from(builder: NoscriptBuilder) -> Self
Converts to this type from the input type.
source§impl From<ObjectBuilder> for ElementBuilder
impl From<ObjectBuilder> for ElementBuilder
source§fn from(builder: ObjectBuilder) -> Self
fn from(builder: ObjectBuilder) -> Self
Converts to this type from the input type.
source§impl From<OlBuilder> for ElementBuilder
impl From<OlBuilder> for ElementBuilder
source§impl From<OptgroupBuilder> for ElementBuilder
impl From<OptgroupBuilder> for ElementBuilder
source§fn from(builder: OptgroupBuilder) -> Self
fn from(builder: OptgroupBuilder) -> Self
Converts to this type from the input type.
source§impl From<OptionBuilder> for ElementBuilder
impl From<OptionBuilder> for ElementBuilder
source§fn from(builder: OptionBuilder) -> Self
fn from(builder: OptionBuilder) -> Self
Converts to this type from the input type.
source§impl From<OutputBuilder> for ElementBuilder
impl From<OutputBuilder> for ElementBuilder
source§fn from(builder: OutputBuilder) -> Self
fn from(builder: OutputBuilder) -> Self
Converts to this type from the input type.
source§impl From<PBuilder> for ElementBuilder
impl From<PBuilder> for ElementBuilder
source§impl From<ParamBuilder> for ElementBuilder
impl From<ParamBuilder> for ElementBuilder
source§fn from(builder: ParamBuilder) -> Self
fn from(builder: ParamBuilder) -> Self
Converts to this type from the input type.
source§impl From<PictureBuilder> for ElementBuilder
impl From<PictureBuilder> for ElementBuilder
source§fn from(builder: PictureBuilder) -> Self
fn from(builder: PictureBuilder) -> Self
Converts to this type from the input type.
source§impl From<PreBuilder> for ElementBuilder
impl From<PreBuilder> for ElementBuilder
source§fn from(builder: PreBuilder) -> Self
fn from(builder: PreBuilder) -> Self
Converts to this type from the input type.
source§impl From<ProgressBuilder> for ElementBuilder
impl From<ProgressBuilder> for ElementBuilder
source§fn from(builder: ProgressBuilder) -> Self
fn from(builder: ProgressBuilder) -> Self
Converts to this type from the input type.
source§impl From<QBuilder> for ElementBuilder
impl From<QBuilder> for ElementBuilder
source§impl From<RbBuilder> for ElementBuilder
impl From<RbBuilder> for ElementBuilder
source§impl From<RpBuilder> for ElementBuilder
impl From<RpBuilder> for ElementBuilder
source§impl From<RtBuilder> for ElementBuilder
impl From<RtBuilder> for ElementBuilder
source§impl From<RtcBuilder> for ElementBuilder
impl From<RtcBuilder> for ElementBuilder
source§fn from(builder: RtcBuilder) -> Self
fn from(builder: RtcBuilder) -> Self
Converts to this type from the input type.
source§impl From<RubyBuilder> for ElementBuilder
impl From<RubyBuilder> for ElementBuilder
source§fn from(builder: RubyBuilder) -> Self
fn from(builder: RubyBuilder) -> Self
Converts to this type from the input type.
source§impl From<SBuilder> for ElementBuilder
impl From<SBuilder> for ElementBuilder
source§impl From<SampBuilder> for ElementBuilder
impl From<SampBuilder> for ElementBuilder
source§fn from(builder: SampBuilder) -> Self
fn from(builder: SampBuilder) -> Self
Converts to this type from the input type.
source§impl From<ScriptBuilder> for ElementBuilder
impl From<ScriptBuilder> for ElementBuilder
source§fn from(builder: ScriptBuilder) -> Self
fn from(builder: ScriptBuilder) -> Self
Converts to this type from the input type.
source§impl From<SectionBuilder> for ElementBuilder
impl From<SectionBuilder> for ElementBuilder
source§fn from(builder: SectionBuilder) -> Self
fn from(builder: SectionBuilder) -> Self
Converts to this type from the input type.
source§impl From<SelectBuilder> for ElementBuilder
impl From<SelectBuilder> for ElementBuilder
source§fn from(builder: SelectBuilder) -> Self
fn from(builder: SelectBuilder) -> Self
Converts to this type from the input type.
source§impl From<SmallBuilder> for ElementBuilder
impl From<SmallBuilder> for ElementBuilder
source§fn from(builder: SmallBuilder) -> Self
fn from(builder: SmallBuilder) -> Self
Converts to this type from the input type.
source§impl From<SourceBuilder> for ElementBuilder
impl From<SourceBuilder> for ElementBuilder
source§fn from(builder: SourceBuilder) -> Self
fn from(builder: SourceBuilder) -> Self
Converts to this type from the input type.
source§impl From<SpanBuilder> for ElementBuilder
impl From<SpanBuilder> for ElementBuilder
source§fn from(builder: SpanBuilder) -> Self
fn from(builder: SpanBuilder) -> Self
Converts to this type from the input type.
source§impl From<StrongBuilder> for ElementBuilder
impl From<StrongBuilder> for ElementBuilder
source§fn from(builder: StrongBuilder) -> Self
fn from(builder: StrongBuilder) -> Self
Converts to this type from the input type.
source§impl From<StyleBuilder> for ElementBuilder
impl From<StyleBuilder> for ElementBuilder
source§fn from(builder: StyleBuilder) -> Self
fn from(builder: StyleBuilder) -> Self
Converts to this type from the input type.
source§impl From<SubBuilder> for ElementBuilder
impl From<SubBuilder> for ElementBuilder
source§fn from(builder: SubBuilder) -> Self
fn from(builder: SubBuilder) -> Self
Converts to this type from the input type.
source§impl From<SummaryBuilder> for ElementBuilder
impl From<SummaryBuilder> for ElementBuilder
source§fn from(builder: SummaryBuilder) -> Self
fn from(builder: SummaryBuilder) -> Self
Converts to this type from the input type.
source§impl From<SupBuilder> for ElementBuilder
impl From<SupBuilder> for ElementBuilder
source§fn from(builder: SupBuilder) -> Self
fn from(builder: SupBuilder) -> Self
Converts to this type from the input type.
source§impl From<TableBuilder> for ElementBuilder
impl From<TableBuilder> for ElementBuilder
source§fn from(builder: TableBuilder) -> Self
fn from(builder: TableBuilder) -> Self
Converts to this type from the input type.
source§impl From<TbodyBuilder> for ElementBuilder
impl From<TbodyBuilder> for ElementBuilder
source§fn from(builder: TbodyBuilder) -> Self
fn from(builder: TbodyBuilder) -> Self
Converts to this type from the input type.
source§impl From<TdBuilder> for ElementBuilder
impl From<TdBuilder> for ElementBuilder
source§impl From<TextareaBuilder> for ElementBuilder
impl From<TextareaBuilder> for ElementBuilder
source§fn from(builder: TextareaBuilder) -> Self
fn from(builder: TextareaBuilder) -> Self
Converts to this type from the input type.
source§impl From<TfootBuilder> for ElementBuilder
impl From<TfootBuilder> for ElementBuilder
source§fn from(builder: TfootBuilder) -> Self
fn from(builder: TfootBuilder) -> Self
Converts to this type from the input type.
source§impl From<ThBuilder> for ElementBuilder
impl From<ThBuilder> for ElementBuilder
source§impl From<TheadBuilder> for ElementBuilder
impl From<TheadBuilder> for ElementBuilder
source§fn from(builder: TheadBuilder) -> Self
fn from(builder: TheadBuilder) -> Self
Converts to this type from the input type.
source§impl From<TimeBuilder> for ElementBuilder
impl From<TimeBuilder> for ElementBuilder
source§fn from(builder: TimeBuilder) -> Self
fn from(builder: TimeBuilder) -> Self
Converts to this type from the input type.
source§impl From<TitleBuilder> for ElementBuilder
impl From<TitleBuilder> for ElementBuilder
source§fn from(builder: TitleBuilder) -> Self
fn from(builder: TitleBuilder) -> Self
Converts to this type from the input type.
source§impl From<TrBuilder> for ElementBuilder
impl From<TrBuilder> for ElementBuilder
source§impl From<TrackBuilder> for ElementBuilder
impl From<TrackBuilder> for ElementBuilder
source§fn from(builder: TrackBuilder) -> Self
fn from(builder: TrackBuilder) -> Self
Converts to this type from the input type.
source§impl From<UBuilder> for ElementBuilder
impl From<UBuilder> for ElementBuilder
source§impl From<UlBuilder> for ElementBuilder
impl From<UlBuilder> for ElementBuilder
source§impl From<VarBuilder> for ElementBuilder
impl From<VarBuilder> for ElementBuilder
source§fn from(builder: VarBuilder) -> Self
fn from(builder: VarBuilder) -> Self
Converts to this type from the input type.
source§impl From<VideoBuilder> for ElementBuilder
impl From<VideoBuilder> for ElementBuilder
source§fn from(builder: VideoBuilder) -> Self
fn from(builder: VideoBuilder) -> Self
Converts to this type from the input type.
source§impl From<WbrBuilder> for ElementBuilder
impl From<WbrBuilder> for ElementBuilder
source§fn from(builder: WbrBuilder) -> Self
fn from(builder: WbrBuilder) -> Self
Converts to this type from the input type.