Select
Select allows users to make a single selection or multiple selections from a list of options.Neutral selected states
When the platform-dst-tokens-finesse feature flag is enabled, this component uses the new neutral treatment for selected states.
Motion in Early Access
Motion updates for multi-value Select tags are in Early Access and available behind the platform-dst-motion-uplift-labels feature flag.
Installation
| Install | yarn add @atlaskit/select |
|---|---|
| Source | Bitbucket.org, (opens new window) |
| npm | @atlaskit/select, (opens new window) |
| Bundle | unpkg.com, (opens new window) |
Props
@atlaskit/select is based on the react-select library, and supports many of the same props. If
you're looking for more advanced customization examples that aren't shown here, refer to the
react-select documentation.
| Description | Allow options to be created while the |
|---|---|
| Type | any |
| Description | No description. |
|---|---|
| Type | "default" | "subtle" | "none" |
| Description | HTML ID of an element that should be used as a description (for assistive tech) {@link https://hello.atlassian.net/browse/ENGHEALTH-14529 Internal documentation for deprecation (no external access)}
Use |
|---|---|
| Type | string |
| Description | HTML ID of an element containing an error message related to the input {@link https://hello.atlassian.net/browse/ENGHEALTH-14529 Internal documentation for deprecation (no external access)} aria-errormessage is not supported widely by assistive technologies. Do not use! |
|---|---|
| Type | string |
| Description | Indicate if the value entered in the field is invalid {@link https://hello.atlassian.net/browse/ENGHEALTH-14529 Internal documentation for deprecation (no external access)}
Use |
|---|---|
| Type | boolean | "false" | "true" | "grammar" | "spelling" |
| Description | Aria label (for assistive tech) {@link https://hello.atlassian.net/browse/ENGHEALTH-14529 Internal documentation for deprecation (no external access)}
Use |
|---|---|
| Type | string |
| Description | HTML ID of an element that should be used as the label (for assistive tech) {@link https://hello.atlassian.net/browse/ENGHEALTH-14529 Internal documentation for deprecation (no external access)}
Use |
|---|---|
| Type | string |
| Description | Used to set the priority with which screen reader should treat updates to live regions. The possible settings are: off, polite (default) or assertive {@link https://hello.atlassian.net/browse/ENGHEALTH-14529 Internal documentation for deprecation (no external access)} Will be removed in future versions. |
|---|---|
| Type | "off" | "assertive" | "polite" |
| Description | Customise the messages used by the aria-live component {@link https://hello.atlassian.net/browse/ENGHEALTH-14529 Internal documentation for deprecation (no external access)} |
|---|---|
| Type | AriaLiveMessages<Option, IsMulti, GroupBase<Option>> |
| Description | Focus the control when it is mounted. There are very few cases that this should be used, and using incorrectly may violate accessibility guidelines. |
|---|---|
| Type | boolean |
| Description | Remove the currently focused option when the user presses backspace when Select isClearable or isMulti {@link https://hello.atlassian.net/browse/ENGHEALTH-14529 Internal documentation for deprecation (no external access)}. Will soon be handled automatically to support expected keyboard accessibility. |
|---|---|
| Type | boolean |
| Description | Remove focus from the input when the user selects an option (handy for dismissing the keyboard on touch devices) |
|---|---|
| Type | boolean |
| Description | If cacheOptions is truthy, then the loaded data will be cached. The cache
will remain until |
|---|---|
| Type | any |
| Description | When the user reaches the top/bottom of the menu, prevent scroll on the scroll-parent {@link https://hello.atlassian.net/browse/ENGHEALTH-14529 Internal documentation for deprecation (no external access)} |
|---|---|
| Type | boolean |
| Description | Sets a className attribute on the outer component {@link https://hello.atlassian.net/browse/ENGHEALTH-14529 Internal documentation for deprecation (no external access)}
If used for testing purposes, use the |
|---|---|
| Type | string |
| Description | If provided, all inner components will be given a prefixed className attribute. This is useful when styling via CSS classes instead of the Styles API approach. |
|---|---|
| Type | string |
| Description | Provide classNames based on state for each inner component |
|---|---|
| Type | { clearIndicator?: (props: ClearIndicatorProps<Option, IsMulti, GroupBase<Option>>) => string; container?: (props: ContainerProps<Option, IsMulti, GroupBase<...>>) => string; ... 18 more ...; valueContainer?: (props: ValueContainerProps<...>) => string; } |
| Description | Set the |
|---|---|
| Type | string |
| Description | If If a function, takes a standard javascript
This is useful when you have a scrollable modal and want to portal the menu out, but want to avoid graphical issues. {@link https://hello.atlassian.net/browse/ENGHEALTH-14529 Internal documentation for deprecation (no external access)} |
|---|---|
| Type | boolean | ((event: Event) => boolean) |
| Description | Close the select menu when the user selects an option |
|---|---|
| Type | boolean |
| Description | This complex object includes all the compositional components that are used
in |
|---|---|
| Type | { Option?: React.ComponentType<OptionProps<Option, IsMulti, GroupBase<Option>>>; Group?: React.ComponentType<GroupProps<Option, IsMulti, GroupBase<...>>>; ... 19 more ...; ValueContainer?: React.ComponentType<...>; } |
| Description | Whether the value of the select, e.g. SingleValue, should be displayed in the control. {@link https://hello.atlassian.net/browse/ENGHEALTH-14529 Internal documentation for deprecation (no external access)} |
|---|---|
| Type | boolean |
| Description | You should not be accessing this prop under any circumstances.
It is provided by |
|---|---|
| Type | (payload: AnalyticsEventPayload) => UIAnalyticsEvent |
| Description | Sets the position of the createOption element in your options list. Defaults to 'last' |
|---|---|
| Type | any |
| Description | No description. |
|---|---|
| Type | string |
| Description | No description. |
|---|---|
| Type | boolean |
| Description | The default set of options to show before the user starts searching. When
set to |
|---|---|
| Type | any |
| Description | No description. |
|---|---|
| Type | Option | MultiValue<Option> |
| Description | Delimiter used to join multiple values into a single HTML Input value {@link https://hello.atlassian.net/browse/ENGHEALTH-14529 Internal documentation for deprecation (no external access)} |
|---|---|
| Type | string |
| Description | This sets the aria-describedby attribute. It sets an accessible description for the select, for people who use assistive technology. Use '<HelperMessage>' from '@atlaskit/form' is preferred. |
|---|---|
| Type | string |
| Description | Clear all values when the user presses escape AND the menu is closed. {@link https://hello.atlassian.net/browse/ENGHEALTH-14529 Internal documentation for deprecation (no external access)}. Will soon be handled automatically to support expected keyboard accessibility. |
|---|---|
| Type | boolean |
| Description | Custom method to filter whether an option should be displayed in the menu |
|---|---|
| Type | (option: FilterOptionOption<Option>, inputValue: string) => boolean |
| Description | Sets the form attribute on the input |
|---|---|
| Type | string |
| Description | Gets the label for the "create new ..." option in the menu. Is given the current input value. |
|---|---|
| Type | any |
| Description | Formats group labels in the menu as React components An example can be found in the Replacing builtins documentation. |
|---|---|
| Type | (group: GroupBase<Option>) => React.ReactNode |
| Description | Formats option labels in the menu and control as React components |
|---|---|
| Type | ((data: Option, formatOptionLabelMeta: FormatOptionLabelMeta<Option>) => React.ReactNode) | ((data: Option, formatOptionLabelMeta: FormatOptionLabelMeta<Option>) => React.ReactNode) |
| Description | Returns the data for the new option when it is created. Used to display the
value, and is passed to |
|---|---|
| Type | any |
| Description | Resolves option data to a string to be displayed as the label by components Note: Failure to resolve to a string type can interfere with filtering and screen reader support. |
|---|---|
| Type | (option: Option) => string |
| Description | Resolves option data to a string to compare options and specify value attributes |
|---|---|
| Type | (option: Option) => string |
| Description | Hide the selected option from the menu |
|---|---|
| Type | boolean |
| Description | The id to set on the SelectContainer component. |
|---|---|
| Type | string |
| Description | The id of the search input |
|---|---|
| Type | string |
| Description | The value of the search input |
|---|---|
| Type | string |
| Description | Define an id prefix for the select components e.g. {your-id}-value |
|---|---|
| Type | string | number |
| Description | Is the select value clearable |
|---|---|
| Type | boolean |
| Description | Is the select disabled |
|---|---|
| Type | boolean |
| Description | Is the select invalid |
|---|---|
| Type | boolean |
| Description | Is the select in a state of loading (async) Is the select in a state of loading (async) Will cause the select to be displayed in the loading state, even if the Async select is not currently waiting for loadOptions to resolve |
|---|---|
| Type | boolean |
| Description | Support multiple selected options |
|---|---|
| Type | booleanIsMulti |
| Description | Override the built-in logic to detect whether an option is disabled An example can be found in the Replacing builtins documentation. |
|---|---|
| Type | (option: Option, selectValue: Options<Option>) => boolean |
| Description | Override the built-in logic to detect whether an option is selected |
|---|---|
| Type | (option: Option, selectValue: Options<Option>) => boolean |
| Description | This prop indicates if the component is required. |
|---|---|
| Type | boolean |
| Description | Is the select direction right-to-left {@link https://hello.atlassian.net/browse/ENGHEALTH-14529 Internal documentation for deprecation (no external access)} |
|---|---|
| Type | boolean |
| Description | Whether to enable search functionality |
|---|---|
| Type | boolean |
| Description | Determines whether the "create new ..." option should be displayed based on the current input value, select value and options array. |
|---|---|
| Type | any |
| Description | This sets the aria-label attribute. It sets an accessible name for the select, for people who use assistive technology. Use of a visible label is highly recommended for greater accessibility support. |
|---|---|
| Type | string |
| Description | This sets the aria-labelledby attribute. It sets an accessible name for the select, for people who use assistive technology. Use of a visible label is highly recommended for greater accessibility support. |
|---|---|
| Type | string |
| Description | Async: Text to display when loading options |
|---|---|
| Type | (obj: { inputValue: string; }) => React.ReactNode |
| Description | Function that returns a promise, which is the set of options to be used once the promise resolves. |
|---|---|
| Type | any |
| Description | Maximum height of the menu before scrolling |
|---|---|
| Type | number |
| Description | Minimum height of the menu before flipping |
|---|---|
| Type | number |
| Description | Name of the HTML Input (optional - without this, no input will be rendered) |
|---|---|
| Type | string |
| Description | Text to display when there are no options |
|---|---|
| Type | ((obj: { inputValue: string; }) => React.ReactNode) | ((obj: { inputValue: string; }) => React.ReactNode) |
| Description | Handle blur events on the control |
|---|---|
| Type | (event: React.FocusEvent<HTMLInputElement, Element>) => void |
| Description | Handle change events on the select |
|---|---|
| Type | (newValue: OnChangeValue<Option, IsMulti>, actionMeta: ActionMeta<Option>) => void |
| Description | No description. |
|---|---|
| Type | boolean |
| Description | If provided, this will be called with the input value when a new option is
created, and |
|---|---|
| Type | any |
| Description | Handle focus events on the control |
|---|---|
| Type | (event: React.FocusEvent<HTMLInputElement, Element>) => void |
| Description | Handle change events on the input |
|---|---|
| Type | (newValue: string, actionMeta: InputActionMeta) => void |
| Description | Handle key down events on the select |
|---|---|
| Type | (event: React.KeyboardEvent<HTMLDivElement>) => void |
| Description | Handle the menu closing |
|---|---|
| Type | () => void |
| Description | Handle the menu opening |
|---|---|
| Type | () => void |
| Description | Fired when the user scrolls to the bottom of the menu |
|---|---|
| Type | (event: WheelEvent | TouchEvent) => void |
| Description | Fired when the user scrolls to the top of the menu |
|---|---|
| Type | (event: WheelEvent | TouchEvent) => void |
| Description | Allows control of whether the menu is opened when the Select is clicked {@link https://hello.atlassian.net/browse/ENGHEALTH-14529 Internal documentation for deprecation (no external access)}. Will soon be removed to support expected accessibility interactions. |
|---|---|
| Type | boolean |
| Description | Allows control of whether the menu is opened when the Select is focused {@link https://hello.atlassian.net/browse/ENGHEALTH-14529 Internal documentation for deprecation (no external access)}. Will soon be removed to support expected accessibility interactions. |
|---|---|
| Type | boolean |
| Description | Array of options that populate the select menu |
|---|---|
| Type | readonly (Option | GroupBase<Option>)[] |
| Description | Number of options to jump in menu when page{up|down} keys are used |
|---|---|
| Type | number |
| Description | Placeholder for the select value |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal |
| Description | |
|---|---|
| Type | React.Ref<any> & React.Ref<AtlaskitSelectRefType> |
| Description | Marks the value-holding input as required for form validation {@link https://hello.atlassian.net/browse/ENGHEALTH-14529 Internal documentation for deprecation (no external access)}
Use |
|---|---|
| Type | boolean |
| Description | Status to relay to screen readers {@link https://hello.atlassian.net/browse/ENGHEALTH-14529 Internal documentation for deprecation (no external access)} |
|---|---|
| Type | (obj: { count: number; }) => string |
| Description | Prevents "Escape" keydown event propagation |
|---|---|
| Type | boolean |
| Description | This prop affects the height of the select control. Compact is gridSize() * 4, default is gridSize * 5 |
|---|---|
| Type | "compact" | "default" |
| Description | Style modifier methods {@link https://hello.atlassian.net/browse/ENGHEALTH-14529 Internal documentation for deprecation (no external access)}
Use the |
|---|---|
| Type | { clearIndicator?: (base: any, props: ClearIndicatorProps<Option, IsMulti, GroupBase<Option>>) => any; container?: (base: any, props: ContainerProps<...>) => any; ... 18 more ...; valueContainer?: (base: any, props: ValueContainerProps<...>) => any; } |
| Description | Sets the tabIndex attribute on the input for focus. Since focus is already managed, the only acceptable value to be used is '-1' in rare cases when removing this field from the document tab order is required. |
|---|---|
| Type | number |
| Description | Select the currently focused option when the user presses tab {@link https://hello.atlassian.net/browse/ENGHEALTH-14529 Internal documentation for deprecation (no external access)}. Will soon be handled automatically to support expected keyboard accessibility. |
|---|---|
| Type | boolean |
| Description | A unique string that appears as data attribute data-testid in the rendered code, serving as a hook for automated tests. Use this instead of using ARIA properties as locators.
|
|---|---|
| Type | string |
| Description | No description. |
|---|---|
| Type | boolean |
| Description | Use isInvalid instead. The state of validation if used in a form. |
|---|---|
| Type | "default" | "error" | "success" |
| Description | The value of the select; reflected by the selected option |
|---|---|
| Type | Option | MultiValue<Option> |