Select
Select (@atlaskit/select)
Select는 옵션 목록에서 하나 또는 여러 개를 선택할 수 있게 해 주는 컴포넌트예요. 옵션을 API에서 비동기로 불러오거나, 여러 개를 선택하거나, 사용자가 새 옵션을 만들거나, 팝업 오버레이로 열어야 할 때 각각 알맞은 변형을 제공해요.
출처: 문서
본문
AsyncSelect 컴포넌트
옵션을 비동기로 불러오는 select 컴포넌트예요. 옵션을 API에서 가져오거나 필요할 때 로드할 때 사용해요.
- 키워드: select, async, dropdown, form, api
- 카테고리: form
- 상태: general-availability
예시
import { Label } from '@atlaskit/form/label/default';
import Select from '@atlaskit/select/default';
import { type OptionsType } from '@atlaskit/select/types';
import { cities } from '../common/data';
const filterCities = (inputValue: string) =>
cities.filter((i) => i.label.toLowerCase().includes(inputValue.toLowerCase()));
const promiseOptions = (inputValue: string) =>
new Promise<OptionsType>((resolve) => {
setTimeout(() => {
resolve(filterCities(inputValue));
}, 1000);
});
const WithPromises = () => {
return (
<>
<Label htmlFor="async-select-example">What city do you live in?</Label>
<Select
inputId="async-select-example"
cacheOptions
defaultOptions
loadOptions={promiseOptions}
/>
</>
);
};
export default (): React.JSX.Element => <WithPromises />;
Props
| Prop | Type | Description |
|---|---|---|
additionalInsideElementRefs |
readonly React.RefObject<HTMLElement>[] |
Element refs outside the menu that should be treated as inside its light-dismiss boundary |
allowCreateWhileLoading |
any |
Allow options to be created while the isLoading prop is true |
appearance |
"none" | "default" | "subtle" |
|
autoFocus |
boolean |
Focus the control when it is mounted |
blurInputOnSelect |
boolean |
Remove focus from the input when the user selects an option (handy for dismissing the keyboard on touch devices) |
cacheOptions |
any |
If cacheOptions is truthy, then the loaded data will be cached |
classNamePrefix |
string |
If provided, all inner components will be given a prefixed className attribute |
classNames |
{ clearIndicator?: (props: ClearIndicatorProps<Option, IsMulti, GroupBase<Option>>) => string; container?: (props: ContainerProps<Option, IsMulti, GroupBase<...>>) => string; ... 18 more ...; valueContainer?: (props: ValueContainerProps<...>) => string; } |
Provide classNames based on state for each inner component |
clearControlLabel |
string |
Set the aria-label for the clear icon button |
closeMenuOnSelect |
boolean |
Close the select menu when the user selects an option |
components |
{ Option?: React.ComponentType<OptionProps<Option, IsMulti, GroupBase<Option>>>; Group?: React.ComponentType<GroupProps<Option, IsMulti, GroupBase<...>>>; ... 19 more ...; ValueContainer?: React.ComponentType<...>; } |
This complex object includes all the compositional components that are used |
in react-select |
||
createOptionPosition |
any |
Sets the position of the createOption element in your options list |
defaultInputValue |
string |
|
defaultMenuIsOpen |
boolean |
|
defaultOptions |
any |
The default set of options to show before the user starts searching |
defaultValue |
Option | MultiValue<Option> |
|
descriptionId |
string |
This sets the aria-describedby attribute |
filterOption |
(option: FilterOptionOption<Option>, inputValue: string) => boolean |
Custom method to filter whether an option should be displayed in the menu |
form |
string |
Sets the form attribute on the input |
formatCreateLabel |
any |
Gets the label for the "create new |
formatGroupLabel |
(group: GroupBase<Option>) => React.ReactNode |
Formats group labels in the menu as React components |
An example can be found in the [Replacing builtins](https://react-select |
| formatOptionLabel | ((data: Option, formatOptionLabelMeta: FormatOptionLabelMeta<Option>) => React.ReactNode) \| ((data: Option, formatOptionLabelMeta: FormatOptionLabelMeta<Option>) => React.ReactNode) | Formats option labels in the menu and control as React components |
| getNewOptionData | any | Returns the data for the new option when it is created |
| getOptionLabel | (option: Option) => string | 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 |
| getOptionValue | (option: Option) => string | Resolves option data to a string to compare options and specify value attributes |
| hideSelectedOptions | boolean | Hide the selected option from the menu |
| id | string | The id to set on the SelectContainer component |
| inputId | string | The id of the search input |
| inputValue | string | The value of the search input |
| instanceId | string \| number | Define an id prefix for the select components e |
| isClearable | boolean | Is the select value clearable |
| isDisabled | boolean | Is the select disabled |
| isInvalid | boolean | Is the select invalid |
| isLoading | boolean | 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 |
| isMulti | boolean | Support multiple selected options |
| isOptionDisabled | (option: Option, selectValue: Options<Option>) => boolean | Override the built-in logic to detect whether an option is disabled
An example can be found in the [Replacing builtins](https://react-select |
| isOptionSelected | (option: Option, selectValue: Options<Option>) => boolean | Override the built-in logic to detect whether an option is selected |
| isRequired | boolean | This prop indicates if the component is required |
| isSearchable | boolean | Whether to enable search functionality |
| isValidNewOption | any | Determines whether the "create new |
| label | string | This sets the aria-label attribute |
| labelId | string | This sets the aria-labelledby attribute |
| loadingMessage | (obj: { inputValue: string; }) => React.ReactNode | Async: Text to display when loading options |
| loadOptions | any | Function that returns a promise, which is the set of options to be used
once the promise resolves |
| maxMenuHeight | number | Maximum height of the menu before scrolling |
| menuIsOpen | boolean | Whether the menu is open |
| menuPlacement | "auto" \| "top" \| "bottom" | Default placement of the menu in relation to the control |
| menuPortalTarget | HTMLElement | Whether the menu should use a portal, and where it should attach
An example can be found in the [Portaling](https://react-select |
| menuPosition | "fixed" \| "absolute" | The CSS position value of the menu, when "fixed" extra layout management is required |
| menuRenderMode | "inline" \| "popup" | Controls how the menu is rendered |
| menuShouldScrollIntoView | boolean | Whether the menu should be scrolled into view when it opens |
| minMenuHeight | number | Minimum height of the menu before flipping |
| name | string | Name of the HTML Input (optional - without this, no input will be rendered) |
| noOptionsMessage | ((obj: { inputValue: string; }) => React.ReactNode) \| ((obj: { inputValue: string; }) => React.ReactNode) | Text to display when there are no options |
| onBlur | (event: React.FocusEvent<HTMLInputElement, Element>) => void | Handle blur events on the control |
| onChange | (newValue: OnChangeValue<Option, IsMulti>, actionMeta: ActionMeta<Option>) => void | Handle change events on the select |
| onClickPreventDefault | boolean | |
| onCreateOption | any | If provided, this will be called with the input value when a new option is
created, and onChange will not be called |
| onFocus | (event: React.FocusEvent<HTMLInputElement, Element>) => void | Handle focus events on the control |
| onInputChange | (newValue: string, actionMeta: InputActionMeta) => void | Handle change events on the input |
| onKeyDown | (event: React.KeyboardEvent<HTMLDivElement>) => void | Handle key down events on the select |
| onMenuClose | () => void | Handle the menu closing |
| onMenuOpen | () => void | Handle the menu opening |
| onMenuScrollToBottom | (event: WheelEvent \| TouchEvent) => void | Fired when the user scrolls to the bottom of the menu |
| onMenuScrollToTop | (event: WheelEvent \| TouchEvent) => void | Fired when the user scrolls to the top of the menu |
| options | readonly (Option \| GroupBase<Option>)[] | Array of options that populate the select menu |
| pageSize | number | Number of options to jump in menu when page{up|down} keys are used |
| placeholder | string \| number \| boolean \| React.ReactElement<any, string \| React.JSXElementConstructor<any>> \| Iterable<React.ReactNode> \| React.ReactPortal | Placeholder for the select value |
| shouldPreventEscapePropagation | boolean | Prevents "Escape" keydown event propagation |
| spacing | "default" \| "compact" | This prop affects the height of the select control |
| tabIndex | number | Sets the tabIndex attribute on the input for focus |
| value | Option \| MultiValue<Option> | The value of the select; reflected by the selected option |
사용 가이드라인
- API 또는 비동기 데이터에서 불러온 옵션에 사용해요
- 가져오는 동안 명확한 로딩 상태를 보여 줘요
- 사용자가 반복해서 검색할 때는 옵션을 캐시해요
CheckboxSelect 컴포넌트
각 옵션에 체크박스 표시가 있는 다중 선택 select예요. 여러 항목을 선택할 때 시각적으로 명확한 확인이 필요할 때 사용해요.
- 키워드: select, checkbox, multi, dropdown, form
- 카테고리: form
- 상태: general-availability
예시
import { Label } from '@atlaskit/form/label/default';
import { CheckboxSelect } from '@atlaskit/select/checkbox-select';
import { cities } from '../common/data';
const SelectCheckboxExample = (): React.JSX.Element => (
<>
<Label htmlFor="checkbox-select-example">What cities have you lived in?</Label>
<CheckboxSelect
inputId="checkbox-select-example"
testId="select"
options={[
...cities,
{
label:
"Super long name that no one will ever read because it's way too long to be a realistic option but it will highlight the flexbox grow and shrink styles",
value: 'test',
},
]}
placeholder=""
/>
</>
);
export default SelectCheckboxExample;
Props
| Prop | Type | Description |
|---|---|---|
additionalInsideElementRefs |
readonly React.RefObject<HTMLElement>[] |
Element refs outside the menu that should be treated as inside its light-dismiss boundary |
appearance |
"none" | "default" | "subtle" |
|
autoFocus |
boolean |
Focus the control when it is mounted |
blurInputOnSelect |
boolean |
Remove focus from the input when the user selects an option (handy for dismissing the keyboard on touch devices) |
classNamePrefix |
string |
If provided, all inner components will be given a prefixed className attribute |
classNames |
{ clearIndicator?: (props: ClearIndicatorProps<OptionT, true, GroupBase<OptionT>>) => string; container?: (props: ContainerProps<OptionT, true, GroupBase<...>>) => string; ... 18 more ...; valueContainer?: (props: ValueContainerProps<...>) => string; } |
Provide classNames based on state for each inner component |
clearControlLabel |
string |
Set the aria-label for the clear icon button |
closeMenuOnSelect |
boolean |
Close the select menu when the user selects an option |
components |
{ Option?: React.ComponentType<OptionProps<OptionT, true, GroupBase<OptionT>>>; Group?: React.ComponentType<GroupProps<OptionT, true, GroupBase<OptionT>>>; ... 19 more ...; ValueContainer?: React.ComponentType<...>; } |
This complex object includes all the compositional components that are used |
in react-select |
||
defaultInputValue |
string |
|
defaultMenuIsOpen |
boolean |
|
defaultValue |
OptionT | MultiValue<OptionT> |
|
descriptionId |
string |
This sets the aria-describedby attribute |
filterOption |
(option: FilterOptionOption<OptionT>, inputValue: string) => boolean |
Custom method to filter whether an option should be displayed in the menu |
form |
string |
Sets the form attribute on the input |
formatGroupLabel |
(group: GroupBase<OptionT>) => React.ReactNode |
Formats group labels in the menu as React components |
An example can be found in the [Replacing builtins](https://react-select |
| formatOptionLabel | (data: OptionT, formatOptionLabelMeta: FormatOptionLabelMeta<OptionT>) => React.ReactNode | |
| getOptionLabel | (option: OptionT) => string | 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 |
| getOptionValue | (option: OptionT) => string | Resolves option data to a string to compare options and specify value attributes |
| hideSelectedOptions | boolean | Hide the selected option from the menu |
| id | string | The id to set on the SelectContainer component |
| inputId | string | The id of the search input |
| inputValue | string | The value of the search input |
| instanceId | string \| number | Define an id prefix for the select components e |
| isClearable | boolean | Is the select value clearable |
| isDisabled | boolean | Is the select disabled |
| isInvalid | boolean | Is the select invalid |
| isLoading | boolean | Is the select in a state of loading (async) |
| isMulti | boolean | Support multiple selected options |
| isOptionDisabled | (option: OptionT, selectValue: Options<OptionT>) => boolean | Override the built-in logic to detect whether an option is disabled
An example can be found in the [Replacing builtins](https://react-select |
| isOptionSelected | (option: OptionT, selectValue: Options<OptionT>) => boolean | Override the built-in logic to detect whether an option is selected |
| isRequired | boolean | This prop indicates if the component is required |
| isSearchable | boolean | Whether to enable search functionality |
| label | string | This sets the aria-label attribute |
| labelId | string | This sets the aria-labelledby attribute |
| loadingMessage | (obj: { inputValue: string; }) => React.ReactNode | Async: Text to display when loading options |
| maxMenuHeight | number | Maximum height of the menu before scrolling |
| menuIsOpen | boolean | Whether the menu is open |
| menuPlacement | "auto" \| "top" \| "bottom" | Default placement of the menu in relation to the control |
| menuPortalTarget | HTMLElement | Whether the menu should use a portal, and where it should attach
An example can be found in the [Portaling](https://react-select |
| menuPosition | "fixed" \| "absolute" | The CSS position value of the menu, when "fixed" extra layout management is required |
| menuRenderMode | "inline" \| "popup" | Controls how the menu is rendered |
| menuShouldScrollIntoView | boolean | Whether the menu should be scrolled into view when it opens |
| minMenuHeight | number | Minimum height of the menu before flipping |
| name | string | Name of the HTML Input (optional - without this, no input will be rendered) |
| noOptionsMessage | (obj: { inputValue: string; }) => React.ReactNode | |
| onBlur | (event: React.FocusEvent<HTMLInputElement, Element>) => void | Handle blur events on the control |
| onChange | (newValue: MultiValue<OptionT>, actionMeta: ActionMeta<OptionT>) => void | Handle change events on the select |
| onClickPreventDefault | boolean | |
| onFocus | (event: React.FocusEvent<HTMLInputElement, Element>) => void | Handle focus events on the control |
| onInputChange | (newValue: string, actionMeta: InputActionMeta) => void | Handle change events on the input |
| onKeyDown | (event: React.KeyboardEvent<HTMLDivElement>) => void | Handle key down events on the select |
| onMenuClose | () => void | Handle the menu closing |
| onMenuOpen | () => void | Handle the menu opening |
| onMenuScrollToBottom | (event: WheelEvent \| TouchEvent) => void | Fired when the user scrolls to the bottom of the menu |
| onMenuScrollToTop | (event: WheelEvent \| TouchEvent) => void | Fired when the user scrolls to the top of the menu |
| options | readonly (OptionT \| GroupBase<OptionT>)[] | Array of options that populate the select menu |
| pageSize | number | Number of options to jump in menu when page{up|down} keys are used |
| placeholder | string \| number \| boolean \| React.ReactElement<any, string \| React.JSXElementConstructor<any>> \| Iterable<React.ReactNode> \| React.ReactPortal | Placeholder for the select value |
| shouldPreventEscapePropagation | boolean | Prevents "Escape" keydown event propagation |
| spacing | "default" \| "compact" | This prop affects the height of the select control |
| tabIndex | number | Sets the tabIndex attribute on the input for focus |
| value | OptionT \| MultiValue<OptionT> | The value of the select; reflected by the selected option |
사용 가이드라인
- 체크박스 표시가 명확성을 높여 줄 때 다중 선택에 사용해요
CountrySelect 컴포넌트
국가 데이터와 함께 국가 선택용으로 미리 구성된 select예요.
- 키워드: select, country, dropdown, form, localization
- 카테고리: form
- 상태: general-availability
예시
import { Label } from '@atlaskit/form/label/default';
import { CountrySelect } from '@atlaskit/select/country-select';
const CountrySelectExample = (): React.JSX.Element => (
<>
<Label htmlFor="country-select-example">What country do you live in?</Label>
<CountrySelect inputId="country-select-example" placeholder="" />
</>
);
export default CountrySelectExample;
Props
| Prop | Type | Description |
|---|---|---|
additionalInsideElementRefs |
readonly React.RefObject<HTMLElement>[] |
Element refs outside the menu that should be treated as inside its light-dismiss boundary |
appearance |
"none" | "default" | "subtle" |
|
autoFocus |
boolean |
Focus the control when it is mounted |
blurInputOnSelect |
boolean |
Remove focus from the input when the user selects an option (handy for dismissing the keyboard on touch devices) |
classNamePrefix |
string |
If provided, all inner components will be given a prefixed className attribute |
classNames |
{ clearIndicator?: (props: ClearIndicatorProps<Country, false, GroupBase<Country>>) => string; container?: (props: ContainerProps<Country, false, GroupBase<...>>) => string; ... 18 more ...; valueContainer?: (props: ValueContainerProps<...>) => string; } |
Provide classNames based on state for each inner component |
clearControlLabel |
string |
Set the aria-label for the clear icon button |
closeMenuOnSelect |
boolean |
Close the select menu when the user selects an option |
components |
{ Option?: React.ComponentType<OptionProps<Country, false, GroupBase<Country>>>; Group?: React.ComponentType<GroupProps<Country, false, GroupBase<Country>>>; ... 19 more ...; ValueContainer?: React.ComponentType<...>; } |
This complex object includes all the compositional components that are used |
in react-select |
||
defaultInputValue |
string |
|
defaultMenuIsOpen |
boolean |
|
defaultValue |
Country | MultiValue<Country> |
|
descriptionId |
string |
This sets the aria-describedby attribute |
filterOption |
(option: FilterOptionOption<Country>, inputValue: string) => boolean |
Custom method to filter whether an option should be displayed in the menu |
form |
string |
Sets the form attribute on the input |
formatGroupLabel |
(group: GroupBase<Country>) => React.ReactNode |
Formats group labels in the menu as React components |
An example can be found in the [Replacing builtins](https://react-select |
| formatOptionLabel | (data: Country, formatOptionLabelMeta: FormatOptionLabelMeta<Country>) => React.ReactNode | |
| getOptionLabel | (option: Country) => string | 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 |
| getOptionValue | (option: Country) => string | Resolves option data to a string to compare options and specify value attributes |
| hideSelectedOptions | boolean | Hide the selected option from the menu |
| id | string | The id to set on the SelectContainer component |
| inputId | string | The id of the search input |
| inputValue | string | The value of the search input |
| instanceId | string \| number | Define an id prefix for the select components e |
| isClearable | boolean | Is the select value clearable |
| isDisabled | boolean | Is the select disabled |
| isInvalid | boolean | Is the select invalid |
| isLoading | boolean | Is the select in a state of loading (async) |
| isMulti | boolean | Support multiple selected options |
| isOptionDisabled | (option: Country, selectValue: Options<Country>) => boolean | Override the built-in logic to detect whether an option is disabled
An example can be found in the [Replacing builtins](https://react-select |
| isOptionSelected | (option: Country, selectValue: Options<Country>) => boolean | Override the built-in logic to detect whether an option is selected |
| isRequired | boolean | This prop indicates if the component is required |
| isSearchable | boolean | Whether to enable search functionality |
| label | string | This sets the aria-label attribute |
| labelId | string | This sets the aria-labelledby attribute |
| loadingMessage | (obj: { inputValue: string; }) => React.ReactNode | Async: Text to display when loading options |
| maxMenuHeight | number | Maximum height of the menu before scrolling |
| menuIsOpen | boolean | Whether the menu is open |
| menuPlacement | "auto" \| "top" \| "bottom" | Default placement of the menu in relation to the control |
| menuPortalTarget | HTMLElement | Whether the menu should use a portal, and where it should attach
An example can be found in the [Portaling](https://react-select |
| menuPosition | "fixed" \| "absolute" | The CSS position value of the menu, when "fixed" extra layout management is required |
| menuRenderMode | "inline" \| "popup" | Controls how the menu is rendered |
| menuShouldScrollIntoView | boolean | Whether the menu should be scrolled into view when it opens |
| minMenuHeight | number | Minimum height of the menu before flipping |
| name | string | Name of the HTML Input (optional - without this, no input will be rendered) |
| noOptionsMessage | (obj: { inputValue: string; }) => React.ReactNode | |
| onBlur | (event: React.FocusEvent<HTMLInputElement, Element>) => void | Handle blur events on the control |
| onChange | (newValue: Country, actionMeta: ActionMeta<Country>) => void | Handle change events on the select |
| onClickPreventDefault | boolean | |
| onFocus | (event: React.FocusEvent<HTMLInputElement, Element>) => void | Handle focus events on the control |
| onInputChange | (newValue: string, actionMeta: InputActionMeta) => void | Handle change events on the input |
| onKeyDown | (event: React.KeyboardEvent<HTMLDivElement>) => void | Handle key down events on the select |
| onMenuClose | () => void | Handle the menu closing |
| onMenuOpen | () => void | Handle the menu opening |
| onMenuScrollToBottom | (event: WheelEvent \| TouchEvent) => void | Fired when the user scrolls to the bottom of the menu |
| onMenuScrollToTop | (event: WheelEvent \| TouchEvent) => void | Fired when the user scrolls to the top of the menu |
| options | readonly (Country \| GroupBase<Country>)[] | Array of options that populate the select menu |
| pageSize | number | Number of options to jump in menu when page{up|down} keys are used |
| placeholder | string \| number \| boolean \| React.ReactElement<any, string \| React.JSXElementConstructor<any>> \| Iterable<React.ReactNode> \| React.ReactPortal | Placeholder for the select value |
| shouldPreventEscapePropagation | boolean | Prevents "Escape" keydown event propagation |
| spacing | "default" \| "compact" | This prop affects the height of the select control |
| tabIndex | number | Sets the tabIndex attribute on the input for focus |
| value | Country \| MultiValue<Country> | The value of the select; reflected by the selected option |
사용 가이드라인
- 폼에서 국가 선택에 사용해요
- 내장된 국가 옵션과 검색 기능을 제공해요
CreatableSelect 컴포넌트
사용자가 새 옵션을 만들 수 있는 select예요. 사용자가 미리 정의된 목록에 없는 사용자 정의 값을 추가할 수 있을 때 사용해요.
- 키워드: select, creatable, dropdown, form, custom
- 카테고리: form
- 상태: general-availability
예시
import React, { Component } from 'react';
import { Label } from '@atlaskit/form/label/default';
import CreatableSelect from '@atlaskit/select/creatable-select';
import { type OptionType, type ValueType } from '@atlaskit/select/types';
const defaultOptions = [
{ label: 'Adelaide', value: 'adelaide' },
{ label: 'Brisbane', value: 'brisbane' },
{ label: 'Canberra', value: 'canberra' },
{ label: 'Darwin', value: 'darwin' },
{ label: 'Hobart', value: 'hobart' },
{ label: 'Melbourne', value: 'melbourne' },
{ label: 'Perth', value: 'perth' },
{ label: 'Sydney', value: 'sydney' },
];
const createOption = (label: string) => ({
label,
value: label.toLowerCase().replace(/\W/g, ''),
});
interface State {
isLoading: boolean;
options: Array<{ label: string; value: string }>;
value?: ValueType<OptionType>;
}
class CreatableAdvanced extends Component<{}, State> {
state: State = {
isLoading: false,
options: defaultOptions,
value: undefined,
};
handleChange = (newValue: any, actionMeta: any) => {
console.group('Value Changed');
console.log(newValue);
console.log(`action: ${actionMeta.action}`);
console.groupEnd();
this.setState({ value: newValue });
};
handleCreate = (inputValue: any) => {
// We do not assume how users would like to add newly created options to the existing options list.
// Instead we pass users through the new value in the onCreate prop
this.setState({ isLoading: true });
console.group('Option created');
console.log('Wait a moment...');
const { options } = this.state;
const newOption = createOption(inputValue);
console.log(newOption);
console.groupEnd();
this.setState({
isLoading: false,
options: [...options, newOption],
value: newOption,
});
};
render() {
const { isLoading, options, value } = this.state;
return (
<>
<Label htmlFor="createable-select-example">What city do you live in?</Label>
<CreatableSelect
inputId="createable-select-example"
isClearable
clearControlLabel="Clear city"
isDisabled={isLoading}
isLoading={isLoading}
onChange={this.handleChange}
onCreateOption={this.handleCreate}
options={options}
value={value}
/>
</>
);
}
}
export default (): React.JSX.Element => <CreatableAdvanced />;
Props
| Prop | Type | Description |
|---|---|---|
additionalInsideElementRefs |
readonly React.RefObject<HTMLElement>[] |
Element refs outside the menu that should be treated as inside its light-dismiss boundary |
allowCreateWhileLoading |
any |
Allow options to be created while the isLoading prop is true |
appearance |
"none" | "default" | "subtle" |
|
autoFocus |
boolean |
Focus the control when it is mounted |
blurInputOnSelect |
boolean |
Remove focus from the input when the user selects an option (handy for dismissing the keyboard on touch devices) |
cacheOptions |
any |
If cacheOptions is truthy, then the loaded data will be cached |
classNamePrefix |
string |
If provided, all inner components will be given a prefixed className attribute |
classNames |
{ clearIndicator?: (props: ClearIndicatorProps<Option, IsMulti, GroupBase<Option>>) => string; container?: (props: ContainerProps<Option, IsMulti, GroupBase<...>>) => string; ... 18 more ...; valueContainer?: (props: ValueContainerProps<...>) => string; } |
Provide classNames based on state for each inner component |
clearControlLabel |
string |
Set the aria-label for the clear icon button |
closeMenuOnSelect |
boolean |
Close the select menu when the user selects an option |
components |
{ Option?: React.ComponentType<OptionProps<Option, IsMulti, GroupBase<Option>>>; Group?: React.ComponentType<GroupProps<Option, IsMulti, GroupBase<...>>>; ... 19 more ...; ValueContainer?: React.ComponentType<...>; } |
This complex object includes all the compositional components that are used |
in react-select |
||
createOptionPosition |
any |
Sets the position of the createOption element in your options list |
defaultInputValue |
string |
|
defaultMenuIsOpen |
boolean |
|
defaultOptions |
any |
The default set of options to show before the user starts searching |
defaultValue |
Option | MultiValue<Option> |
|
descriptionId |
string |
This sets the aria-describedby attribute |
filterOption |
(option: FilterOptionOption<Option>, inputValue: string) => boolean |
Custom method to filter whether an option should be displayed in the menu |
form |
string |
Sets the form attribute on the input |
formatCreateLabel |
any |
Gets the label for the "create new |
formatGroupLabel |
(group: GroupBase<Option>) => React.ReactNode |
Formats group labels in the menu as React components |
An example can be found in the [Replacing builtins](https://react-select |
| formatOptionLabel | ((data: Option, formatOptionLabelMeta: FormatOptionLabelMeta<Option>) => React.ReactNode) \| ((data: Option, formatOptionLabelMeta: FormatOptionLabelMeta<Option>) => React.ReactNode) | Formats option labels in the menu and control as React components |
| getNewOptionData | any | Returns the data for the new option when it is created |
| getOptionLabel | (option: Option) => string | 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 |
| getOptionValue | (option: Option) => string | Resolves option data to a string to compare options and specify value attributes |
| hideSelectedOptions | boolean | Hide the selected option from the menu |
| id | string | The id to set on the SelectContainer component |
| inputId | string | The id of the search input |
| inputValue | string | The value of the search input |
| instanceId | string \| number | Define an id prefix for the select components e |
| isClearable | boolean | Is the select value clearable |
| isDisabled | boolean | Is the select disabled |
| isInvalid | boolean | Is the select invalid |
| isLoading | boolean | 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 |
| isMulti | boolean | Support multiple selected options |
| isOptionDisabled | (option: Option, selectValue: Options<Option>) => boolean | Override the built-in logic to detect whether an option is disabled
An example can be found in the [Replacing builtins](https://react-select |
| isOptionSelected | (option: Option, selectValue: Options<Option>) => boolean | Override the built-in logic to detect whether an option is selected |
| isRequired | boolean | This prop indicates if the component is required |
| isSearchable | boolean | Whether to enable search functionality |
| isValidNewOption | any | Determines whether the "create new |
| label | string | This sets the aria-label attribute |
| labelId | string | This sets the aria-labelledby attribute |
| loadingMessage | (obj: { inputValue: string; }) => React.ReactNode | Async: Text to display when loading options |
| loadOptions | any | Function that returns a promise, which is the set of options to be used
once the promise resolves |
| maxMenuHeight | number | Maximum height of the menu before scrolling |
| menuIsOpen | boolean | Whether the menu is open |
| menuPlacement | "auto" \| "top" \| "bottom" | Default placement of the menu in relation to the control |
| menuPortalTarget | HTMLElement | Whether the menu should use a portal, and where it should attach
An example can be found in the [Portaling](https://react-select |
| menuPosition | "fixed" \| "absolute" | The CSS position value of the menu, when "fixed" extra layout management is required |
| menuRenderMode | "inline" \| "popup" | Controls how the menu is rendered |
| menuShouldScrollIntoView | boolean | Whether the menu should be scrolled into view when it opens |
| minMenuHeight | number | Minimum height of the menu before flipping |
| name | string | Name of the HTML Input (optional - without this, no input will be rendered) |
| noOptionsMessage | ((obj: { inputValue: string; }) => React.ReactNode) \| ((obj: { inputValue: string; }) => React.ReactNode) | Text to display when there are no options |
| onBlur | (event: React.FocusEvent<HTMLInputElement, Element>) => void | Handle blur events on the control |
| onChange | (newValue: OnChangeValue<Option, IsMulti>, actionMeta: ActionMeta<Option>) => void | Handle change events on the select |
| onClickPreventDefault | boolean | |
| onCreateOption | any | If provided, this will be called with the input value when a new option is
created, and onChange will not be called |
| onFocus | (event: React.FocusEvent<HTMLInputElement, Element>) => void | Handle focus events on the control |
| onInputChange | (newValue: string, actionMeta: InputActionMeta) => void | Handle change events on the input |
| onKeyDown | (event: React.KeyboardEvent<HTMLDivElement>) => void | Handle key down events on the select |
| onMenuClose | () => void | Handle the menu closing |
| onMenuOpen | () => void | Handle the menu opening |
| onMenuScrollToBottom | (event: WheelEvent \| TouchEvent) => void | Fired when the user scrolls to the bottom of the menu |
| onMenuScrollToTop | (event: WheelEvent \| TouchEvent) => void | Fired when the user scrolls to the top of the menu |
| options | readonly (Option \| GroupBase<Option>)[] | Array of options that populate the select menu |
| pageSize | number | Number of options to jump in menu when page{up|down} keys are used |
| placeholder | string \| number \| boolean \| React.ReactElement<any, string \| React.JSXElementConstructor<any>> \| Iterable<React.ReactNode> \| React.ReactPortal | Placeholder for the select value |
| shouldPreventEscapePropagation | boolean | Prevents "Escape" keydown event propagation |
| spacing | "default" \| "compact" | This prop affects the height of the select control |
| tabIndex | number | Sets the tabIndex attribute on the input for focus |
| value | Option \| MultiValue<Option> | The value of the select; reflected by the selected option |
사용 가이드라인
- 사용자가 커스텀 옵션을 추가해야 할 때 사용해요
- 만들기 전에 새 값을 검증해요
PopupSelect 컴포넌트
팝업 오버레이에서 열리는 select예요. select를 포털이나 오버레이 컨텍스트에서 렌더링해야 할 때 사용해요.
- 키워드: select, popup, dropdown, overlay, portal
- 카테고리: form
- 상태: general-availability
예시
import Button from '@atlaskit/button/default/button';
import ChevronDownIcon from '@atlaskit/icon/core/chevron-down';
import { PopupSelect } from '@atlaskit/select/popup-select';
const options = [
{ label: 'accessibility', value: 'accessibility' },
{ label: 'analytics', value: 'analytics' },
{ label: 'ktlo', value: 'ktlo' },
{ label: 'testing', value: 'testing' },
{ label: 'regression', value: 'regression' },
{ label: 'layering', value: 'layering' },
{ label: 'innovation', value: 'innovation' },
{ label: 'new-feature', value: 'new' },
{ label: 'existing', value: 'existing' },
{ label: 'wont-do', value: 'wont-do' },
];
const PopupSelectExample = (): React.JSX.Element => {
return (
<PopupSelect
placeholder=""
options={options}
target={({ isOpen, ...triggerProps }) => (
<Button {...triggerProps} iconAfter={ChevronDownIcon}>
Label
</Button>
)}
/>
);
};
export default PopupSelectExample;
Props
| Prop | Type | Description |
|---|---|---|
additionalInsideElementRefs |
readonly RefObject<HTMLElement>[] |
Element refs outside the menu that should be treated as inside its light-dismiss boundary |
appearance |
"none" | "default" | "subtle" |
|
autoFocus |
boolean |
Focus the control when it is mounted |
blurInputOnSelect |
boolean |
Remove focus from the input when the user selects an option (handy for dismissing the keyboard on touch devices) |
classNamePrefix |
string |
If provided, all inner components will be given a prefixed className attribute |
classNames |
{ clearIndicator?: (props: ClearIndicatorProps<Option, IsMulti, GroupBase<Option>>) => string; container?: (props: ContainerProps<Option, IsMulti, GroupBase<...>>) => string; ... 18 more ...; valueContainer?: (props: ValueContainerProps<...>) => string; } |
Provide classNames based on state for each inner component |
clearControlLabel |
string |
Set the aria-label for the clear icon button |
closeMenuOnSelect |
boolean |
Defines whether the menu should close when selected |
components |
{ Option?: ComponentType<OptionProps<Option, IsMulti, GroupBase<Option>>>; Group?: ComponentType<GroupProps<Option, IsMulti, GroupBase<...>>>; ... 19 more ...; ValueContainer?: ComponentType<...>; } |
This complex object includes all the compositional components that are used |
in react-select |
||
defaultInputValue |
string |
|
defaultIsOpen |
boolean |
|
defaultMenuIsOpen |
boolean |
|
defaultValue |
Option | MultiValue<Option> |
|
descriptionId |
string |
This sets the aria-describedby attribute |
filterOption |
(option: FilterOptionOption<Option>, inputValue: string) => boolean |
Custom method to filter whether an option should be displayed in the menu |
footer |
string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
The footer content shown at the bottom of the popup, underneath the select options |
form |
string |
Sets the form attribute on the input |
formatGroupLabel |
(group: GroupBase<Option>) => ReactNode |
Formats group labels in the menu as React components |
An example can be found in the [Replacing builtins](https://react-select |
| formatOptionLabel | (data: Option, formatOptionLabelMeta: FormatOptionLabelMeta<Option>) => ReactNode | Formats option labels in the menu and control as React components |
| getOptionLabel | (option: Option) => string | 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 |
| getOptionValue | (option: Option) => string | Resolves option data to a string to compare options and specify value attributes |
| hideSelectedOptions | boolean | Hide the selected option from the menu |
| id | string | The id to set on the SelectContainer component |
| inputId | string | The id of the search input |
| inputValue | string | The value of the search input |
| instanceId | string \| number | Define an id prefix for the select components e |
| isClearable | boolean | Is the select value clearable |
| isDisabled | boolean | Is the select disabled |
| isInvalid | boolean | This prop indicates if the component is in an error state |
| isLoading | boolean | Is the select in a state of loading (async) |
| isMulti | boolean | Support multiple selected options |
| isOpen | boolean | |
| isOptionDisabled | (option: Option, selectValue: Options<Option>) => boolean | Override the built-in logic to detect whether an option is disabled
An example can be found in the [Replacing builtins](https://react-select |
| isOptionSelected | (option: Option, selectValue: Options<Option>) => boolean | Override the built-in logic to detect whether an option is selected |
| isRequired | boolean | This prop indicates if the component is required |
| isSearchable | boolean | If false, renders a select with no search field |
| label | string | This gives an accessible name to the input for people who use assistive technology |
| labelId | string | This sets the aria-labelledby attribute |
| loadingMessage | (obj: { inputValue: string; }) => ReactNode | Async: Text to display when loading options |
| maxMenuHeight | number | Maximum height of the menu before scrolling |
| maxMenuWidth | string \| number | The maximum width for the popup menu |
| menuIsOpen | boolean | Whether the menu is open |
| menuPlacement | "auto" \| "top" \| "bottom" | Default placement of the menu in relation to the control |
| menuPortalTarget | HTMLElement | Whether the menu should use a portal, and where it should attach
An example can be found in the [Portaling](https://react-select |
| menuPosition | "fixed" \| "absolute" | The CSS position value of the menu, when "fixed" extra layout management is required |
| menuShouldScrollIntoView | boolean | Whether the menu should be scrolled into view when it opens |
| minMenuHeight | number | Minimum height of the menu before flipping |
| minMenuWidth | string \| number | The maximum width for the popup menu |
| name | string | Name of the HTML Input (optional - without this, no input will be rendered) |
| noOptionsMessage | (obj: { inputValue: string; }) => ReactNode | Text to display when there are no options |
| onBlur | (event: FocusEvent<HTMLInputElement, Element>) => void | Handle blur events on the control |
| onChange | (newValue: OnChangeValue<Option, IsMulti>, actionMeta: ActionMeta<Option>) => void | Handle change events on the select |
| onFocus | (event: FocusEvent<HTMLInputElement, Element>) => void | Handle focus events on the control |
| onInputChange | (newValue: string, actionMeta: InputActionMeta) => void | Handle change events on the input |
| onKeyDown | (event: KeyboardEvent<HTMLDivElement>) => void | Handle key down events on the select |
| onMenuClose | () => void | Handle the menu closing |
| onMenuOpen | () => void | Handle the menu opening |
| onMenuScrollToBottom | (event: globalThis.WheelEvent \| globalThis.TouchEvent) => void | Fired when the user scrolls to the bottom of the menu |
| onMenuScrollToTop | (event: globalThis.WheelEvent \| globalThis.TouchEvent) => void | Fired when the user scrolls to the top of the menu |
| options | readonly (Option \| GroupBase<Option>)[] | Array of options that populate the select menu |
| pageSize | number | Number of options to jump in menu when page{up|down} keys are used |
| placeholder | string \| number \| boolean \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal | Placeholder for the select value |
| popperProps | { strategy?: PositioningStrategy; placement?: Placement; innerRef?: Ref<any>; modifiers?: readonly Modifier<Modifiers, object>[]; referenceElement?: HTMLElement \| VirtualElement; onFirstUpdate?: (state: Partial<...>) => void; } | The props passed down to React Popper |
| searchThreshold | number | The maximum number of options the select can contain without rendering the search field |
| shouldCloseMenuOnTab | boolean | Defines whether the menu should be closed by pressing the Tab key |
| shouldKeepInputOnSelect | boolean | If true, the input value will be kept when an option is selected |
| shouldPreventEscapePropagation | boolean | Prevents "Escape" keydown event propagation |
| spacing | "default" \| "compact" | Use this to set whether the component uses compact or standard spacing |
| tabIndex | number | Sets the tabIndex attribute on the input for focus |
| target | (options: PopupSelectTriggerProps & { isOpen: boolean; }) => ReactNode | Render props used to anchor the popup to your content |
| value | Option \| MultiValue<Option> | The value of the select; reflected by the selected option |
사용 가이드라인
- select를 오버레이/포털에서 렌더링해야 할 때 사용해요
- 모달과 함께 쓸 때 z-index와 레이어링을 고려해요
- 포커스 관리가 잘 되도록 해요
RadioSelect 컴포넌트
각 옵션에 라디오 표시가 있는 단일 선택 select예요. 라디오 스타일의 선택 표시가 필요할 때 사용해요.
- 키워드: select, radio, single, dropdown, form
- 카테고리: form
- 상태: general-availability
예시
import { Label } from '@atlaskit/form/label/default';
import { RadioSelect } from '@atlaskit/select/radio-select';
import { cities } from '../common/data';
const SelectRadioExample = (): React.JSX.Element => (
<>
<Label htmlFor="radio-select-example">What city do you live in?</Label>
<RadioSelect
inputId="radio-select-example"
testId="react-select"
options={[
...cities,
{
label: "Super long name that no one will ever read because it's way too long",
value: 'test',
},
]}
placeholder=""
/>
</>
);
export default SelectRadioExample;
Props
| Prop | Type | Description |
|---|---|---|
additionalInsideElementRefs |
readonly RefObject<HTMLElement>[] |
Element refs outside the menu that should be treated as inside its light-dismiss boundary |
appearance |
"none" | "default" | "subtle" |
|
autoFocus |
boolean |
Focus the control when it is mounted |
blurInputOnSelect |
boolean |
Remove focus from the input when the user selects an option (handy for dismissing the keyboard on touch devices) |
classNamePrefix |
string |
If provided, all inner components will be given a prefixed className attribute |
classNames |
{ clearIndicator?: (props: ClearIndicatorProps<OptionType, false, GroupBase<OptionType>>) => string; container?: (props: ContainerProps<...>) => string; ... 18 more ...; valueContainer?: (props: ValueContainerProps<...>) => string; } |
Provide classNames based on state for each inner component |
clearControlLabel |
string |
Set the aria-label for the clear icon button |
closeMenuOnSelect |
boolean |
Close the select menu when the user selects an option |
components |
{ Option?: ComponentType<OptionProps<OptionType, false, GroupBase<OptionType>>>; Group?: ComponentType<GroupProps<OptionType, false, GroupBase<...>>>; ... 19 more ...; ValueContainer?: ComponentType<...>; } |
This complex object includes all the compositional components that are used |
in react-select |
||
defaultInputValue |
string |
|
defaultMenuIsOpen |
boolean |
|
defaultValue |
OptionType | MultiValue<OptionType> |
|
descriptionId |
string |
This sets the aria-describedby attribute |
filterOption |
(option: FilterOptionOption<OptionType>, inputValue: string) => boolean |
Custom method to filter whether an option should be displayed in the menu |
form |
string |
Sets the form attribute on the input |
formatGroupLabel |
(group: GroupBase<OptionType>) => ReactNode |
Formats group labels in the menu as React components |
An example can be found in the [Replacing builtins](https://react-select |
| formatOptionLabel | (data: OptionType, formatOptionLabelMeta: FormatOptionLabelMeta<OptionType>) => ReactNode | |
| getOptionLabel | (option: OptionType) => string | 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 |
| getOptionValue | (option: OptionType) => string | Resolves option data to a string to compare options and specify value attributes |
| hideSelectedOptions | boolean | Hide the selected option from the menu |
| id | string | The id to set on the SelectContainer component |
| inputId | string | The id of the search input |
| inputValue | string | The value of the search input |
| instanceId | string \| number | Define an id prefix for the select components e |
| isClearable | boolean | Is the select value clearable |
| isDisabled | boolean | Is the select disabled |
| isInvalid | boolean | Is the select invalid |
| isLoading | boolean | Is the select in a state of loading (async) |
| isMulti | boolean | Support multiple selected options |
| isOptionDisabled | (option: OptionType, selectValue: Options<OptionType>) => boolean | Override the built-in logic to detect whether an option is disabled
An example can be found in the [Replacing builtins](https://react-select |
| isOptionSelected | (option: OptionType, selectValue: Options<OptionType>) => boolean | Override the built-in logic to detect whether an option is selected |
| isRequired | boolean | This prop indicates if the component is required |
| isSearchable | boolean | Whether to enable search functionality |
| label | string | This sets the aria-label attribute |
| labelId | string | This sets the aria-labelledby attribute |
| loadingMessage | (obj: { inputValue: string; }) => ReactNode | Async: Text to display when loading options |
| maxMenuHeight | number | Maximum height of the menu before scrolling |
| menuIsOpen | boolean | Whether the menu is open |
| menuPlacement | "auto" \| "top" \| "bottom" | Default placement of the menu in relation to the control |
| menuPortalTarget | HTMLElement | Whether the menu should use a portal, and where it should attach
An example can be found in the [Portaling](https://react-select |
| menuPosition | "fixed" \| "absolute" | The CSS position value of the menu, when "fixed" extra layout management is required |
| menuRenderMode | "inline" \| "popup" | Controls how the menu is rendered |
| menuShouldScrollIntoView | boolean | Whether the menu should be scrolled into view when it opens |
| minMenuHeight | number | Minimum height of the menu before flipping |
| name | string | Name of the HTML Input (optional - without this, no input will be rendered) |
| noOptionsMessage | (obj: { inputValue: string; }) => ReactNode | |
| onBlur | (event: FocusEvent<HTMLInputElement, Element>) => void | Handle blur events on the control |
| onChange | (newValue: OptionType, actionMeta: ActionMeta<OptionType>) => void | Handle change events on the select |
| onClickPreventDefault | boolean | |
| onFocus | (event: FocusEvent<HTMLInputElement, Element>) => void | Handle focus events on the control |
| onInputChange | (newValue: string, actionMeta: InputActionMeta) => void | Handle change events on the input |
| onKeyDown | (event: KeyboardEvent<HTMLDivElement>) => void | Handle key down events on the select |
| onMenuClose | () => void | Handle the menu closing |
| onMenuOpen | () => void | Handle the menu opening |
| onMenuScrollToBottom | (event: globalThis.WheelEvent \| globalThis.TouchEvent) => void | Fired when the user scrolls to the bottom of the menu |
| onMenuScrollToTop | (event: globalThis.WheelEvent \| globalThis.TouchEvent) => void | Fired when the user scrolls to the top of the menu |
| options | readonly (OptionType \| GroupBase<OptionType>)[] | Array of options that populate the select menu |
| pageSize | number | Number of options to jump in menu when page{up|down} keys are used |
| placeholder | string \| number \| boolean \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal | Placeholder for the select value |
| shouldPreventEscapePropagation | boolean | Prevents "Escape" keydown event propagation |
| spacing | "default" \| "compact" | This prop affects the height of the select control |
| tabIndex | number | Sets the tabIndex attribute on the input for focus |
| value | OptionType \| MultiValue<OptionType> | The value of the select; reflected by the selected option |
사용 가이드라인
- 라디오 표시가 명확성을 높여 줄 때 단일 선택에 사용해요
Select 컴포넌트
Select는 사용자가 옵션 목록에서 단일 선택 또는 다중 선택을 할 수 있게 해 줘요.
- 키워드: select, dropdown, combobox, form, input, options, choice, picker
- 카테고리: form
- 상태: general-availability
예시
import { Label } from '@atlaskit/form/label/default';
import Select from '@atlaskit/select/default';
export default function SelectAppearanceDefault(): React.JSX.Element {
return (
<>
<Label htmlFor="default-appearance-example">Favorite fruit</Label>
<Select
inputId="default-appearance-example"
appearance="default"
options={[
{ label: 'Apple', value: 'a' },
{ label: 'Banana', value: 'b' },
]}
/>
</>
);
}
Props
| Prop | Type | Description |
|---|---|---|
additionalInsideElementRefs |
readonly React.RefObject<HTMLElement>[] |
Element refs outside the menu that should be treated as inside its light-dismiss boundary |
allowCreateWhileLoading |
any |
Allow options to be created while the isLoading prop is true |
appearance |
"none" | "default" | "subtle" |
|
autoFocus |
boolean |
Focus the control when it is mounted |
blurInputOnSelect |
boolean |
Remove focus from the input when the user selects an option (handy for dismissing the keyboard on touch devices) |
cacheOptions |
any |
If cacheOptions is truthy, then the loaded data will be cached |
classNamePrefix |
string |
If provided, all inner components will be given a prefixed className attribute |
classNames |
{ clearIndicator?: (props: ClearIndicatorProps<Option, IsMulti, GroupBase<Option>>) => string; container?: (props: ContainerProps<Option, IsMulti, GroupBase<...>>) => string; ... 18 more ...; valueContainer?: (props: ValueContainerProps<...>) => string; } |
Provide classNames based on state for each inner component |
clearControlLabel |
string |
Set the aria-label for the clear icon button |
closeMenuOnSelect |
boolean |
Close the select menu when the user selects an option |
components |
{ Option?: React.ComponentType<OptionProps<Option, IsMulti, GroupBase<Option>>>; Group?: React.ComponentType<GroupProps<Option, IsMulti, GroupBase<...>>>; ... 19 more ...; ValueContainer?: React.ComponentType<...>; } |
This complex object includes all the compositional components that are used |
in react-select |
||
createOptionPosition |
any |
Sets the position of the createOption element in your options list |
defaultInputValue |
string |
|
defaultMenuIsOpen |
boolean |
|
defaultOptions |
any |
The default set of options to show before the user starts searching |
defaultValue |
Option | MultiValue<Option> |
|
descriptionId |
string |
This sets the aria-describedby attribute |
filterOption |
(option: FilterOptionOption<Option>, inputValue: string) => boolean |
Custom method to filter whether an option should be displayed in the menu |
form |
string |
Sets the form attribute on the input |
formatCreateLabel |
any |
Gets the label for the "create new |
formatGroupLabel |
(group: GroupBase<Option>) => React.ReactNode |
Formats group labels in the menu as React components |
An example can be found in the [Replacing builtins](https://react-select |
| formatOptionLabel | ((data: Option, formatOptionLabelMeta: FormatOptionLabelMeta<Option>) => React.ReactNode) \| ((data: Option, formatOptionLabelMeta: FormatOptionLabelMeta<Option>) => React.ReactNode) | Formats option labels in the menu and control as React components |
| getNewOptionData | any | Returns the data for the new option when it is created |
| getOptionLabel | (option: Option) => string | 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 |
| getOptionValue | (option: Option) => string | Resolves option data to a string to compare options and specify value attributes |
| hideSelectedOptions | boolean | Hide the selected option from the menu |
| id | string | The id to set on the SelectContainer component |
| inputId | string | The id of the search input |
| inputValue | string | The value of the search input |
| instanceId | string \| number | Define an id prefix for the select components e |
| isClearable | boolean | Is the select value clearable |
| isDisabled | boolean | Is the select disabled |
| isInvalid | boolean | Is the select invalid |
| isLoading | boolean | 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 |
| isMulti | boolean | Support multiple selected options |
| isOptionDisabled | (option: Option, selectValue: Options<Option>) => boolean | Override the built-in logic to detect whether an option is disabled
An example can be found in the [Replacing builtins](https://react-select |
| isOptionSelected | (option: Option, selectValue: Options<Option>) => boolean | Override the built-in logic to detect whether an option is selected |
| isRequired | boolean | This prop indicates if the component is required |
| isSearchable | boolean | Whether to enable search functionality |
| isValidNewOption | any | Determines whether the "create new |
| label | string | This sets the aria-label attribute |
| labelId | string | This sets the aria-labelledby attribute |
| loadingMessage | (obj: { inputValue: string; }) => React.ReactNode | Async: Text to display when loading options |
| loadOptions | any | Function that returns a promise, which is the set of options to be used
once the promise resolves |
| maxMenuHeight | number | Maximum height of the menu before scrolling |
| menuIsOpen | boolean | Whether the menu is open |
| menuPlacement | "auto" \| "top" \| "bottom" | Default placement of the menu in relation to the control |
| menuPortalTarget | HTMLElement | Whether the menu should use a portal, and where it should attach
An example can be found in the [Portaling](https://react-select |
| menuPosition | "fixed" \| "absolute" | The CSS position value of the menu, when "fixed" extra layout management is required |
| menuRenderMode | "inline" \| "popup" | Controls how the menu is rendered |
| menuShouldScrollIntoView | boolean | Whether the menu should be scrolled into view when it opens |
| minMenuHeight | number | Minimum height of the menu before flipping |
| name | string | Name of the HTML Input (optional - without this, no input will be rendered) |
| noOptionsMessage | ((obj: { inputValue: string; }) => React.ReactNode) \| ((obj: { inputValue: string; }) => React.ReactNode) | Text to display when there are no options |
| onBlur | (event: React.FocusEvent<HTMLInputElement, Element>) => void | Handle blur events on the control |
| onChange | (newValue: OnChangeValue<Option, IsMulti>, actionMeta: ActionMeta<Option>) => void | Handle change events on the select |
| onClickPreventDefault | boolean | |
| onCreateOption | any | If provided, this will be called with the input value when a new option is
created, and onChange will not be called |
| onFocus | (event: React.FocusEvent<HTMLInputElement, Element>) => void | Handle focus events on the control |
| onInputChange | (newValue: string, actionMeta: InputActionMeta) => void | Handle change events on the input |
| onKeyDown | (event: React.KeyboardEvent<HTMLDivElement>) => void | Handle key down events on the select |
| onMenuClose | () => void | Handle the menu closing |
| onMenuOpen | () => void | Handle the menu opening |
| onMenuScrollToBottom | (event: WheelEvent \| TouchEvent) => void | Fired when the user scrolls to the bottom of the menu |
| onMenuScrollToTop | (event: WheelEvent \| TouchEvent) => void | Fired when the user scrolls to the top of the menu |
| options | readonly (Option \| GroupBase<Option>)[] | Array of options that populate the select menu |
| pageSize | number | Number of options to jump in menu when page{up|down} keys are used |
| placeholder | string \| number \| boolean \| React.ReactElement<any, string \| React.JSXElementConstructor<any>> \| Iterable<React.ReactNode> \| React.ReactPortal | Placeholder for the select value |
| shouldPreventEscapePropagation | boolean | Prevents "Escape" keydown event propagation |
| spacing | "default" \| "compact" | This prop affects the height of the select control |
| tabIndex | number | Sets the tabIndex attribute on the input for focus |
| value | Option \| MultiValue<Option> | The value of the select; reflected by the selected option |
사용 가이드라인
- 목록에서 하나 이상을 고를 때 사용해요. 폼과 인라인 편집에서 흔히 쓰여요
- 필드에 보이는 라벨을 사용해요. placeholder만 라벨로 쓰지 마세요 (placeholder는 사라지고 접근성도 없어요)
- 논리적인 순서를 사용해요 (예: 가장 많이 선택된 것 먼저, 숫자 순)
- 옵션이 너무 많아 사용자를 압도하지 않도록 해요
- 긴 옵션 목록에는 검색을 활성화해요
- 비동기 데이터의 로딩 상태를 고려해요
- 알파벳순 정렬은 피해요 (지역화가 불가능해요). 번역 가능한 옵션 목록에는 논리적인 순서를 사용해요
콘텐츠 가이드라인
- 명확하고 설명적인 옵션 라벨을 작성해요
- 옵션 전체에서 일관된 용어를 사용해요
- 옵션 텍스트는 간결하되 의미 있게 유지해요
- 관련 옵션은 모든 항목을 그룹화할 수 있을 때만 그룹으로 묶어요. 잘 알려진 카테고리나 명확히 구분할 때 사용해요 (예: Portland ME vs OR). 한 개짜리 그룹은 만들지 마세요
접근성 가이드라인
- 필드에 라벨과 도움말 텍스트를 사용해요. placeholder를 라벨로 쓰지 마세요 (포커스 시 사라지고 접근성이 없어요)
- clear 컨트롤은 탭 순서에서 제외돼요. 키보드 사용자는 Delete로 선택을 지워요
- 모든 select에 명확한 라벨을 제공해요
- 방향키로 키보드 탐색이 되도록 해요
- 스크린 리더 안내를 지원해요
더 알아보기 (Learn more)
Select 컴포넌트의 변형(Async, Checkbox, Country, Creatable, Popup, Radio)과 각각의 사용 가이드라인, 콘텐츠 가이드라인, 접근성 가이드라인을 살펴봤어요. 실제 사용 시에는 @atlaskit/select 패키지의 컴포넌트와 props를 조합해 폼과 인라인 편집에 맞게 활용하면 돼요.