import { Input } from 'sud-ui';텍스트를 입력할 때.
import React, { useState } from 'react';
import { Input } from 'sud-ui';
const BasicInput = () => {
const [value, setValue] = useState("");
return (
<Input
value={value}
onChange={(e) => setValue(e.target.value)}
placeholder="Enter text."
/>
);
};
export default BasicInput;import React, { useState } from 'react';
import { Input } from 'sud-ui';
const DisabledInput = () => {
const [value, setValue] = useState("");
return (
<Input
value={value}
onChange={(e) => setValue(e.target.value)}
disabled
placeholder="Disabled Input"
/>
);
};
export default DisabledInput;import React, { useState } from 'react';
import { Input, Radio, Card } from 'sud-ui';
const TypeInput = () => {
const [type, setType] = useState('text');
const [textValue, setTextValue] = useState('');
const [numberValue, setNumberValue] = useState('');
const typeOptions = [
{ label: 'text', value: 'text' },
{ label: 'number', value: 'number' }
];
return (
<div className="flex flex-col gap-[20px]">
<Card style={{ width: "100%" }} shadow="none" colorType="sub">
<div className="flex justify-center w-full">
<Radio.Group
options={typeOptions}
direction="horizontal"
value={type}
onChange={setType}
/>
</div>
</Card>
<Input
type={type}
value={type === "text" ? textValue : numberValue}
onChange={(e) =>
type === "text"
? setTextValue(e.target.value)
: setNumberValue(e.target.value)
}
placeholder={`${type} type Input`}
/>
</div>
);
};
export default TypeInput;import React, { useState } from 'react';
import { Input } from 'sud-ui';
const ClearableInput = () => {
const [value, setValue] = useState("Try to clear!");
return (
<Input
value={value}
onChange={(e) => setValue(e.target.value)}
clearable
placeholder="Clearable Input"
/>
);
};
export default ClearableInput;import React, { useState } from 'react';
import { Input } from 'sud-ui';
const LabelInput = () => {
const [value, setValue] = useState("");
return (
<Input
value={value}
onChange={(e) => setValue(e.target.value)}
label="name"
placeholder="Label Input"
/>
);
};
export default LabelInput;import React, { useState } from 'react';
import { Input } from 'sud-ui';
const AutoCompleteInput = () => {
const [value, setValue] = useState("");
return (
<Input
value={value}
onChange={(e) => setValue(e.target.value)}
autoComplete="email"
placeholder="Auto Complete Input"
/>
);
};
export default AutoCompleteInput;import React, { useState } from 'react';
import { Input, Radio, Card } from 'sud-ui';
const ShapeInput = () => {
const [shape, setShape] = useState('rounded');
const [shapeValue, setShapeValue] = useState('');
const shapeOptions = [
{ label: 'rounded', value: 'rounded' },
{ label: 'square', value: 'square' },
{ label: 'capsule', value: 'capsule' }
];
return (
<div className="flex flex-col gap-[20px]">
<Card style={{ width: "100%" }} shadow="none" colorType="sub">
<div className="flex justify-center w-full">
<Radio.Group
options={shapeOptions}
direction="horizontal"
value={shape}
onChange={setShape}
/>
</div>
</Card>
<Input
shape={shape}
value={shapeValue}
onChange={(e) => setShapeValue(e.target.value)}
placeholder={`${shape} Shape Input`}
/>
</div>
);
};
export default ShapeInput;import React, { useState } from 'react';
import { Input, Radio, Card, Button } from 'sud-ui';
const PrefixSuffixInput = () => {
const [prefixSuffix, setPrefixSuffix] = useState('prefix');
const prefixSuffixOptions = [
{ label: 'prefix', value: 'prefix' },
{ label: 'suffix', value: 'suffix' }
];
return (
<div className="flex flex-col gap-[20px]">
<Card style={{ width: "100%" }} shadow="none" colorType="sub">
<div className="flex justify-center w-full">
<Radio.Group
options={prefixSuffixOptions}
direction="horizontal"
value={prefixSuffix}
onChange={setPrefixSuffix}
/>
</div>
</Card>
<div className="flex flex-col gap-[20px]">
<Input
{...(prefixSuffix === "prefix"
? { prefix: "₩" }
: { suffix: "KRW" })}
value={prefixSuffixValue}
onChange={(e) => setPrefixSuffixValue(e.target.value)}
placeholder="Prefix/Suffix Input"
/>
<Input
{...(prefixSuffix === "prefix"
? { prefix: <Button size="sm" colorType="primary" shadow="none">Search</Button> }
: { suffix: <Button size="sm" colorType="primary">Confirm</Button> })}
value={prefixSuffixValue}
onChange={(e) => setPrefixSuffixValue(e.target.value)}
placeholder="Prefix/Suffix Input"
/>
</div>
</div>
);
};
export default PrefixSuffixInput;import React, { useState } from 'react';
import { Input } from 'sud-ui';
const ThousandSeparatorInput = () => {
const [value, setValue] = useState("");
return (
<Input
type="number"
thousandSeparator
value={value}
onChange={(e) => setValue(e.target.value)}
placeholder="Enter number"
/>
);
};
export default ThousandSeparatorInput;import React, { useState } from 'react';
import { Input, Radio, Card } from 'sud-ui';
const SizeInput = () => {
const [size, setSize] = useState('md');
const [value, setValue] = useState('');
const sizeOptions = [
{ label: 'sm', value: 'sm' },
{ label: 'md', value: 'md' },
{ label: 'lg', value: 'lg' }
];
return (
<div className="flex flex-col gap-[20px]">
<Card style={{ width: "100%" }} shadow="none" colorType="sub">
<div className="flex justify-center w-full">
<Radio.Group
options={sizeOptions}
direction="horizontal"
value={size}
onChange={setSize}
/>
</div>
</Card>
<Input
size={size}
value={value}
onChange={(e) => setValue(e.target.value)}
placeholder={`${size} 크기의 Input 입니다.`}
/>
</div>
);
};
export default SizeInput;import React, { useState } from 'react';
import { Input } from 'sud-ui';
const ReadOnlyInput = () => {
const [value, setValue] = useState("");
return (
<Input
value={value}
onChange={(e) => setValue(e.target.value)}
readOnly
placeholder="Read Only Input"
/>
);
};
export default ReadOnlyInput;import React, { useState } from 'react';
import { Input } from 'sud-ui';
const MaxLengthInput = () => {
const [value, setValue] = useState("");
return (
<Input
value={value}
onChange={(e) => setValue(e.target.value)}
maxLength={12}
placeholder="Max Length Input"
/>
);
};
export default MaxLengthInput;import React, { useState } from 'react';
import { Input } from 'sud-ui';
const PasswordInput = () => {
const [value, setValue] = useState("");
return (
<Input
value={value}
onChange={(e) => setValue(e.target.value)}
password
placeholder="Password Input"
/>
);
};
export default PasswordInput;import React, { useState } from 'react';
import { Input } from 'sud-ui';
const UnderlineInput = () => {
const [value, setValue] = useState("");
return (
<Input
value={value}
onChange={(e) => setValue(e.target.value)}
underline
placeholder="Underline Input"
/>
);
};
export default UnderlineInput;import React, { useState } from 'react';
import { Input } from 'sud-ui';
const ErrorInput = () => {
const [value, setValue] = useState("");
return (
<Input
value={value}
onChange={(e) => setValue(e.target.value)}
error={value.length > 0}
errorText="Error Message"
placeholder="Error Input"
/>
);
};
export default ErrorInput;import React, { useState } from 'react';
import { Input, Radio, Card } from 'sud-ui';
const IconInput = () => {
const [iconPosition, setIconPosition] = useState('after');
const [iconValue, setIconValue] = useState('');
const iconPositionOptions = [
{ label: 'before', value: 'before' },
{ label: 'after', value: 'after' }
];
return (
<div className="flex flex-col gap-[20px]">
<Card style={{ width: "100%" }} shadow="none" colorType="sub">
<div className="flex justify-center w-full">
<Radio.Group
options={iconPositionOptions}
direction="horizontal"
value={iconPosition}
onChange={setIconPosition}
/>
</div>
</Card>
<Input
{...(iconPosition === "before"
? { beforeIcon: <Search /> }
: { afterIcon: <Search /> })}
value={iconValue}
onChange={(e) => setIconValue(e.target.value)}
placeholder="Icon Input"
/>
</div>
);
};
export default IconInput;import React, { useState } from 'react';
import { Input } from 'sud-ui';
const CustomColorInput = () => {
const [value, setValue] = useState("");
return (
<div className="flex flex-col gap-[20px]">
<Input
placeholder="Enter textColor"
value={value}
onChange={(e) => setValue(e.target.value)}
color={`${value}-8`}
background={`${value}-1`}
borderColor={`${value}-8`}
/>
<div className="flex flex-wra gap-[10px]">
<Tag colorType="blue">blue</Tag>
<Tag colorType="green">green</Tag>
<Tag colorType="orange">orange</Tag>
<Tag colorType="red">red</Tag>
<Tag colorType="forest">forest</Tag>
<Tag colorType="purple">purple</Tag>
<Tag colorType="volcano">volcano</Tag>
<Tag colorType="lime">lime</Tag>
...
</div>
</div>
);
};
export default CustomColorInput;속성 이름 | 설명 | 타입 | 기본값 |
|---|
| value | 입력 필드의 값 | string | "" |
| onChange | 값이 변경될 때 호출되는 함수 (e: ChangeEvent<HTMLInputElement>) => void | (e: ChangeEvent<HTMLInputElement>) => void | - |
| placeholder | 입력 필드의 placeholder 텍스트 | string | - |
| type | 입력 필드의 타입 (InputType) | text | password | number | int | email | tel | url | file | hidden | submit | reset | text |
| size | 입력 필드의 크기 (InputSize) | sm | md | lg | md |
| shape | 입력 필드의 모서리 모양 | square | circle | rounded | capsule | rounded |
| disabled | 입력 필드 비활성화 여부 | boolean | false |
| readOnly | 읽기 전용 여부 | boolean | false |
| autoFocus | 자동 포커스 여부 | boolean | false |
| password | 비밀번호 입력 필드 여부 | boolean | false |
| maxLength | 최대 입력 길이 | number | - |
| clearable | 값을 지울 수 있는 버튼 표시 여부 | boolean | false |
| label | 입력 필드의 라벨 | string | ReactNode | - |
| underline | 밑줄 스타일 여부 | boolean | false |
| autoComplete | 자동 완성 속성 | string | - |
| error | 에러 상태 여부 | boolean | false |
| errorText | 에러 메시지 | string | - |
| beforeIcon | 입력 필드 앞에 표시될 아이콘 | ReactNode | - |
| afterIcon | 입력 필드 뒤에 표시될 아이콘 | ReactNode | - |
| prefix | 입력 필드 앞에 표시될 텍스트 | ReactNode | - |
| suffix | 입력 필드 뒤에 표시될 텍스트 | ReactNode | - |
| background | 배경색(palette값 또는 HEX code) | string | - |
| color | 텍스트 색상(palette값 또는 HEX code) | string | - |
| border | 테두리 표시 여부 | boolean | true |
| borderColor | 테두리 색상(palette값 또는 HEX code) | string | - |
| borderType | 테두리 스타일 | solid | dashed | dotted | double | groove | ridge | inset | outset | none | solid |
| borderWeight | 테두리 두께 | number | 1 |
| shadow | 그림자 크기 | none | sm | md | lg | sm |
| className | 추가 클래스명 | string | "" |
| style | 추가 스타일 | React.CSSProperties | {} |
| thousandSeparator | 숫자 입력 시 3자리마다 콤마 추가 여부 | boolean | false |
| onEnter | Enter 키를 눌렀을 때 호출되는 함수 (e: KeyboardEvent<HTMLInputElement>) => void | (e: KeyboardEvent<HTMLInputElement>) => void | - |
| onKeyDown | 키를 눌렀을 때 호출되는 함수 (e: KeyboardEvent<HTMLInputElement>) => void | (e: KeyboardEvent<HTMLInputElement>) => void | - |
| onClick | 클릭 이벤트 핸들러 (e: MouseEvent<HTMLDivElement>) => void | (e: MouseEvent<HTMLDivElement>) => void | - |
| id | 입력 필드의 ID | string | - |
| name | 입력 필드의 name 속성 | string | - |
| ariaLabel | ARIA 라벨 (접근성) | string | - |
| required | 필수 입력 여부 | boolean | false |
| ariaRequired | ARIA required 속성 (접근성) | boolean | - |
| ariaInvalid | ARIA invalid 속성 (접근성) | boolean | - |
| ariaDescribedby | ARIA describedby 속성 (접근성) | string | - |