ListBox

Listbox shows lists

installyarn add @react-spectrum/listbox
version3.0.0-alpha.1
usageimport {ListBox} from '@react-spectrum/listbox'

Example#


<ListBox width={200} aria-label="label">
  <Section title="Justify">
    <Item>Left</Item>
    <Item>Middle</Item>
    <Item>Right</Item>
  </Section>
  <Section title="Align">
    <Item>Top</Item>
    <Item>Center</Item>
    <Item>Bottom</Item>
  </Section>
</ListBox>

Content#


Accessibility#

Internationalization#

Events#


Props#


NameTypeDefaultDescription
autoFocusbooleanFocusStrategy
shouldFocusWrapboolean
childrenReactElement<SectionProps<T>>ReactElement<ItemProps<T>>ReactElement<SectionProps<T>>ReactElement<ItemProps<T>>[](item: T) => ReactElement<SectionProps<T>>ReactElement<ItemProps<T>>The contents of the collection.
disabledKeysIterable<Key>They item keys that are disabled. These items cannot be selected, focused, or otherwise interacted with.
itemsIterable<T>Item objects in the collection or section.
itemKeystringProperty name on each item object to use as the unique key. id or key by default.
isLoadingbooleanWhether the items are currently loading.
selectionModeSelectionModeThe type of selection that is allowed in the collection.
disallowEmptySelectionbooleanWhether the collection allows empty selection.
selectedKeys'all'Iterable<Key>The currently selected keys in the collection (controlled).
defaultSelectedKeys'all'Iterable<Key>The initial selected keys in the collection (uncontrolled).
UNSAFE_classNamestring
UNSAFE_styleCSSProperties
Events
NameTypeDefaultDescription
onLoadMore() => anyHandler that is called when more items should be loaded, e.g. while scrolling near the bottom.
onSelectionChange(keys: Selection) => anyHandler that is called when the selection changes.
Layout
NameTypeDefaultDescription
flexstringnumberboolean
flexGrownumber
flexShrinknumber
flexBasisnumberstring
alignSelf'auto' | 'normal' | 'start' | 'end' | 'flex-start' | 'flex-end' | 'self-start' | 'self-end' | 'center' | 'stretch'
justifySelf'auto' | 'normal' | 'start' | 'end' | 'flex-start' | 'flex-end' | 'self-start' | 'self-end' | 'center' | 'left' | 'right' | 'stretch'
flexOrdernumber
gridAreastring
gridColumnstring
gridRowstring
gridColumnStartstring
gridColumnEndstring
gridRowStartstring
gridRowEndstring
Spacing
NameTypeDefaultDescription
marginDimensionValue
marginTopDimensionValue
marginLeftDimensionValue
marginRightDimensionValue
marginBottomDimensionValue
marginStartDimensionValue
marginEndDimensionValue
marginXDimensionValue
marginYDimensionValue
Sizing
NameTypeDefaultDescription
widthDimensionValue
minWidthDimensionValue
maxWidthDimensionValue
heightDimensionValue
minHeightDimensionValue
maxHeightDimensionValue
Positioning
NameTypeDefaultDescription
position'static' | 'relative' | 'absolute' | 'fixed' | 'sticky'
topDimensionValue
bottomDimensionValue
leftDimensionValue
rightDimensionValue
startDimensionValue
endDimensionValue
zIndexnumber
isHiddenboolean
Accessibility
NameTypeDefaultDescription
rolestring
idstring
tabIndexnumber
aria-labelstringDefines a string value that labels the current element.
aria-labelledbystringIdentifies the element (or elements) that labels the current element.
aria-describedbystringIdentifies the element (or elements) that describes the object.
aria-controlsstringIdentifies the element (or elements) whose contents or presence are controlled by the current element.
aria-ownsstringIdentifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship between DOM elements where the DOM hierarchy cannot be used to represent the relationship.
aria-hiddenboolean'false''true'Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.

Visual options#