Select
A select, also known as a dropdown menu, displays a list of selectable choices and options.
import * as React from 'react';
import { LabeledSelect } from '@itwin/itwinui-react';
export default () => {
return (
<>
<LabeledSelect
label='Select label'
message='Help message'
placeholder='Labeled select'
options={[
{ value: 1, label: 'Item #1' },
{ value: 2, label: 'Item #2' },
{ value: 3, label: 'Item #3' },
]}
/>
</>
);
};
A select is a control element meant to allow the user to select an option from a list. Select menus take up less space since they can be collapsed back into a single line. Use select menus in forms and lists that have many items that each have several options to pick from.
Usage
The basic usage of Select
involves using the options
prop to pass an array of objects with label
and value
properties. The label
is the user-facing text, and the value
is the internal value that will be returned when the option is selected.
The default appearance of the collapsed select menu can also display placeholder text (such as “Select an Option…”) using the placeholder
prop, or a pre-selected option using the value
prop.
Note that this value
prop reflects the value
of the selected option (not the label
), and it must be used in conjunction with the onChange
prop to maintain your state.
With label
To add a label, pass a label
prop to the <LabeledSelect>
component. LabeledSelect
is a simple wrapper around the base Select
with additinal functionality.
With Icon
import * as React from 'react';
import { LabeledSelect } from '@itwin/itwinui-react';
import {
SvgSmileyHappy,
SvgSmileySad,
SvgSmileyNeutral,
} from '@itwin/itwinui-icons-react';
export default () => {
return (
<LabeledSelect
label={'Choose feeling'}
options={[
{
value: 'happy',
label: 'Happy',
startIcon: <SvgSmileyHappy />,
},
{
value: 'neutral',
label: 'Neutral',
startIcon: <SvgSmileyNeutral />,
},
{
value: 'sad',
label: 'Sad',
startIcon: <SvgSmileySad />,
},
]}
placeholder={'How are you today?'}
/>
);
};
Disabled
import * as React from 'react';
import { LabeledSelect } from '@itwin/itwinui-react';
export default () => {
return (
<LabeledSelect
disabled
label={'Disabled Select Label'}
options={[
{
value: 1,
label: 'Item #1',
},
{
value: 2,
label: 'Item #2',
},
{
value: 3,
label: 'Item #3',
},
]}
placeholder={'Placeholder text'}
/>
);
};
The menu can be disabled as its default state, without any option selected; it can be disabled with an option selected; and options in the dropdown menu can be disabled so the user cannot select one or more specific options, depending on context.
Sublabels
If the options have sub-labels, but the field is default-sized, omit the sub-label in the field when it displays a selected option (as shown above).
import * as React from 'react';
import { Select } from '@itwin/itwinui-react';
export default () => {
const options = [
{
value: 1,
label: 'Item #1',
sublabel: 'Sublabel #1',
},
{
value: 2,
label: 'Item #2',
sublabel: 'Sublabel #2',
},
{
value: 3,
label: 'Item #3',
sublabel: 'Sublabel #3',
},
];
return (
<Select
triggerProps={{
'aria-label': 'Select label',
}}
options={options}
placeholder={'Placeholder text'}
size={'large'}
/>
);
};
Statuses
import * as React from 'react';
import { MenuItem, LabeledSelect } from '@itwin/itwinui-react';
export default () => {
const options = [
{
value: 'yellow',
label: 'Yellow',
},
{
value: 'green',
label: 'Green',
},
{
value: 'red',
label: 'Red',
},
];
return (
<LabeledSelect
label={'Choose color'}
options={options}
placeholder={'Placeholder text'}
itemRenderer={(option) => (
<MenuItem
style={{
color: option.value,
}}
>
{option.label}
</MenuItem>
)}
selectedItemRenderer={(option) => (
<span
style={{
backgroundColor: option.value,
}}
>
{option.label}
</span>
)}
/>
);
};
Truncation
Ideally, truncation in select menus should be avoided as much as possible. It is recommended that the collapsed select be wide enough to fit 24 characters, plus the ellipsis symbol. There may be cases where this cannot be followed, so it is only our best recommendation.
import * as React from 'react';
import {
MenuItem,
MiddleTextTruncation,
LabeledSelect,
} from '@itwin/itwinui-react';
import { useCallback, useState } from 'react';
export default () => {
const options = [
{
value:
'MyFileWithAReallyLongNameThatWillBeTruncatedBecauseItIsReallyThatLongSoHardToBelieve_FinalVersion_V2.html',
label:
'MyFileWithAReallyLongNameThatWillBeTruncatedBecauseItIsReallyThatLongSoHardToBelieve_FinalVersion_V2.html',
},
{
value: 'ShortNameFile.jpg',
label: 'ShortNameFile.jpg',
},
{
value: 'SomeOtherFile.dgn',
label: 'SomeOtherFile.dgn',
},
];
const [selectedValue, setSelectedValue] = useState(options[0].value);
const textRenderer = useCallback(
(truncatedText, originalText) => (
<span title={truncatedText !== originalText ? originalText : undefined}>
{truncatedText}
</span>
),
[],
);
return (
<LabeledSelect
label={'Choose file'}
options={options}
value={selectedValue}
onChange={setSelectedValue}
placeholder={'Placeholder text'}
itemRenderer={(option) => (
<MenuItem>
<MiddleTextTruncation
text={option.label}
textRenderer={textRenderer}
/>
</MenuItem>
)}
selectedItemRenderer={(option) => (
<MiddleTextTruncation text={option.label} textRenderer={textRenderer} />
)}
/>
);
};
In certain situations, text truncation is inevitable. This may happen in a select menu containing files or folders that were named by the user.
Native select
By default, the Select
component is rendered as a fully custom select. If you want to use the native <select>
element, you can specify the native
prop.
It is recommended to use the native select when the options are few and simple.
import * as React from 'react';
import { LabeledSelect } from '@itwin/itwinui-react';
export default () => {
return (
<LabeledSelect
native
label='Fruit'
options={[
{ value: 'apple', label: 'Apple' },
{ value: 'kiwi', label: 'Kiwi' },
{ value: 'orange', label: 'Orange' },
]}
placeholder='Pick a fruit'
required
/>
);
};
The native select has some limitations, such as no support for icons and sublabels. However, it is more accessible and works much better on mobile devices, where using a custom dropdown menu hurts the user experience. The native select also has the benefit of participating in the browser’s built-in form validation and autofill.
Borderless
The native
Select can also be rendered without borders, by specifying styleType="borderless"
.
When using the borderless Select, placeholder
is not allowed and it must have a default selected value. If a default value is not specified (using value
or defaultValue
), the first option will be automatically selected.
import * as React from 'react';
import { Select } from '@itwin/itwinui-react';
export default () => {
return (
<Select
native
styleType='borderless'
options={[
{ value: 'apple', label: 'Apple' },
{ value: 'kiwi', label: 'Kiwi' },
{ value: 'orange', label: 'Orange' },
]}
triggerProps={{ 'aria-label': 'Fruit' }}
/>
);
};
Props
Prop | Description | Default |
---|---|---|
label | Label of the select. ReactNode | |
message | Message below the select. Does not apply to 'inline' select. ReactNode | |
status | Status of the select.
Status of select. "positive" | "warning" | "negative" | '' |
svgIcon | @deprecated Pass a <StatusMessage startIcon={svgIcon} /> to the message prop instead.Custom svg icon. Will override status icon if specified. Element | |
required | If true, shows a red asterisk. Form submission is only disabled when using the native prop (i.e. <LabeledSelect native> ).boolean | false |
wrapperProps | Pass props to wrapper element. Omit<Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & { ref?: Ref<...>; }, "as" | "labelPlacement"> & InputGridOwnProps & { ...; } | |
labelProps | Passes properties for label. DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> | |
messageContentProps | Passes properties for message content. Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & { ref?: Ref<HTMLDivElement>; } | |
messageIconProps | Passes properties for message icon. Omit<Omit<DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & { ...; }, "as" | ... 4 more ... | "padded"> & { ...; } & Omit<...> & { ...; } | |
displayStyle | Set display style of label.
Supported values:
"default" | "inline" | 'default' |
slot | string | |
style | CSSProperties | |
title | string | |
key | Key | |
defaultChecked | boolean | |
suppressContentEditableWarning | boolean | |
suppressHydrationWarning | boolean | |
accessKey | string | |
autoFocus | boolean | |
className | string | |
contentEditable | Booleanish | "inherit" | |
contextMenu | string | |
dir | string | |
draggable | Booleanish | |
hidden | boolean | |
id | string | |
lang | string | |
nonce | string | |
spellCheck | Booleanish | |
tabIndex | number | |
translate | "yes" | "no" | |
radioGroup | string | |
role | AriaRole | |
about | string | |
content | string | |
datatype | string | |
inlist | any | |
prefix | string | |
property | string | |
rel | string | |
resource | string | |
rev | string | |
typeof | string | |
vocab | string | |
autoCapitalize | string | |
autoCorrect | string | |
autoSave | string | |
color | string | |
itemProp | string | |
itemScope | boolean | |
itemType | string | |
itemID | string | |
itemRef | string | |
results | number | |
security | string | |
unselectable | "on" | "off" | |
inputMode | Hints at the type of data that might be entered by the user while editing the element or its contents
@see https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute "search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | |
is | Specify that a standard HTML element should behave like a defined custom built-in element
@see https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is string | |
aria-activedescendant | Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application. string | |
aria-atomic | Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute. Booleanish | |
aria-autocomplete | Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be
presented if they are made. "list" | "none" | "inline" | "both" | |
aria-braillelabel | Defines a string value that labels the current element, which is intended to be converted into Braille.
@see aria-label. string | |
aria-brailleroledescription | Defines a human-readable, author-localized abbreviated description for the role of an element, which is intended to be converted into Braille.
@see aria-roledescription. string | |
aria-busy | Booleanish | |
aria-checked | Indicates the current "checked" state of checkboxes, radio buttons, and other widgets.
@see aria-pressed
@see aria-selected. boolean | "true" | "false" | "mixed" | |
aria-colcount | Defines the total number of columns in a table, grid, or treegrid.
@see aria-colindex. number | |
aria-colindex | Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.
@see aria-colcount
@see aria-colspan. number | |
aria-colindextext | Defines a human readable text alternative of aria-colindex.
@see aria-rowindextext. string | |
aria-colspan | Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.
@see aria-colindex
@see aria-rowspan. number | |
aria-controls | Identifies the element (or elements) whose contents or presence are controlled by the current element.
@see aria-owns. string | |
aria-current | Indicates the element that represents the current item within a container or set of related elements. boolean | "time" | "step" | "true" | "false" | "page" | "location" | "date" | |
aria-describedby | Identifies the element (or elements) that describes the object.
@see aria-labelledby string | |
aria-description | Defines a string value that describes or annotates the current element.
@see related aria-describedby. string | |
aria-details | Identifies the element that provides a detailed, extended description for the object.
@see aria-describedby. string | |
aria-disabled | Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.
@see aria-hidden
@see aria-readonly. Booleanish | |
aria-dropeffect | Indicates what functions can be performed when a dragged object is released on the drop target.
@deprecated in ARIA 1.1 "link" | "none" | "copy" | "execute" | "move" | "popup" | |
aria-errormessage | Identifies the element that provides an error message for the object.
@see aria-invalid
@see aria-describedby. string | |
aria-expanded | Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. Booleanish | |
aria-flowto | Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion,
allows assistive technology to override the general default of reading in document source order. string | |
aria-grabbed | Indicates an element's "grabbed" state in a drag-and-drop operation.
@deprecated in ARIA 1.1 Booleanish | |
aria-haspopup | Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. boolean | "dialog" | "menu" | "true" | "false" | "grid" | "listbox" | "tree" | |
aria-hidden | Indicates whether the element is exposed to an accessibility API.
@see aria-disabled. Booleanish | |
aria-invalid | Indicates the entered value does not conform to the format expected by the application.
@see aria-errormessage. boolean | "true" | "false" | "grammar" | "spelling" | |
aria-keyshortcuts | Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element. string | |
aria-label | Defines a string value that labels the current element.
@see aria-labelledby. string | |
aria-labelledby | Identifies the element (or elements) that labels the current element.
@see aria-describedby. string | |
aria-level | Defines the hierarchical level of an element within a structure. number | |
aria-live | Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region. "off" | "assertive" | "polite" | |
aria-modal | Indicates whether an element is modal when displayed. Booleanish | |
aria-multiline | Indicates whether a text box accepts multiple lines of input or only a single line. Booleanish | |
aria-multiselectable | Indicates that the user may select more than one item from the current selectable descendants. Booleanish | |
aria-orientation | Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous. "horizontal" | "vertical" | |
aria-owns | 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.
@see aria-controls. string | |
aria-placeholder | Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value.
A hint could be a sample value or a brief description of the expected format. string | |
aria-posinset | Defines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.
@see aria-setsize. number | |
aria-pressed | Indicates the current "pressed" state of toggle buttons.
@see aria-checked
@see aria-selected. boolean | "true" | "false" | "mixed" | |
aria-readonly | Indicates that the element is not editable, but is otherwise operable.
@see aria-disabled. Booleanish | |
aria-relevant | Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.
@see aria-atomic. "text" | "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals" | |
aria-required | Indicates that user input is required on the element before a form may be submitted. Booleanish | |
aria-roledescription | Defines a human-readable, author-localized description for the role of an element. string | |
aria-rowcount | Defines the total number of rows in a table, grid, or treegrid.
@see aria-rowindex. number | |
aria-rowindex | Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.
@see aria-rowcount
@see aria-rowspan. number | |
aria-rowindextext | Defines a human readable text alternative of aria-rowindex.
@see aria-colindextext. string | |
aria-rowspan | Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.
@see aria-rowindex
@see aria-colspan. number | |
aria-selected | Indicates the current "selected" state of various widgets.
@see aria-checked
@see aria-pressed. Booleanish | |
aria-setsize | Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.
@see aria-posinset. number | |
aria-sort | Indicates if items in a table or grid are sorted in ascending or descending order. "none" | "ascending" | "descending" | "other" | |
aria-valuemax | Defines the maximum allowed value for a range widget. number | |
aria-valuemin | Defines the minimum allowed value for a range widget. number | |
aria-valuenow | Defines the current value for a range widget.
@see aria-valuetext. number | |
aria-valuetext | Defines the human readable text alternative of aria-valuenow for a range widget. string | |
dangerouslySetInnerHTML | { __html: string | TrustedHTML; } | |
onCopy | ClipboardEventHandler<HTMLDivElement> | |
onCopyCapture | ClipboardEventHandler<HTMLDivElement> | |
onCut | ClipboardEventHandler<HTMLDivElement> | |
onCutCapture | ClipboardEventHandler<HTMLDivElement> | |
onPaste | ClipboardEventHandler<HTMLDivElement> | |
onPasteCapture | ClipboardEventHandler<HTMLDivElement> | |
onCompositionEnd | CompositionEventHandler<HTMLDivElement> | |
onCompositionEndCapture | CompositionEventHandler<HTMLDivElement> | |
onCompositionStart | CompositionEventHandler<HTMLDivElement> | |
onCompositionStartCapture | CompositionEventHandler<HTMLDivElement> | |
onCompositionUpdate | CompositionEventHandler<HTMLDivElement> | |
onCompositionUpdateCapture | CompositionEventHandler<HTMLDivElement> | |
onFocus | FocusEventHandler<HTMLDivElement> | |
onFocusCapture | FocusEventHandler<HTMLDivElement> | |
onBlur | FocusEventHandler<HTMLDivElement> | |
onBlurCapture | FocusEventHandler<HTMLDivElement> | |
onChangeCapture | FormEventHandler<HTMLDivElement> | |
onBeforeInput | FormEventHandler<HTMLDivElement> | |
onBeforeInputCapture | FormEventHandler<HTMLDivElement> | |
onInput | FormEventHandler<HTMLDivElement> | |
onInputCapture | FormEventHandler<HTMLDivElement> | |
onReset | FormEventHandler<HTMLDivElement> | |
onResetCapture | FormEventHandler<HTMLDivElement> | |
onSubmit | FormEventHandler<HTMLDivElement> | |
onSubmitCapture | FormEventHandler<HTMLDivElement> | |
onInvalid | FormEventHandler<HTMLDivElement> | |
onInvalidCapture | FormEventHandler<HTMLDivElement> | |
onLoad | ReactEventHandler<HTMLDivElement> | |
onLoadCapture | ReactEventHandler<HTMLDivElement> | |
onError | ReactEventHandler<HTMLDivElement> | |
onErrorCapture | ReactEventHandler<HTMLDivElement> | |
onKeyDown | KeyboardEventHandler<HTMLDivElement> | |
onKeyDownCapture | KeyboardEventHandler<HTMLDivElement> | |
onKeyPress | @deprecated KeyboardEventHandler<HTMLDivElement> | |
onKeyPressCapture | @deprecated KeyboardEventHandler<HTMLDivElement> | |
onKeyUp | KeyboardEventHandler<HTMLDivElement> | |
onKeyUpCapture | KeyboardEventHandler<HTMLDivElement> | |
onAbort | ReactEventHandler<HTMLDivElement> | |
onAbortCapture | ReactEventHandler<HTMLDivElement> | |
onCanPlay | ReactEventHandler<HTMLDivElement> | |
onCanPlayCapture | ReactEventHandler<HTMLDivElement> | |
onCanPlayThrough | ReactEventHandler<HTMLDivElement> | |
onCanPlayThroughCapture | ReactEventHandler<HTMLDivElement> | |
onDurationChange | ReactEventHandler<HTMLDivElement> | |
onDurationChangeCapture | ReactEventHandler<HTMLDivElement> | |
onEmptied | ReactEventHandler<HTMLDivElement> | |
onEmptiedCapture | ReactEventHandler<HTMLDivElement> | |
onEncrypted | ReactEventHandler<HTMLDivElement> | |
onEncryptedCapture | ReactEventHandler<HTMLDivElement> | |
onEnded | ReactEventHandler<HTMLDivElement> | |
onEndedCapture | ReactEventHandler<HTMLDivElement> | |
onLoadedData | ReactEventHandler<HTMLDivElement> | |
onLoadedDataCapture | ReactEventHandler<HTMLDivElement> | |
onLoadedMetadata | ReactEventHandler<HTMLDivElement> | |
onLoadedMetadataCapture | ReactEventHandler<HTMLDivElement> | |
onLoadStart | ReactEventHandler<HTMLDivElement> | |
onLoadStartCapture | ReactEventHandler<HTMLDivElement> | |
onPause | ReactEventHandler<HTMLDivElement> | |
onPauseCapture | ReactEventHandler<HTMLDivElement> | |
onPlay | ReactEventHandler<HTMLDivElement> | |
onPlayCapture | ReactEventHandler<HTMLDivElement> | |
onPlaying | ReactEventHandler<HTMLDivElement> | |
onPlayingCapture | ReactEventHandler<HTMLDivElement> | |
onProgress | ReactEventHandler<HTMLDivElement> | |
onProgressCapture | ReactEventHandler<HTMLDivElement> | |
onRateChange | ReactEventHandler<HTMLDivElement> | |
onRateChangeCapture | ReactEventHandler<HTMLDivElement> | |
onResize | ReactEventHandler<HTMLDivElement> | |
onResizeCapture | ReactEventHandler<HTMLDivElement> | |
onSeeked | ReactEventHandler<HTMLDivElement> | |
onSeekedCapture | ReactEventHandler<HTMLDivElement> | |
onSeeking | ReactEventHandler<HTMLDivElement> | |
onSeekingCapture | ReactEventHandler<HTMLDivElement> | |
onStalled | ReactEventHandler<HTMLDivElement> | |
onStalledCapture | ReactEventHandler<HTMLDivElement> | |
onSuspend | ReactEventHandler<HTMLDivElement> | |
onSuspendCapture | ReactEventHandler<HTMLDivElement> | |
onTimeUpdate | ReactEventHandler<HTMLDivElement> | |
onTimeUpdateCapture | ReactEventHandler<HTMLDivElement> | |
onVolumeChange | ReactEventHandler<HTMLDivElement> | |
onVolumeChangeCapture | ReactEventHandler<HTMLDivElement> | |
onWaiting | ReactEventHandler<HTMLDivElement> | |
onWaitingCapture | ReactEventHandler<HTMLDivElement> | |
onAuxClick | MouseEventHandler<HTMLDivElement> | |
onAuxClickCapture | MouseEventHandler<HTMLDivElement> | |
onClick | MouseEventHandler<HTMLDivElement> | |
onClickCapture | MouseEventHandler<HTMLDivElement> | |
onContextMenu | MouseEventHandler<HTMLDivElement> | |
onContextMenuCapture | MouseEventHandler<HTMLDivElement> | |
onDoubleClick | MouseEventHandler<HTMLDivElement> | |
onDoubleClickCapture | MouseEventHandler<HTMLDivElement> | |
onDrag | DragEventHandler<HTMLDivElement> | |
onDragCapture | DragEventHandler<HTMLDivElement> | |
onDragEnd | DragEventHandler<HTMLDivElement> | |
onDragEndCapture | DragEventHandler<HTMLDivElement> | |
onDragEnter | DragEventHandler<HTMLDivElement> | |
onDragEnterCapture | DragEventHandler<HTMLDivElement> | |
onDragExit | DragEventHandler<HTMLDivElement> | |
onDragExitCapture | DragEventHandler<HTMLDivElement> | |
onDragLeave | DragEventHandler<HTMLDivElement> | |
onDragLeaveCapture | DragEventHandler<HTMLDivElement> | |
onDragOver | DragEventHandler<HTMLDivElement> | |
onDragOverCapture | DragEventHandler<HTMLDivElement> | |
onDragStart | DragEventHandler<HTMLDivElement> | |
onDragStartCapture | DragEventHandler<HTMLDivElement> | |
onDrop | DragEventHandler<HTMLDivElement> | |
onDropCapture | DragEventHandler<HTMLDivElement> | |
onMouseDown | MouseEventHandler<HTMLDivElement> | |
onMouseDownCapture | MouseEventHandler<HTMLDivElement> | |
onMouseEnter | MouseEventHandler<HTMLDivElement> | |
onMouseLeave | MouseEventHandler<HTMLDivElement> | |
onMouseMove | MouseEventHandler<HTMLDivElement> | |
onMouseMoveCapture | MouseEventHandler<HTMLDivElement> | |
onMouseOut | MouseEventHandler<HTMLDivElement> | |
onMouseOutCapture | MouseEventHandler<HTMLDivElement> | |
onMouseOver | MouseEventHandler<HTMLDivElement> | |
onMouseOverCapture | MouseEventHandler<HTMLDivElement> | |
onMouseUp | MouseEventHandler<HTMLDivElement> | |
onMouseUpCapture | MouseEventHandler<HTMLDivElement> | |
onSelect | ReactEventHandler<HTMLDivElement> | |
onSelectCapture | ReactEventHandler<HTMLDivElement> | |
onTouchCancel | TouchEventHandler<HTMLDivElement> | |
onTouchCancelCapture | TouchEventHandler<HTMLDivElement> | |
onTouchEnd | TouchEventHandler<HTMLDivElement> | |
onTouchEndCapture | TouchEventHandler<HTMLDivElement> | |
onTouchMove | TouchEventHandler<HTMLDivElement> | |
onTouchMoveCapture | TouchEventHandler<HTMLDivElement> | |
onTouchStart | TouchEventHandler<HTMLDivElement> | |
onTouchStartCapture | TouchEventHandler<HTMLDivElement> | |
onPointerDown | PointerEventHandler<HTMLDivElement> | |
onPointerDownCapture | PointerEventHandler<HTMLDivElement> | |
onPointerMove | PointerEventHandler<HTMLDivElement> | |
onPointerMoveCapture | PointerEventHandler<HTMLDivElement> | |
onPointerUp | PointerEventHandler<HTMLDivElement> | |
onPointerUpCapture | PointerEventHandler<HTMLDivElement> | |
onPointerCancel | PointerEventHandler<HTMLDivElement> | |
onPointerCancelCapture | PointerEventHandler<HTMLDivElement> | |
onPointerEnter | PointerEventHandler<HTMLDivElement> | |
onPointerEnterCapture | PointerEventHandler<HTMLDivElement> | |
onPointerLeave | PointerEventHandler<HTMLDivElement> | |
onPointerLeaveCapture | PointerEventHandler<HTMLDivElement> | |
onPointerOver | PointerEventHandler<HTMLDivElement> | |
onPointerOverCapture | PointerEventHandler<HTMLDivElement> | |
onPointerOut | PointerEventHandler<HTMLDivElement> | |
onPointerOutCapture | PointerEventHandler<HTMLDivElement> | |
onGotPointerCapture | PointerEventHandler<HTMLDivElement> | |
onGotPointerCaptureCapture | PointerEventHandler<HTMLDivElement> | |
onLostPointerCapture | PointerEventHandler<HTMLDivElement> | |
onLostPointerCaptureCapture | PointerEventHandler<HTMLDivElement> | |
onScroll | UIEventHandler<HTMLDivElement> | |
onScrollCapture | UIEventHandler<HTMLDivElement> | |
onWheel | WheelEventHandler<HTMLDivElement> | |
onWheelCapture | WheelEventHandler<HTMLDivElement> | |
onAnimationStart | AnimationEventHandler<HTMLDivElement> | |
onAnimationStartCapture | AnimationEventHandler<HTMLDivElement> | |
onAnimationEnd | AnimationEventHandler<HTMLDivElement> | |
onAnimationEndCapture | AnimationEventHandler<HTMLDivElement> | |
onAnimationIteration | AnimationEventHandler<HTMLDivElement> | |
onAnimationIterationCapture | AnimationEventHandler<HTMLDivElement> | |
onTransitionEnd | TransitionEventHandler<HTMLDivElement> | |
onTransitionEndCapture | TransitionEventHandler<HTMLDivElement> | |
native | If true, the native <select> element will be rendered.Extra props, such as name can be passed to the <select> using triggerProps .boolean | false |
disabled | Disables select. boolean | false |
size | Modify size of select. "small" | "large" | |
value | Selected option value. Must be a string, because it is passed as an attribute to the native string | T | T[] | |
onChange | Callback invoked when the selected value changes.
Callback function handling change event on select. ((value: string, event: ChangeEvent<HTMLSelectElement>) => void) | ((value: T) => void) | ((value: T, event: SelectValueChangeEvent) => void) | |
options | Array of options that populates the select menu. The value property of each option must be a string.
Array of options that populates the select menu.{ label: string; value: string; disabled?: boolean; }[] | SelectOption<T>[] | |
defaultValue | Default value that is selected on initial render. This is useful when you don't want to
maintain your own state but still want to control the initial value. If not passed, the first option (or placeholder) will be automatically selected. string | number | readonly string[] | |
triggerProps | Props to pass to the select element.
Props to pass to the select button (trigger) element. Omit<Omit<DetailedHTMLProps<SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>, "ref"> & { ...; }, "size"> | (Omit<...> & { ...; }) | |
multiple | Enable multiple selection. boolean | false |
styleType | Style of the select.
Use 'borderless' to hide outline.
LabeledSelect does not support styleType .
styleType is only supported for <Select native> .never | 'default' |
placeholder | Placeholder for when no item is selected. Will be rendered as a disabled option at the top of the list, and automatically selected when no value or defaultValue is provided.Not allowed when styleType is borderless .
Placeholder when no item is selected.ReactNode | |
ref | ForwardedRef<HTMLElement> | |
itemRenderer | Custom renderer for an item in the dropdown list. MenuItem item props are going to be populated if not provided.(option: SelectOption<T>, itemProps: ItemRendererProps) => Element | |
menuClassName | Custom class for menu. string | |
menuStyle | Custom style for menu. CSSProperties | |
popoverProps | Props to customize Popover behavior. Pick<PopoverOptions & { autoUpdateOptions?: { ancestorScroll?: boolean; ancestorResize?: boolean; elementResize?: boolean; animationFrame?: boolean; layoutShift?: boolean; }; interactions?: { ...; }; role?: "dialog" | ... 1 more ... | "listbox"; matchWidth?: boolean; } & Omit<...>, "placement" | ... 3 more ... | "cl... | |
selectedItemRenderer | Custom renderer for the selected item in select.
If multiple is enabled, it will give array of options to render.((option: SelectOption<T>) => Element) | ((options: SelectOption<T>[]) => Element) |