Skip to main content

Element

Enum Element 

Source
pub enum Element {
Show 29 variants Div, Raw { value: String, }, Text { value: String, }, Aside, Main, Header, Footer, Section, Form { action: Option<String>, method: Option<String>, }, Span, Input { input: Input, name: Option<String>, autofocus: Option<bool>, }, Button { type: Option<String>, }, Image { source: Option<String>, alt: Option<String>, fit: Option<ImageFit>, source_set: Option<String>, sizes: Option<Number>, loading: Option<ImageLoading>, }, Anchor { target: Option<LinkTarget>, href: Option<String>, }, Heading { size: HeaderSize, }, UnorderedList, OrderedList, ListItem, Table, THead, TH { rows: Option<Number>, columns: Option<Number>, }, TBody, TR, TD { rows: Option<Number>, columns: Option<Number>, }, Textarea { value: String, placeholder: Option<String>, name: Option<String>, rows: Option<Number>, cols: Option<Number>, }, Details { open: Option<bool>, }, Summary, Select { name: Option<String>, selected: Option<String>, multiple: Option<bool>, disabled: Option<bool>, autofocus: Option<bool>, }, Option { value: Option<String>, disabled: Option<bool>, },
}
Expand description

HTML element type with associated properties.

Represents different HTML elements that can be used in a container, with element-specific properties like image sources, anchor hrefs, etc.

Variants§

§

Div

Generic div container (default).

§

Raw

Raw HTML content (will NOT be escaped when rendered).

Use this for intentionally injecting HTML markup. For regular text content that should be safely escaped, use Element::Text instead.

Fields

§value: String

The raw HTML value (rendered without escaping).

§

Text

Escaped text content (HTML entities will be escaped when rendered).

This is the safe default for displaying user-provided or dynamic text content. Characters like <, >, and & will be escaped to prevent XSS attacks.

Fields

§value: String

The text value (will be HTML-escaped in HTML renderer).

§

Aside

Aside element for sidebar content.

§

Main

Main content element.

§

Header

Header element for page or section headers.

§

Footer

Footer element for page or section footers.

§

Section

Section element for thematic grouping of content.

§

Form

Form element for user input.

Fields

§action: Option<String>

Form submission URL.

§method: Option<String>

HTTP method for form submission (GET, POST, etc.).

§

Span

Inline span element for text styling.

§

Input

Input element for form fields.

Fields

§input: Input

The input type and configuration.

§name: Option<String>

Form field name for submission.

§autofocus: Option<bool>

Whether the input should automatically receive focus.

§

Button

Button element for user interaction.

Fields

§type: Option<String>

Button type (submit, reset, button).

§

Image

Image element with responsive loading support.

Fields

§source: Option<String>

Image source URL.

§alt: Option<String>

Alternative text for accessibility.

§fit: Option<ImageFit>

How the image should fit its container.

§source_set: Option<String>

Responsive image source set.

§sizes: Option<Number>

Sizes attribute for responsive images.

§loading: Option<ImageLoading>

Loading strategy (lazy, eager).

§

Anchor

Anchor element for hyperlinks.

Fields

§target: Option<LinkTarget>

Link target behavior (_blank, _self, etc.).

§href: Option<String>

Link destination URL.

§

Heading

Heading element (h1-h6).

Fields

§size: HeaderSize

Heading level (1-6).

§

UnorderedList

Unordered list element (ul).

§

OrderedList

Ordered list element (ol).

§

ListItem

List item element (li).

§

Table

Table element for tabular data.

§

THead

Table head element (thead).

§

TH

Table header cell element (th).

Fields

§rows: Option<Number>

Row span for multi-row headers.

§columns: Option<Number>

Column span for multi-column headers.

§

TBody

Table body element (tbody).

§

TR

Table row element (tr).

§

TD

Table data cell element (td).

Fields

§rows: Option<Number>

Row span for multi-row cells.

§columns: Option<Number>

Column span for multi-column cells.

§

Textarea

Textarea element for multi-line text input.

Fields

§value: String

Current text value.

§placeholder: Option<String>

Placeholder text when empty.

§name: Option<String>

Form field name for submission.

§rows: Option<Number>

Visible number of text rows.

§cols: Option<Number>

Visible number of text columns.

§

Details

Details disclosure element for expandable content.

Fields

§open: Option<bool>

Whether the details are initially open.

§

Summary

Summary element for details disclosure heading.

§

Select

Select element for dropdown menus.

Fields

§name: Option<String>

Form field name for submission.

§selected: Option<String>

The value of the currently selected option.

§multiple: Option<bool>

Whether multiple options can be selected.

§disabled: Option<bool>

Whether the select is disabled.

§autofocus: Option<bool>

Whether the select should automatically receive focus.

§

Option

Option element for select menus.

Fields

§value: Option<String>

Option value for form submission.

§disabled: Option<bool>

Whether this option is disabled.

Implementations§

Source§

impl Element

Source

pub const fn allows_children(&self) -> bool

Checks if this element type can contain child containers.

Returns true for container elements (div, section, button, etc.) and false for self-closing or content elements (input, img, textarea, raw HTML).

Container elements that allow children:

  • Structural: Div, Aside, Main, Header, Footer, Section
  • Interactive: Form, Button, Anchor, Details, Summary
  • Text: Span, Heading
  • Lists: UnorderedList, OrderedList, ListItem
  • Tables: Table, THead, TH, TBody, TR, TD

Elements that do not allow children:

  • Input elements
  • Images
  • Textarea elements
  • Raw HTML content
  • Canvas elements (when feature enabled)
Source

pub const fn tag_display_str(&self) -> &'static str

Returns the display name of this element type as a static string.

This is primarily used for debugging and error messages. The returned string matches the variant name (e.g., “Div”, “Button”, “Heading”).

Trait Implementations§

Source§

impl Clone for Element

Source§

fn clone(&self) -> Element

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Element

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Element

Source§

fn default() -> Element

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Element

Source§

fn eq(&self, other: &Element) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Element

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> Typeable for T
where T: Any,

Source§

fn get_type(&self) -> TypeId

Get the TypeId of this object.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V