Textbox

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}
6
1import { Input } from '@devup-ui/components'
2
3export default function Default() {
4    return <Input placeholder="Enter text here" />
5}
6
This field is required

Error 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}
12
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}
12

Disabled 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}
6
1import { Input } from '@devup-ui/components'
2
3export default function Disabled() {
4    return <Input disabled placeholder="Disabled input" />
5}
6

Icon 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}
27
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}
27
API

Input props는 input HTML 속성(type 제외)을 확장합니다.

속성설명타입기본값
type

입력 필드의 type(file 타입 제외)

Exclude<InputType, 'file'>

undefined

typography

테마의 타이포그래피 스타일 키

keyof DevupThemeTypography

undefined

error

입력 필드의 오류 상태 여부

boolean

false

errorMessage

입력 필드 아래에 표시할 오류 메시지

string

undefined

allowClear

입력값이 있을 때 지우기 버튼을 표시할지 여부

boolean

true

onClear

지우기 버튼을 클릭했을 때 호출되는 콜백

() => void

undefined

icon

입력 필드 왼쪽에 표시할 아이콘

React.ReactNode

undefined

disabled

입력 필드의 비활성화 여부

boolean

false

classNames

내부 요소에 적용할 사용자 정의 클래스 이름

{
container?: string

input?: string

icon?: string

errorMessage?: string

}

undefined

colors

입력 필드의 사용자 정의 색상 변수

{
primary?: string

error?: string

text?: string

base?: string

iconBold?: string

border?: string

inputBackground?: string

primaryFocus?: string

negative20?: string

}

undefined