@atlaskit/textfield — 텍스트 필드
단일 줄 텍스트 입력 컴포넌트예요. 폼, 모달, 검색, 카드에서 한 줄의 텍스트를 입력받을 때 사용해요.
출처: 문서
본문
TextField component
단일 줄 텍스트 입력 컴포넌트예요.
- 키워드: textfield, input, form, text, field, single-line
- 카테고리: form
- 상태: general-availability
예시
import TextField from '@atlaskit/textfield/text-field';
const Examples = (): React.JSX.Element => (
<>
<TextField label="Name" placeholder="Enter your name" />
<TextField
label="Email"
type="email"
placeholder="Enter your email address"
isRequired
autoComplete="email"
/>
<TextField label="Password" type="password" placeholder="Enter your password" isRequired />
</>
);
export default Examples;
Props
| Prop | Type | Description |
|---|---|---|
appearance |
"none" | "subtle" | "standard" |
Controls the appearance of the field |
elemAfterInput |
string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
Element after input in text field |
elemBeforeInput |
string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
Element before input in text field |
isCompact |
boolean |
Applies compact styling, making the field smaller |
isDisabled |
boolean |
Sets the field as to appear disabled, |
| people will not be able to interact with the text field and it won't appear in the focus order | ||
isInvalid |
boolean |
Changes the text field to have a border indicating that its value is invalid |
isMonospaced |
boolean |
Sets content text value to appear monospaced |
isReadOnly |
boolean |
If true, prevents the value of the input from being edited |
isRequired |
boolean |
Set required for form that the field is part of |
name |
string |
Name of the input element |
onChange |
(event: FormEvent<HTMLInputElement>) => void |
Handler called when the inputs value changes |
onMouseDown |
(event: MouseEvent<HTMLElement, globalThis.MouseEvent>) => void |
Handler called when the mouse down event is triggered on the input element |
placeholder |
string |
Placeholder text to display in the text field whenever it is empty |
width |
string | number |
Sets maximum width of input |
사용 지침
- 폼, 모달, 검색, 카드에서 단일 줄 텍스트에 사용해요
- 라벨은 필수예요 (입력 위에 두고, 도움말 텍스트는 선택)
- 중요 정보에 placeholder를 사용하지 마세요 — 라벨이나 도움말 텍스트를 사용해요 (검색 예외: 검색 아이콘 + 접근 가능한 라벨)
- 문자 제한과 검증을 고려해요
콘텐츠 지침
- 명확하고 짧은 라벨을 작성해요
- 예시/서식에는 도움말 텍스트를 사용하고, 입력 후에도 도움말이 보이게 해요
- 적절한 오류 메시지를 제공해요
- 콘텐츠 길이와 서식을 고려해요
접근성 지침
- 보이는 라벨 또는 올바른 연결(association)을 사용해요. 중요 정보에는 placeholder를 쓰지 마세요 — 라벨이나 도움말을 사용해요 (검색은 아이콘 + 접근 가능한 라벨로 예외)
- 상호작용 요소를 중첩하지 마세요 (포커스 문제를 일으켜요)
- 커스텀 검증: onBlur에서 검증하고, 동적 안내를 위해 aria-live="polite" 및 aria-relevant/aria-atomic이 있는 오류 컨테이너를 사용해요
- 모든 텍스트 필드에 명확한 라벨을 제공해요
- 키보드 내비게이션을 지원해요
- 필수 필드를 명확히 표시해요
- 적절한 오류 상태와 메시지를 사용해요