Component properties
Derives a builder that checks required properties at compile time.
For ButtonProps, the derive generates ButtonPropsBuilder. Its build() method is available only after every required property has been set.
#[derive(Props)]
struct ButtonProps {
#[into]
label: String,
kind: ButtonKind,
#[default]
disabled: bool,
}
let props = ButtonProps::builder()
.label("Save")
.kind(ButtonKind::Primary)
.build();
Field Attributes
Use field attributes to control the builder:
#[default]usesDefault::default()for an omitted property.#[default(expr)]uses a custom fallback instead. The fallback runs only when the property is omitted and does not require the type to implementDefault.#[into]lets the setter accept any value that converts to the field's type throughInto. For example, callers can pass&strfor aStringfield.