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

  • Open

    Open the dropdown (Enter, Space, or ArrowDown)

  • Close

    Close the dropdown (Escape)

  • MoveNext

    Move to next option (ArrowDown)

  • MovePrev

    Move to previous option (ArrowUp)

  • MoveFirst

    Move to first option (Home)

  • MoveLast

    Move to last option (End)

  • Select

    Select the currently highlighted option (Enter)

  • TypeAhead(String)

    Type-ahead search (Character keys)

pub type Size {
  Small
  Medium
  Large
}

Constructors

  • Small
  • Medium
  • Large
pub type Variant {
  Default
  Muted
}

Constructors

  • Default
  • Muted

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)
Search Document