pub enum SelectVariant {
Default,
Destructive,
Ghost,
}Expand description
Select component with proper accessibility and styling variants
The Select component provides accessible dropdown selection functionality with proper ARIA attributes, keyboard navigation, focus management, and flexible styling.
§Features
- Proper select semantics and accessibility
- Keyboard navigation (Arrow keys, Enter, Escape)
- Focus management and tab navigation
- Multiple variants and sizes
- State management (open/closed, selected value)
- Event handling (change, open, close)
- Integration with form controls
§Example
use leptos::prelude::*;
use radix_leptos_primitives::*;
#[component]
fn MySelect() -> impl IntoView {
let (selected_value, setselected_value) = create_signal("option1".to_string());
let (isopen, set_isopen) = create_signal(false);
let options = [
("option1", "Option 1"),
("option2", "Option 2"),
("option3", "Option 3"),
];
view! {
<Select
value=selected_value
on_value_change=move |value| setselected_value.set(value)
open=isopen
onopen_change=move |open| set_isopen.set(open)
>
<SelectTrigger>
<SelectValue placeholder="Select an option" />
</SelectTrigger>
<SelectContent>
{options.into_iter().map(|(value, label)| {
view! {
<SelectItem value=value.to_string()>
{label}
</SelectItem>
}
}).collect_view()}
</SelectContent>
</Select>
}
}Variants§
Implementations§
Trait Implementations§
Source§impl Clone for SelectVariant
impl Clone for SelectVariant
Source§fn clone(&self) -> SelectVariant
fn clone(&self) -> SelectVariant
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SelectVariant
impl Debug for SelectVariant
Source§impl PartialEq for SelectVariant
impl PartialEq for SelectVariant
impl Copy for SelectVariant
impl StructuralPartialEq for SelectVariant
Auto Trait Implementations§
impl Freeze for SelectVariant
impl RefUnwindSafe for SelectVariant
impl Send for SelectVariant
impl Sync for SelectVariant
impl Unpin for SelectVariant
impl UnwindSafe for SelectVariant
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> SerializableKey for T
impl<T> SerializableKey for T
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.