The Select component is used to gather input from a user. It is similar in functionality to a <select>
element. Best practice is to use this component as a child of FormGroup
. It’s based on the Fundamental React Select component. We recommend preparing to migrate to the Select component from the current Dropdown component as part of the effort to migrate to the SAP Fiori design language.
Three sizes are supported: 'lg'
(default), 'md'
and 'sm'
. Use the size
property to set the size.
Use the disabled
property to disable a Select. A disabled element is unusable and un-clickable.
Use the readOnly
property to set a Select to read-only mode. A read-only element is focusable but un-clickable.
Use the includeEmptyOption
property to include an empty option for when no option is selected. Be sure to also provide an emptyAriaLabel
for assistive technologies.
Property | Type | Default | Description |
---|---|---|---|
className | String | Any custom classes to add to the element. | |
controlClassName | String | Any custom classes to add to the control wrapping <div> element. | |
disabled | Boolean | false | Controls whether the component is enabled or disabled. |
emptyAriaLabel | String | Required if includeEmptyOption is true | Localized screen reader label for an empty option if included, or if no placeholder is included. |
id | String | Sets the id attribute on the element. | |
includeEmptyOption | Boolean | Set to true to include an empty option. If true, also provide an emptyAriaLabel . | |
listClassName | String | Any custom classes to add to the option list element. | |
listItemClassName | String | Any custom classes to add to add to the list item elements. | |
listItemTextClassName | String | Any custom classes to add to the list item child <span> elements. | |
options | Array | [] | An array of objects with a key and text to render the selectable options. [{ key: string, text: string }] |
placeholder | String | Localized placeholder text of the input. | |
popoverProps | Object | Properties to pass through to the popover. | |
readOnly | Boolean | false | Controls whether the component is read-only. |
required | Boolean | false | Adds the required attribute to the element. NOTE: This does not perform any validation, but rather just marks the field as required. |
selectedKey | String | The key corresponding to the option to be selected on page load. | |
size | String | 'lg' | Size of the element. Options are 'lg' , 'md' , 'sm' . |
triggerClassName | String | Any custom classes to add to the trigger <span> element. | |
validationOverlayProps | Object | Contains all the props to pass to the ValidationOverlay component. See validationOverlayProps for details. | |
validationMessage | Object | An object identifying a validation message. The object will include properties for state and text ; e.g., { state: 'warning', text: 'This is your last warning' } . |
Property | Parameters | Description |
---|---|---|
onChange | event | Callback function fired when option is selected. |
onBlur | event | Callback function for onBlur events. |
onFocus | event | Callback function for onFocus events. |
Property | Parameters | Description |
---|---|---|
className | String | Any custom classes to add to validation popover’s outermost <div> element. |
formMessageProps | Object | Additional props to be spread to the ValidationOverlay’s FormMessage component. |
popperClassName | String | Any custom classes to add to validation popover’s popper <div> element. |
referenceClassName | String | Any custom classes to add to ValidationOverlay’s reference <div> element |
wrapperProps | Object | Additional props to be spread to the popover’s outermost <div> element. |