Function freya_components::Dropdown
source · pub fn Dropdown<T>(props: DropdownProps<T>) -> Element
Expand description
Select from multiple options, use alongside DropdownItem
.
§Styling
Inherits the DropdownTheme
theme.
§Example
fn app() -> Element {
let values = use_hook(|| vec!["Value A".to_string(), "Value B".to_string(), "Value C".to_string()]);
let mut selected_dropdown = use_signal(|| "Value A".to_string());
rsx!(
Dropdown {
value: selected_dropdown.read().clone(),
for ch in values {
DropdownItem {
value: ch.to_string(),
onclick: {
to_owned![ch];
move |_| selected_dropdown.set(ch.clone())
},
label { "{ch}" }
}
}
}
)
}
§Preview
![Dropdown Preview][dropdown]