Function freya::prelude::Dropdown

pub fn Dropdown<T, 'a>(
    cx: &'a Scoped<'a, DropdownProps<'a, T>>
) -> Option<VNode<'a>>where
    T: PartialEq<T> + 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}" }
                    }
                )
            })
        }
    )
}