# 텍스트 필드 (Text field)

분류: 컴포넌트 > 입력 (Components > Input)
주소: https://ui-glossary-xi.vercel.app/components/text-field
다른 이름: 입력칸, 입력 필드, 인풋, 텍스트 입력, 글자 입력칸, text field, text input, input field, textbox, email field, url field, money field

글자를 직접 쳐서 넣는 한 줄 입력칸. 사용자가 글자를 직접 쳐서 넣는 입력칸. 칸 하나만이 아니라 위의 라벨, 칸 안의 플레이스홀더, 아래의 도움말·오류 글까지 묶어 하나의 텍스트 필드로 본다.

## 용도
- 이름·이메일·주소처럼 보기에서 고를 수 없는 값을 받을 때.
- 칸 너비를 예상 글자 수에 맞춘다(우편번호는 짧게, 주소는 길게) — 너비 자체가 힌트가 된다(GOV.UK).
- 오류는 칸 아래에 무엇이 틀렸고 어떻게 고치는지 글로 보여 주고, 칸과 aria-describedby로 잇는다.

## 헷갈릴 수 있는 UI
- 제자리 편집 (Inline edit, https://ui-glossary-xi.vercel.app/md/inline-edit.md): 제자리 편집은 평소에 글로 보이다가 고칠 때만 입력칸으로 바뀐다. 텍스트 필드는 늘 칸 모양이다.
- 입력 덧붙임 묶음 (Input group, https://ui-glossary-xi.vercel.app/md/input-group.md): 입력 덧붙임 묶음은 텍스트 필드 앞뒤에 'https://'·'원' 같은 글이나 '적용' 버튼을 붙여 한 칸처럼 묶은 것이다.
- 라벨 (Label, https://ui-glossary-xi.vercel.app/md/label.md): 라벨은 텍스트 필드 위의 이름 글이고, 텍스트 필드는 라벨·칸·도움말을 모두 묶은 입력 하나다.
- 플레이스홀더 (Placeholder, https://ui-glossary-xi.vercel.app/md/placeholder.md): 플레이스홀더는 텍스트 필드 안의 흐린 예시 글자이고, 치면 사라진다.
- 콤보박스 (Combobox (autocomplete), https://ui-glossary-xi.vercel.app/md/combobox.md): 콤보박스는 치면 아래에 추천 목록이 열려 골라 넣는 입력칸이다. 텍스트 필드는 친 글자가 그대로 값이 된다.
- 스테퍼 (Stepper, https://ui-glossary-xi.vercel.app/md/stepper.md): 스테퍼는 숫자 칸에 −/+ 버튼이 붙어 한 단계씩 바꾼다. 텍스트 필드는 아무 글자나 직접 친다.
- 날짜 입력 (Date input, https://ui-glossary-xi.vercel.app/md/date-input.md): 날짜 입력은 연·월·일 칸으로 나눠 숫자만 받고 실제로 있는 날짜인지 검사한다. 텍스트 필드는 아무 글자나 받는 칸 하나다.
- 한 단 폼 (Single-column form layout, https://ui-glossary-xi.vercel.app/md/single-column-form.md): 한 단 폼은 텍스트 필드 여러 개를 위에서 아래로 한 줄씩 쌓는 배치 규칙이다. 텍스트 필드는 그 안의 칸 하나다.
- 검색창 (Search field, https://ui-glossary-xi.vercel.app/md/search-field.md): 검색창은 찾기 전용 칸(type="search")으로 돋보기·지우기 버튼이 붙고 Enter가 곧 검색이다. 텍스트 필드는 폼과 함께 내는 값을 적는다.
- 텍스트 영역 (Textarea, https://ui-glossary-xi.vercel.app/md/textarea.md): 텍스트 영역은 여러 줄의 긴 글을 받고 Enter가 줄 바꿈이다. 텍스트 필드는 한 줄짜리 값을 받는다.
- 비밀번호 입력 (Password input, https://ui-glossary-xi.vercel.app/md/password-input.md): 비밀번호 입력은 친 글자를 ●로 가리고 보기 버튼으로 잠깐 드러낸다. 텍스트 필드는 친 글자가 그대로 보인다.
- 인라인 오류 메시지 (Inline error message (inline validation), https://ui-glossary-xi.vercel.app/md/inline-error.md): 인라인 오류 메시지는 텍스트 필드 곁에 붙어 무엇이 틀렸고 어떻게 고칠지 말하는 글로, 칸과 aria-describedby로 이어진다.

## AI에게 이렇게 말하세요
- 한국어: 닉네임 텍스트 필드를 만들어 줘. 칸 위에 라벨 '닉네임', 아래에 도움말 '2~10자', 오른쪽 아래에 글자 수 '0/10'. 칸을 떠날 때 2자보다 짧으면 aria-invalid="true"와 빨간 테두리, 칸 아래에 '2자 이상 입력해 주세요'를 보여 주고 aria-describedby로 도움말·오류를 칸에 이어 줘.
- English: Build a nickname text field: label 'Nickname' above, helper text '2–10 characters' below and a '0/10' counter at the bottom-right. On blur, if it's shorter than two characters, set aria-invalid="true", show a red border and the message 'Enter at least 2 characters' below, and connect the helper and error text with aria-describedby.

이렇게 말하면 엉뚱한 게 나와요:
- "닉네임 검색창 만들어 줘" — 추천 목록이 열리는 검색·콤보박스가 나올 수 있다. 직접 치는 칸이면 텍스트 필드. (대신 나오는 것: 콤보박스)
- "회색 글씨로 '닉네임' 들어간 칸" — 라벨 없이 플레이스홀더만 있는 칸이 나와 치면 이름이 사라진다. (대신 나오는 것: 플레이스홀더)

## 핵심 구조 요점
### 태그
- <label for> + <input type="text" id> + 도움말 <p id>. 여러 줄이면 <textarea>.
- 이메일·전화는 type="email"/"tel"과 autocomplete를 주면 휴대폰 자판과 자동 채우기가 맞춰진다.

### 접근성 속성
- 오류일 때 aria-invalid="true", 도움말·오류 글은 aria-describedby로 연결(WCAG 3.3.1).
- <input type="text">는 role="textbox"로 읽힌다.

### 키보드
- Tab으로 들어가 글자를 친다. Enter는 폼 제출(한 줄 칸), 여러 줄 칸은 줄바꿈.

## 출처
- [GOV.UK Design System — Text input](https://design-system.service.gov.uk/components/text-input/)
- [Material Design 3 — Text fields](https://m3.material.io/components/text-fields/overview)
- [MDN — <input type="text">](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/text)
- [WCAG 2.2 — Understanding 3.3.1 Error Identification](https://www.w3.org/WAI/WCAG22/Understanding/error-identification.html)
