pub enum AttributeValue {
Text(String),
Signal(Signal<String>),
Event(NativeEventHandler),
Dynamic(String),
Css(Css),
}Expand description
Represents the value of an HTML attribute.
Attributes can be static text, reactive signals, event handlers, dynamic expressions, or CSS class references.
Variants§
Text(String)
A static string value.
Signal(Signal<String>)
A dynamic signal-backed value.
Event(NativeEventHandler)
An event handler callback.
Dynamic(String)
A dynamic expression value of any type (for component props).
Css(Css)
A CSS class reference created by the class! macro.
Implementations§
Source§impl AttributeValue
Implementation of attribute value factory methods for reactive and merged values.
impl AttributeValue
Implementation of attribute value factory methods for reactive and merged values.
Sourcepub fn create_reactive_style<F>(compute: F) -> Self
pub fn create_reactive_style<F>(compute: F) -> Self
Creates a reactive style Self that updates when signals change.
This function replaces the inline Signal::create(...) + subscribe_attr_signal(...)
boilerplate that was previously generated by the html! macro for every
style: attribute containing reactive if conditions.
§Arguments
Fn() -> String + 'static- A closure that computes the current CSS string. Called on initial render and whenever any signal changes.
§Returns
Self- ASelf::Signalbacked by aSignal<String>that reactively re-evaluates the CSS string on signal updates.
Sourcepub fn create_reactive_signal<F>(compute: F) -> Self
pub fn create_reactive_signal<F>(compute: F) -> Self
Creates a reactive attribute Self for conditional attribute values.
This function replaces the inline Signal::create(...) + subscribe_attr_signal(...)
boilerplate that was previously generated by the html! macro for every
attribute value containing an if condition.
§Arguments
Fn() -> String + 'static- A closure that computes the current attribute value. Called on initial render and whenever any signal changes.
§Returns
Self- ASelf::Signalbacked by aSignal<String>that reactively re-evaluates the attribute value on signal updates.
Sourcepub fn merge_class(values: &[Self]) -> Self
pub fn merge_class(values: &[Self]) -> Self
Merges multiple class attribute values into a single Self.
Each input value is adapted into a Self via IntoReactiveValue.
Css values are injected into the DOM and their names are collected.
All non-empty class names are joined with spaces into a final Text attribute.
If any value is signal-backed, the result becomes a reactive Signal attribute
that re-evaluates when any constituent signal changes.
§Arguments
&[Self]- The class attribute values to merge.
§Returns
Self- A merged attribute value containing space-separated class names.
Sourcepub fn merge_style(values: &[Self]) -> Self
pub fn merge_style(values: &[Self]) -> Self
Merges multiple style attribute values into a single Self.
Each input value is expected to be a style string (Text) or a reactive
Signal<String> producing a style string. All non-empty style strings are
joined with spaces into a final combined style attribute.
If any value is signal-backed, the result becomes a reactive Signal attribute.
§Arguments
&[Self]- The style attribute values to merge.
§Returns
Self- A merged attribute value containing the combined CSS style string.
Trait Implementations§
Source§impl Clone for AttributeValue
impl Clone for AttributeValue
Source§fn clone(&self) -> AttributeValue
fn clone(&self) -> AttributeValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AttributeValue
impl Debug for AttributeValue
Source§impl PartialEq for AttributeValue
Visual equality comparison for attribute values.
impl PartialEq for AttributeValue
Visual equality comparison for attribute values.
Compares values by their visual output rather than identity. Signal
values are compared by their current resolved string; when both signals
share the same inner pointer, they are always considered unequal
because the signal may have mutated between VDOM snapshots and .get()
would return the same current value for both, masking the change.
Event values are always considered equal (re-binding is handled by the
handler registry), and Css values are compared by class name.