Input
Input은 한 줄짜리 글자를 입력받는 요소입니다. 주로 이름, 이메일, 검색어처럼 짧은 값을 받을 때 사용됩니다. 라벨, 도움말, 오류 문구를 함께 표시할 수 있어 무엇을 어떻게 입력해야 하는지 사용자에게 분명하게 알려 줍니다.
State
Code
vue
<script setup>
import { ref } from 'vue'
import { AInput } from '@mobigen/rnd-design-system'
const keyword = ref('')
</script>
<template>
<AInput v-model="keyword" search clearable label="Search" placeholder="검색어를 입력하세요" />
<AInput label="Default" placeholder="Email" />
<AInput label="Disabled" placeholder="Email" disabled />
<AInput label="Error" model-value="not-an-email" error="유효한 이메일을 입력해주세요." />
<AInput label="Code" size="md" hint="6자까지 입력할 수 있습니다." name="code" maxlength="6" />
</template>Props
| 속성 | 값 |
|---|---|
modelValue | String |
label | String |
ariaLabel | String |
id | String |
placeholder | String |
disabled | true, false |
error | String |
hint | String |
search | true, false |
clearable | true, false |
clearLabel | String |
required | true, false |
type | String |
size | sm, md, lg, xl |
name, autocomplete, maxlength 같은 속성은 입력 요소에 그대로 전달된다.
Events
| 이벤트 | 전달 값 |
|---|---|
update:modelValue | String |
clear | 없음 |
Methods
| 이름 | 설명 |
|---|---|
focus() | <input>에 포커스를 준다. |
blur() | <input>의 포커스를 뺀다. |
select() | <input>의 내용을 모두 선택한다. |
템플릿 ref로 호출한다.
Notes
clearable을 주면 값이 있을 때 오른쪽에 지우기 버튼이 생긴다. 누르면 값을 비우고clear이벤트를 보낸 뒤 입력에 포커스를 돌려준다. 비활성 상태에서는 보이지 않는다.- 지우기 버튼의 접근성 이름은 기본 "입력 지우기"이고
clearLabel로 바꾼다. modelValue가String만 허용한다.type="number"로 써도 값은 문자열로 전달된다.