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>ReactElement<ItemProps>(item: T) => ReactElement<SectionProps>ReactElement<ItemProps>
disabledKeysIterable<Key>
itemsIterable<T>
itemKeystring
isLoadingboolean
selectionModeSelectionMode
selectedKeysIterable<Key>
defaultSelectedKeysIterable<Key>
UNSAFE_classNamestring
UNSAFE_styleCSSProperties
Events
NameTypeDefaultDescription
onLoadMore() => any
onSelectionChange(keys: Set<Key>) => any
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-ownsstring

Identifies 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#