ui/autocomplete

Types

Messages for autocomplete keyboard navigation

pub type Msg {
  Open
  Close
  MoveNext
  MovePrev
  Select
  MoveFirst
  MoveLast
  TypeAhead(String)
}

Constructors

  • Open
  • Close
  • MoveNext
  • MovePrev
  • Select
  • MoveFirst
  • MoveLast
  • TypeAhead(String)
pub type Size {
  Small
  Medium
  Large
}

Constructors

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

Constructors

  • Default
  • Muted

Values

pub fn autocomplete(
  attributes: List(attribute.Attribute(a)),
  children: List(element.Element(a)),
) -> element.Element(a)
pub fn input(
  attributes: List(attribute.Attribute(a)),
) -> element.Element(a)
pub fn item(
  attributes: List(attribute.Attribute(a)),
  children: List(element.Element(a)),
) -> element.Element(a)
pub fn keymap(
  key_event: keyboard.KeyEvent,
  is_open: Bool,
) -> option.Option(Msg)

Keymap for autocomplete keyboard navigation

Keyboard interactions:

  • ArrowDown: Open dropdown and move to next option
  • ArrowUp: Open dropdown and move to previous option
  • Enter: Select current option
  • Escape: Close dropdown
  • Home: Move to first option
  • End: Move to last option
  • Type-ahead: Filter options by typing

Follows WAI-ARIA Combobox pattern.

pub fn list(
  attributes: List(attribute.Attribute(a)),
  children: List(element.Element(a)),
) -> element.Element(a)
pub fn size(s: Size) -> attribute.Attribute(a)
Search Document