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.
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.
Aside
Aside element for sidebar content.
Main
Main content element.
Header
Header element for page or section headers.
Footer element for page or section footers.
Section
Section element for thematic grouping of content.
Form
Form element for user input.
Fields
Span
Inline span element for text styling.
Input
Input element for form fields.
Fields
Button
Button element for user interaction.
Image
Image element with responsive loading support.
Fields
loading: Option<ImageLoading>Loading strategy (lazy, eager).
Anchor
Anchor element for hyperlinks.
Fields
target: Option<LinkTarget>Link target behavior (_blank, _self, etc.).
Heading
Heading element (h1-h6).
Fields
size: HeaderSizeHeading 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
TBody
Table body element (tbody).
TR
Table row element (tr).
TD
Table data cell element (td).
Fields
Textarea
Textarea element for multi-line text input.
Fields
Details
Details disclosure element for expandable content.
Summary
Summary element for details disclosure heading.
Select
Select element for dropdown menus.
Fields
Option
Option element for select menus.
Implementations§
Source§impl Element
impl Element
Sourcepub const fn allows_children(&self) -> bool
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)
Sourcepub const fn tag_display_str(&self) -> &'static str
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”).