Listbox

Listbox is used to select one or more values from a list of items.

9 airports
  • flagJohn F. Kennedy
    JFK
  • flagHeathrow
    LHR
  • flagCharles de Gaulle
    CDG
  • flagFrankfurt
    FRA
  • flagSchiphol
    AMS
  • flagIstanbul
    IST
  • flagDubai
    DXB
  • flagChangi
    SIN
  • flagHaneda
    HND
No selected item
PREVIEW

Listbox is used with the v-model property for two-way value binding along with the options collection. Label and value of an option are defined with the optionLabel and optionValue properties respectively. Note that, when options are simple primitive values such as a string array, no optionLabel and optionValue would be necessary.

  • New York
  • Rome
  • London
  • Istanbul
  • Paris
No selected item
basic-demo

For custom content support define an option slot where the default slot props refers to an option.

  • Australia
    Australia
  • Brazil
    Brazil
  • China
    China
  • Egypt
    Egypt
  • France
    France
  • Germany
    Germany
  • India
    India
  • Japan
    Japan
  • Spain
    Spain
  • United States
    United States
No selected item
option-demo

Enable the checkmark property to display a checkmark indicator next to the selected option. Set highlightOnSelect to false to use checkmark-only styling.

  • New York
  • Rome
  • London
  • Istanbul
  • Paris
No selected item
checkmark-demo

Listbox allows choosing a single item by default, enable multiple property to choose more than one. When the optional metaKeySelection is present, behavior is changed in a way that selecting a new item requires meta key to be present.

  • New York
  • Rome
  • London
  • Istanbul
  • Paris
No selected item
multiple-demo

Use metaKeySelection in multiple mode to require Ctrl / Cmd for additive selection.

Hold Ctrl (or Cmd on macOS) while selecting to keep existing selections.

  • New York
  • Rome
  • London
  • Istanbul
  • Paris
No selected item
metakeyselection-demo

Combine the multiple property with the checkbox property to render checkboxes for each option.

  • New York
  • Rome
  • London
  • Istanbul
  • Paris
No selected item
checkbox-demo

Options can be grouped when a nested data structure is provided by defining optionGroupLabel and optionGroupChildren properties.

  • Germany
  • Berlin
  • Frankfurt
  • Hamburg
  • Munich
  • USA
  • Chicago
  • Los Angeles
  • New York
  • San Francisco
  • Japan
  • Kyoto
  • Osaka
  • Tokyo
  • Yokohama
No selected item
simple-demo

Use the optiongroup slot to customize group headers with custom content like flags.

  • 🇩🇪Germany
  • Berlin
  • Frankfurt
  • Hamburg
  • Munich
  • 🇺🇸USA
  • Chicago
  • Los Angeles
  • New York
  • San Francisco
  • 🇯🇵Japan
  • Kyoto
  • Osaka
  • Tokyo
  • Yokohama
No selected item
custom-demo

Listbox provides built-in filtering that is enabled by adding the filter property.

5 results are available
  • New York
  • Rome
  • London
  • Istanbul
  • Paris
No selected item
filter-demo

Invalid state is displayed using the invalid prop to indicate a failed validation. You can use this style when integrating with form validation libraries.

  • New York
  • Rome
  • London
  • Istanbul
  • Paris
No selected item
invalid-demo

When disabled is present, the element cannot be edited and focused.

  • New York
  • Rome
  • London
  • Istanbul
  • Paris
No selected item
disabled-demo

Use optionDisabled to disable specific items by field name while keeping the listbox itself interactive.

  • New York
  • Rome
  • London
  • Istanbul
  • Paris
No selected item
optiondisabled-demo

Use autoOptionFocus to control initial focused option behavior, selectOnFocus to select options while navigating with focus, and focusOnHover to move focus with mouse hover when the component is focused.

  • New York
  • Rome
  • London
  • Istanbul
  • Paris
No selected item
focusbehavior-demo

VirtualScroller is used to render a long list of options efficiently like 100K records in this demo. The configuration is done with virtualScrollerOptions property, refer to the VirtualScroller for more information about the available options as it is used internally by Listbox.

No selected item
virtualscroll-demo

Listbox integrates seamlessly with the PrimeVue Forms library.

  • New York
  • Rome
  • London
  • Istanbul
  • Paris
1 items selected
forms-demo

Screen Reader

Value to describe the component can be provided aria-labelledby or aria-label props. The list element has a listbox role with the aria-multiselectable attribute that sets to true when multiple selection is enabled. Each list item has an option role with aria-selected and aria-disabled as their attributes.

If filtering is enabled, filterInputProps can be defined to give aria-* props to the input element. Alternatively filterPlaceholder is usually utilized by the screen readers as well.

Keyboard Support

KeyFunction
tabMoves focus to the first selected option, if there is none then first option receives the focus.
up arrowMoves focus to the previous option.
down arrowMoves focus to the next option.
enterToggles the selected state of the focused option.
spaceToggles the selected state of the focused option.
homeMoves focus to the first option.
endMoves focus to the last option.
shift + down arrowMoves focus to the next option and toggles the selection state.
shift + up arrowMoves focus to the previous option and toggles the selection state.
shift + spaceSelects the items between the most recently selected option and the focused option.
control + shift + homeSelects the focused options and all the options up to the first one.
control + shift + endSelects the focused options and all the options down to the last one.
control + aSelects all options.
pageUpJumps visual focus to first option.
pageDownJumps visual focus to last option.
any printable characterMoves focus to the option whose label starts with the characters being typed.

Filter Input Keyboard Support

KeyFunction
down arrowMoves focus to the next option, if there is none then visual focus does not change.
up arrowMoves focus to the previous option, if there is none then visual focus does not change.
left arrowRemoves the visual focus from the current option and moves input cursor to one character left.
right arrowRemoves the visual focus from the current option and moves input cursor to one character right.
homeMoves input cursor at the end, if not then moves focus to the first option.
endMoves input cursor at the beginning, if not then moves focus to the last option.
enterCloses the popup and moves focus to the multiselect element.
escapeCloses the popup and moves focus to the multiselect element.
tabMoves focus to the next focusable element in the component. If there is none, moves focus to next element in page.
Theme Designer