본문으로 건너뛰기

Form Field ​

Form Field는 입력 요소 하나에 라벨, 도움말, 오류 메시지를 함께 붙이는 묶음입니다. 주로 체크박스 묶음이나 직접 만든 입력처럼 라벨 기능이 없는 요소에 사용됩니다. 어느 입력에서든 라벨과 메시지의 위치, 색, 간격을 같게 맞춰 화면마다 오류 표시가 달라지지 않게 합니다.

State ​

Code ​

vue
<script setup>
import { AFormField, ACheckbox } from '@mobigen/rnd-design-system'
</script>

<template>
  <AFormField label="알림 받을 방법" hint="하나 이상 고릅니다." required>
    <template #default="{ attrs }">
      <div role="group" v-bind="attrs" :aria-labelledby="`${attrs.id}-label`">
        <ACheckbox>이메일</ACheckbox>
        <ACheckbox>문자 메시지</ACheckbox>
      </div>
    </template>
  </AFormField>
</template>

Props ​

속성값
labelString
idString
hintString
errorString
requiredtrue, false
disabledtrue, false

Slots ​

슬롯전달 값
default{ id, labelId, describedBy, invalid, required, disabled, attrs }

Notes ​

  • attrs에는 id, aria-describedby, aria-invalid, aria-required가 들어 있다. 입력 요소에 v-bind="attrs"로 붙이면 라벨, 메시지와 연결된다.
  • Input, Select, Textarea처럼 label 속성이 있는 컴포넌트는 Form Field로 감싸지 않고 그대로 쓴다.