DioxusLabs / DioxusLabs/docsite
Attribute spreading (`..props.attributes` syntax) is not documented
- Dominant language
- Rust
- Stars
- 206
- Forks
- 208
- Avg merge
- 1h 11m
- Merged PRs (30d)
- 3
Description
Attribute "spreading" (I wish we could find a new name for this.. 😅) is the process of assigning properties from a "catch-all" collection.
This is very useful for developing reusable components, but it's completely missing from the docsite.
Here's an example, adapted from https://github.com/DioxusLabs/dioxus/issues/3844:
```rust
#[derive(Props, PartialEq, Debug, Clone)]
pub struct ChildProps {
#[props(extends = button, extends = GlobalAttributes)]
pub attributes: Vec,
#[props(optional, default = None)]
pub children: Element,
}
#[component]
pub fn Child(props: ChildProps) -> Element {
rsx! {
button {
..props.attributes,
{props.children}
}
}
}
#[component]
pub fn Hero() -> Element {
rsx! {
Child {
class: "hard-to-miss",
style: "border: 1px solid lime;",
"Content here..",
}
}
}
```
It would be very nice to have this feature mentioned in the documentation.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.