Default Props
v0.7.6 adds support for the Default trait in component syntax, letting you omit props that have sensible defaults.
The .. syntax
When a component struct derives or implements Default, you can now use .. after any explicit props to fill the remaining fields with their default values — identical to Rust's struct update syntax:
1#[derive(Default)]2pub struct Alert {3 pub message: String,4 pub kind: AlertKind, // defaults to AlertKind::Info5 pub dismissible: bool, // defaults to false6}78// Only set what you care about9view! {10 <Alert message={"Saved!".into()} .. />11}
The .. shorthand must appear after all explicit props and before the closing />
Useful for configuration components
This pattern works well for components with many optional settings, such as modals, toasts, tables, or form inputs. Define your defaults once on the struct, and callers only need to specify what differs:
1#[derive(Default)]2pub struct DataTable {3 pub rows: Vec<Row>,4 pub striped: bool, // false5 pub bordered: bool, // false6 pub page_size: usize, // 0 = show all7}89view! {10 // Use all defaults except rows11 <DataTable rows={data} .. />1213 // Override a couple of options14 <DataTable rows={data} striped={true} page_size={25} .. />15}
Upgrading
No breaking changes. Update your dependency and derive Default on any component struct you want to use the shorthand with:
1[dependencies]2tidos = "0.7.6"