AutoComplete
AutoComplete (자동 완성)
AutoComplete는 자동 완성 기능이 강화된 입력 상자 또는 커스텀 입력 컨트롤이에요. 입력하면서 후보 목록을 바로 보여 주기 때문에 검색창 같은 곳에서 자주 쓰입니다.
출처: 문서
본문
API
AutoComplete
| 속성 | 설명 | 타입 | 기본값 | 버전 |
|---|---|---|---|---|
| allowClear | 내용을 지울 수 있게 허용할지 여부 | boolean | - |
- |
| defaultActiveFirstOption | 첫 번째 옵션을 기본으로 하이라이트할지 여부 | boolean | true |
- |
| disabled | autocomplete을 비활성화할지 여부 | boolean | - |
- |
| error | textarea에 오류가 있는지 여부. (더 이상 권장하지 않으며, 다음 메이저 버전에서 제거돼요. 대신 status='error'를 사용해 주세요) | boolean | - |
- |
| loading | 컴포넌트가 데이터를 불러 오는 중인지 여부. | boolean | - |
2.10.0 |
| strict | strict: true로 설정하면 대소문자를 구분해요 |
boolean | - |
- |
| defaultValue | autocomplete의 기본 값. | string | - |
- |
| placeholder | 입력의 플레이스홀더 | string | - |
- |
| value | autocomplete의 값. | string | - |
- |
| status | 상태 | 'error' | 'warning' | - |
2.45.0 |
| children | 입력/소스 데이터를 커스터마이즈해요 | ReactNode | - |
- |
| className | 추가 css 클래스 | string | string[] | - |
- |
| data | 데이터 소스 | (string | { value: string; name: string; [key: string]: any } | ReactNode)[] | - |
- |
| inputProps | Input 컴포넌트의 속성. | Partial<InputProps> | - |
2.10.0 |
| style | 추가 스타일 | CSSProperties | - |
- |
| triggerProps | Trigger 컴포넌트의 모든 속성을 넘겨요 |
Partial<TriggerProps> | - |
- |
| virtualListProps | 가상 스크롤 속성. | AvailableVirtualListProps | - |
2.2.0 |
| dropdownRender | 드롭다운 내용을 커스터마이즈해요 | (menu: ReactNode) => ReactNode | - |
- |
| filterOption | true이면 입력 값으로 옵션을 거릅니다. 함수라면 그 함수의 기준으로 옵션을 거르세요. | boolean | ((inputValue: string, option: ReactElement) => boolean) | true |
- |
| getPopupContainer | 드롭다운의 컨테이너를 설정해요. | (node: HTMLElement) => Element | - |
- |
| onBlur | 컴포넌트가 블러됐을 때 호출되는 콜백 | (event) => void | - |
- |
| onChange | 옵션을 선택하거나 입력 값이 바뀌었을 때 호출되는 콜백 | (value: string, option?: OptionInfo) => void | - |
- |
| onFocus | 컴포넌트가 포커스를 받았을 때 호출되는 콜백 | (event) => void | - |
- |
| onPressEnter | Enter를 눌렀을 때 호출되는 콜백 | (event, activeOption?: OptionInfo) => void | - |
activeOption in 2.25.1 |
| onSearch | 항목을 검색할 때 호출되는 콜백 | (value: string) => void | - |
- |
| onSelect | 옵션을 선택했을 때 호출되는 콜백. | (value: string, option: OptionInfo) => void | - |
- |
| triggerElement | 트리거 요소를 커스터마이즈해요 | ReactElement | (({ value }) => ReactElement) | <Input /> |
() => ReactElement in 2.31.0 |
OptionInfo
export interface OptionInfo extends PropsWithChildren<OptionProps> {
child?: ReactElement;
_valid: boolean;
_index: number;
_origin: "children" | "options" | "userCreatedOptions" | "userCreatingOption";
}
AvailableVirtualListProps
export type AvailableVirtualListProps = Pick<
VirtualListProps<any>,
| "height"
| "itemHeight"
| "threshold"
| "isStaticItemHeight"
| "scrollOptions"
| "onScroll"
| "wrapperChild"
>;
AutoComplete.Option
Select.Option과 같아요. Select를 참고해 주세요.
AutoComplete.OptGroup
Select.OptGroup과 같아요. Select를 참고해 주세요.
더 알아보기
AutoComplete 컴포넌트의 더 자세한 내용은 Arco Design 공식 문서에서 확인해 보세요.