DioxusLabs / DioxusLabs/dioxus

Implement multiple optional attributes for components

Open
#2,454 0 comments 2 reactions 0 assignees View on GitHub
consistency enhancement
Dominant language
Rust
Stars
39.1k
Forks
1.9k
Avg merge
4d 10h
Merged PRs (30d)
4

Description

## Feature Request

Multiple optional attributes are supported for html elements but it doesn't support for components. This will allow us to initialize attributes conditionaly.

```rs
#[component]
pub fn Text(#[props(optional)] class: String, #[props(optional)] children: Element) -> Element {
rsx! {
label {
class: "w-full text-white",
class: class,
{children}
}
}
}

pub fn Page() -> Element {
let mut my_signall: Signal> = use_signal(|| None);
rsx! {
Text {
class: "cursor-pointer",
class: if {my_signall.read().is_some()} { "text-green-600"}
"Content"
}
}
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.