Function freya_components::Dropdown
source · pub fn Dropdown<'a, T>(cx: Scope<'a, DropdownProps<'a, T>>) -> Element<'a>where
T: PartialEq + Clone + Display + 'static,
Expand description
Dropdown
component.
Props
See DropdownProps
.
Styling
Inherits the DropdownTheme
theme.
Example
fn app(cx: Scope) -> Element {
let values = cx.use_hook(|| vec!["A".to_string(), "B".to_string(), "C".to_string()]);
let selected_dropdown = use_state(cx, || "A".to_string());
render!(
Dropdown {
value: selected_dropdown.get().clone(),
values.iter().map(|ch| {
rsx!(
DropdownItem {
value: ch.to_string(),
onclick: move |_| selected_dropdown.set(ch.to_string()),
label { "{ch}" }
}
)
})
}
)
}