prop

Attribute Macro prop 

Source
#[prop]
Expand description

Attribute macro for marking component properties.

Properties are values passed from parent to child components.

§Attributes

  • #[prop] - Required property
  • #[prop(default = value)] - Property with default value
  • #[prop(optional)] - Optional property (wrapped in Option)

§Example

#[derive(Component)]
struct MyComponent {
    #[prop]
    required_value: String,

    #[prop(default = 42)]
    with_default: i32,

    #[prop(optional)]
    maybe_value: Option<String>,
}