Docs

List Box

List Box allows the user to select one or more values from a scrollable list of items.

List Box allows the user to select one or more values from a scrollable list of items.

Open in a
new tab
<ListBox multiple selectedValues={[0, 2]}>
  <Item>Show assignee</Item>
  <Item>Show due date</Item>
  <Item>Show status</Item>
</ListBox>

Although functionally similar to Checkbox Group and Radio Button Group, List Box is designed to be used as a lightweight scrollable selection list, rather than as a form input field.

Dividers

You can use dividers to group related items. Use them sparingly to avoid creating unnecessary visual clutter.

Open in a
new tab
<ListBox multiple selectedValues={[0, 2, 3]}>
  <Item>Show assignee</Item>
  <Item>Show due date</Item>
  <Item>Show status</Item>
  <hr />
  <Item>Show thumbnail</Item>
  <Item>Show preview</Item>
</ListBox>

Disabled Items

Disable items to show that they are currently unavailable for selection.

Open in a
new tab
<ListBox selected={0}>
  <Item>In progress (2)</Item>
  <Item>Done (4)</Item>
  <Item disabled>Cancelled (0)</Item>
</ListBox>
Note
Accessibility

Some assistive technologies don’t announce disabled items.

Selection

List Box supports both single and multiple selection. Single selection allows the user to select only one item, whereas multiple selection enables more than one item to be selected.

Single

Open in a
new tab
<ListBox selected={0}>
  <Item>In progress</Item>
  <Item>Done</Item>
  <Item>Cancelled</Item>
</ListBox>

Multi

Open in a
new tab
<ListBox
  multiple
  selectedValues={selectedValues}
  onSelectedValuesChanged={(e) => setSelectedValues(e.detail.value)}
  style={{ height: '200px' }}
>
  {items.map((person, index) => (
    <Item key={index}>
      {person.firstName} {person.lastName}
    </Item>
  ))}
</ListBox>

Custom Item Presentation

Items can be rendered with rich content instead of plain text. This can be useful to provide additional information in a more legible fashion than appending it to the item text.

Open in a
new tab
<ListBox
  multiple
  selectedValues={selectedValues}
  onSelectedValuesChanged={(e) => setSelectedValues(e.detail.value)}
>
  {items.map((person) => (
    <Item
      value={String(items.indexOf(person))}
      style={{ lineHeight: 'var(--lumo-line-height-m)' }}
      key={items.indexOf(person)}
    >
      <HorizontalLayout style={{ alignItems: 'center' }} theme="spacing">
        <Avatar img={person.pictureUrl} name={`${person.firstName} ${person.lastName}`} />
        <VerticalLayout>
          <span>
            {person.firstName} {person.lastName}
          </span>
          <span
            style={{
              color: 'var(--lumo-secondary-text-color)',
              fontSize: 'var(--lumo-font-size-s)',
            }}
          >
            {person.profession}
          </span>
        </VerticalLayout>
      </HorizontalLayout>
    </Item>
  ))}
</ListBox>

Best Practices

List Box isn’t designed to be used as an input field in forms, and lacks features such as label, helper, and validation errors. See related components later for better options for use in forms. List Box is best suited for use as a lightweight, scrollable, single-column list for single or multi-selection of items.

Component Usage recommendations

Checkbox Group

Input field for selecting multiple options from a list.

Combo Box

Select a value from a filterable overlay. Appropriate for large sets of options. Supports lazy loading and entry of custom values.

Radio Button Group

Select a single option from a list. Optimal accessibility, as all options are visible without any user action.

Select

Input field for selecting a value from a overlay. More compact than a Radio Button Group.

Grid

A more advanced list component for cases where multiple columns, filtering or lazy loading is required.