Textbox
Textbox 컴포넌트는 한 줄 텍스트 입력에 사용합니다.
예제
Default Basic text input with placeholder. Includes a clear button that appears when the input has value.
1import { Input } from '@devup-ui/components'
2
3export default function Default() {
4 return <Input placeholder="Enter text here" />
5}
61import { Input } from '@devup-ui/components'
2
3export default function Default() {
4 return <Input placeholder="Enter text here" />
5}
6Error
Use error prop to display the input in an error state with a red border. Use errorMessage prop to show a validation message below the input.
1import { Input } from '@devup-ui/components'
2
3export default function ErrorDemo() {
4 return (
5 <Input
6 error
7 errorMessage="This field is required"
8 placeholder="Enter text"
9 />
10 )
11}
121import { Input } from '@devup-ui/components'
2
3export default function ErrorDemo() {
4 return (
5 <Input
6 error
7 errorMessage="This field is required"
8 placeholder="Enter text"
9 />
10 )
11}
12Disabled
Use disabled prop to prevent user interaction. The input will have a muted appearance and the clear button will be hidden.
1import { Input } from '@devup-ui/components'
2
3export default function Disabled() {
4 return <Input disabled placeholder="Disabled input" />
5}
61import { Input } from '@devup-ui/components'
2
3export default function Disabled() {
4 return <Input disabled placeholder="Disabled input" />
5}
6Icon
Pass a React node to the icon prop to display an icon on the left side of the input. Useful for search fields or inputs with visual context.
1import { Input } from '@devup-ui/components'
2
3function SearchIcon() {
4 return (
5 <svg
6 aria-hidden="true"
7 fill="none"
8 height="20"
9 viewBox="0 0 20 20"
10 width="20"
11 xmlns="http://www.w3.org/2000/svg"
12 >
13 <path
14 d="M17.5 17.5L13.875 13.875M15.8333 9.16667C15.8333 12.8486 12.8486 15.8333 9.16667 15.8333C5.48477 15.8333 2.5 12.8486 2.5 9.16667C2.5 5.48477 5.48477 2.5 9.16667 2.5C12.8486 2.5 15.8333 5.48477 15.8333 9.16667Z"
15 stroke="currentColor"
16 strokeLinecap="round"
17 strokeLinejoin="round"
18 strokeWidth="1.5"
19 />
20 </svg>
21 )
22}
23
24export default function WithIcon() {
25 return <Input icon={<SearchIcon />} placeholder="Search..." />
26}
271import { Input } from '@devup-ui/components'
2
3function SearchIcon() {
4 return (
5 <svg
6 aria-hidden="true"
7 fill="none"
8 height="20"
9 viewBox="0 0 20 20"
10 width="20"
11 xmlns="http://www.w3.org/2000/svg"
12 >
13 <path
14 d="M17.5 17.5L13.875 13.875M15.8333 9.16667C15.8333 12.8486 12.8486 15.8333 9.16667 15.8333C5.48477 15.8333 2.5 12.8486 2.5 9.16667C2.5 5.48477 5.48477 2.5 9.16667 2.5C12.8486 2.5 15.8333 5.48477 15.8333 9.16667Z"
15 stroke="currentColor"
16 strokeLinecap="round"
17 strokeLinejoin="round"
18 strokeWidth="1.5"
19 />
20 </svg>
21 )
22}
23
24export default function WithIcon() {
25 return <Input icon={<SearchIcon />} placeholder="Search..." />
26}
27API
Input props는 input HTML 속성(type 제외)을 확장합니다.
| 속성 | 설명 | 타입 | 기본값 |
|---|---|---|---|
| type | 입력 필드의 type(file 타입 제외) |
|
|
| typography | 테마의 타이포그래피 스타일 키 |
|
|
| error | 입력 필드의 오류 상태 여부 |
|
|
| errorMessage | 입력 필드 아래에 표시할 오류 메시지 |
|
|
| allowClear | 입력값이 있을 때 지우기 버튼을 표시할지 여부 |
|
|
| onClear | 지우기 버튼을 클릭했을 때 호출되는 콜백 |
|
|
| icon | 입력 필드 왼쪽에 표시할 아이콘 |
|
|
| disabled | 입력 필드의 비활성화 여부 |
|
|
| classNames | 내부 요소에 적용할 사용자 정의 클래스 이름 |
|
|
| colors | 입력 필드의 사용자 정의 색상 변수 |
|
|