Skip to main content

create_reactive_style_attribute

Function create_reactive_style_attribute 

Source
pub fn create_reactive_style_attribute<F>(compute: F) -> AttributeValue
where F: Fn() -> String + 'static,
Expand description

Creates a reactive style AttributeValue that updates when signals change.

This function replaces the inline Signal::new(...) + 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

  • AttributeValue - A AttributeValue::Signal backed by a Signal<String> that reactively re-evaluates the CSS string on signal updates.