# Listbox A listbox widget presents a list of options and allows a user to select one or more of them. A listbox that allows a single option to be chosen is a single-select listbox; one that allows multiple options to be selected is a multi-select listbox. > From [listbox wai-aria best practices](https://www.w3.org/TR/wai-aria-practices/#Listbox) ```js script import { html } from '@lion/core'; import { Required } from '@lion/form-core'; import { loadDefaultFeedbackMessages } from '@lion/validate-messages'; import { listboxData } from './docs/listboxData.js'; import './lion-option.js'; import './lion-listbox.js'; export default { title: 'Forms/Listbox', }; ``` ```js preview-story export const main = () => html` Apple Artichoke Asparagus Banana Beets `; ``` ## Features - Single & Multiple Choice - Orientation - Rotation when using keyboard for selection ## How to use ### Installation ```bash npm i --save @lion/listbox ``` ## Examples ## Multiple choice Add `multiple-choice` flag to allow multiple values to be selected. This will: - keep the listbox overlay open on click of an option - display a list of selected option representations next to the text box - make the value of type `Array` instead of `String` ```js preview-story export const multiple = () => html` Apple Artichoke Asparagus Banana Beets Bell pepper Broccoli Brussels sprout Cabbage Carrot `; ``` ## Orientation When `orientation="horizontal"`, left and right arrow keys will be enabled, plus the screenreader will be informed about the direction of the options. By default, `orientation="horizontal"` is set, which enables up and down arrow keys. ```js preview-story export const orientationHorizontal = () => html` Apple Artichoke Asparagus Banana Beets Bell pepper Broccoli Brussels sprout Cabbage Carrot `; ``` With `multiple-choice` flag configured, multiple options can be checked. ```js preview-story export const orientationHorizontalMultiple = () => html` Apple Artichoke Asparagus Banana Beets Bell pepper Broccoli Brussels sprout Cabbage Carrot `; ``` ## Selection-follows-focus When true, will synchronize activedescendant and selected element on arrow key navigation. This behavior can usually be seen in `