ui/select
Types
Keyboard messages for custom select dropdown component. Note: Native HTML select handles keyboard natively. These messages are for custom select implementations.
pub type Msg {
Open
Close
MoveNext
MovePrev
MoveFirst
MoveLast
Select
TypeAhead(String)
}
Constructors
-
OpenOpen the dropdown (Enter, Space, or ArrowDown)
-
CloseClose the dropdown (Escape)
-
MoveNextMove to next option (ArrowDown)
-
MovePrevMove to previous option (ArrowUp)
-
MoveFirstMove to first option (Home)
-
MoveLastMove to last option (End)
-
SelectSelect the currently highlighted option (Enter)
-
TypeAhead(String)Type-ahead search (Character keys)
Values
pub fn aria_activedescendant(
id: String,
) -> attribute.Attribute(a)
Attribute to indicate the currently active descendant.
pub fn aria_expanded(expanded: Bool) -> attribute.Attribute(a)
Attribute to indicate expanded state.
pub fn keymap(
key_event: keyboard.KeyEvent,
is_open: Bool,
) -> option.Option(Msg)
Keymap for custom select dropdown keyboard navigation. Follows WAI-ARIA select pattern:
- Enter/Space/ArrowDown: Open dropdown
- Escape: Close dropdown
- ArrowDown: Move to next option
- ArrowUp: Move to previous option
- Home: Move to first option
- End: Move to last option
- Enter: Select highlighted option
- Character: Type-ahead search
pub fn option(
attributes: List(attribute.Attribute(a)),
label: String,
option_value: String,
) -> element.Element(a)
pub fn option_element_id(index: Int) -> String
Get the element ID for a select option at the given index.
pub fn option_group(
attributes: List(attribute.Attribute(a)),
label: String,
children: List(element.Element(a)),
) -> element.Element(a)
pub fn select(
attributes: List(attribute.Attribute(a)),
children: List(element.Element(a)),
) -> element.Element(a)
pub fn size(s: Size) -> attribute.Attribute(a)
pub fn variant(v: Variant) -> attribute.Attribute(a)