Select

Select

import Select from "@kiwicom/orbit-components/lib/Select";
<Select options={Option} />

Props

NameTypeDefaultDescription
dataAttrsObjectOptional prop for passing data-* attributes to the input DOM element.
dataTeststringOptional prop for testing purposes.
disabledbooleanfalseIf true, the Select will be disabled.
errorReact.NodeThe error message for the Select. See Functional specs
helpReact.NodeThe help message for the Select.
idstringAdds id HTML attribute to an element.
labelTranslationThe label for the Select.
inlineLabelbooleanIf true the label renders on the left side of the Select.
namestringThe name for the Select.
onBlurevent => void \| PromiseFunction for handling onBlur event.
onChangeevent => void \| PromiseFunction for handling onChange event.
onFocusevent => void \| PromiseFunction for handling onFocus event.
optionsOption[]The content of the Select, passed as array of objects.
placeholderTranslationStringThe placeholder for the Select.
prefixReact.NodeThe prefix component for the Select. See Functional specs
reffuncProp for forwarded ref of the Select. See Functional specs
requiredbooleanfalseIf true, the label is displayed as required.
spaceAfterenumAdditional margin-bottom after component.
tabIndexstring \| numberSpecifies the tab order of an element
valuestring""The value of the Select.
widthstring100%Specifies width of the Select
helpClosablebooleantrueWhether to display help as a closable tooltip, or have it open only while the field is focused, same as error.
customValueTextstringThe custom text alternative of current value. See Functional specs.
ariaLabelstringOptional prop for aria-label value. See Accessibility.

enum

spaceAfter
"none"
"smallest"
"small"
"normal"
"medium"
"large"
"largest"

Option

NameTypeDescription
valuestring \| numberThe value of the Option.
labelstringThe label for the Option.
keystringThe key of the Option.
disabledbooleanIf true, the Option will be disabled.

Functional specs

class Component extends React.PureComponent<Props> {
componentDidMount() {
this.ref.current && this.ref.current.focus();
}
ref: { current: React.ElementRef<*> | null } = React.createRef();
render() {
return <Select ref={this.ref} />;
}
}

Accessibility

  • The ariaLabel prop allows you to specify an aria-label attribute for the select component. This attribute provides additional information to screen readers, enhancing the accessibility of the component. By using ariaLabel, you can ensure that users who rely on assistive technologies receive the necessary context and information about the component’s purpose and functionality.
  • If the label prop is not provided, the ariaLabel prop must be specified to ensure component accessibility.