Radio
Radio (라디오)
여러 선택지 중 하나만 고르는 단일 선택 컴포넌트예요. RadioGroup과 함께 쓰면서 v-model과 label을 연결해 선택 값을 다뤄요.
출처: 문서
본문
소개 (Intro)
대안의 집합 안에서 단일 선택을 하는 데 사용해요.
설치 (Install)
import { createApp } from 'vue'
import { Radio, RadioGroup } from '@nutui/nutui'
const app = createApp()
app.use(Radio)
app.use(RadioGroup)
기본 사용법 (Basic Usage)
v-model로 옵션의 label 필드를 바인딩해요. nut-radio는 nut-radio-group과 함께 사용해야 해요.
demo: radio basic
가로 배치 (Horizontal)
direction으로 방향을 설정해요. 기본값은 vertical이고 horizontal로 설정할 수 있어요.
demo: radio horizontal
비활성화 (Disabled)
demo: radio disabled
커스텀 아이콘 (Custom icon)
demo: radio icon
텍스트 위치 (Text Position)
text-position으로 텍스트 위치를 설정해요. 기본값은 right이고 left로 설정할 수 있어요.
demo: radio position
아이콘 크기 (Icon Size)
demo: radio icon-size
모양 (Shape)
shape로 Radio 모양을 설정해요. 기본값은 round이고 button으로 설정할 수 있어요.
demo: radio shape
커스텀 버튼 크기 (Custom Button Size) v4.2.4
size로 Radio 크기를 설정해요. shape가 button일 때만 적용돼요.
demo: radio size
이벤트 발생 (Event Trigger)
demo: radio event
API
Radio Props
| Attribute | Description | Type | Default |
|---|---|---|---|
| disabled | Disable selection | boolean | false |
| icon-size | Icon Size | string | number | 18 |
| label | Radio box ID | string | number | boolean | - |
| shape | Shape, optional values are button、round |
string | round |
sizev4.2.4 |
Can be set to small mini normal, when shape = button |
string | normal |
Radio Slots
| Name | Description |
|---|---|
| icon | Icon when not selected |
| checkedIcon | Icon when selected |
RadioGroup Props
| Attribute | Description | Type | Default |
|---|---|---|---|
| v-model | The identifier of the currently selected item is selected when it is consistent with the label value |
string | number | boolean | - |
| text-position | The position of the text, optional value:left,right |
string | right |
| direction | Use horizontal and vertical optional values horizontal、vertical |
string | vertical |
RadioGroup Events
| Event | Description | Arguments |
|---|---|---|
| change | Triggered when the value changes | Currently selected item value(label)【There is a value after setting label, which is empty by default】 |
Types v4.3.6
컴포넌트는 다음 타입 정의를 export해요:
import type {
RadioShape,
RadioButtonSize,
RadioProps,
RadioInstance,
RadioGroupDirection,
RadioGroupTextPosition,
RadioGroupProps,
RadioGroupInstance
} from '@nutui/nutui';
Theming
CSS Variables
The component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.
| Name | Default Value |
|---|---|
| --nut-radio-label-font-color | #1d1e1e |
| --nut-radio-label-font-active-color | var(--nut-primary-color) |
| --nut-radio-label-disable-color | #999 |
| --nut-radio-icon-disable-color | #d6d6d6 |
| --nut-radio-label-button-border-color | var(--nut-primary-color) |
| --nut-radio-label-button-background | var(--nut-primary-color) |
| --nut-radio-label-margin-left | 15px |
| --nut-radio-button-border-radius | 15px |
| --nut-radio-label-font-size | 14px |
| --nut-radio-button-font-size | 12px |
| --nut-radio-button-padding | 5px 18px |
| --nut-radio-icon-disable-color2 | var(--nut-help-color) |
더 알아보기 (Learn more)
- 원문 문서: Radio — NutUI v4 영문 문서
- NutUI 저장소: jd-opensource/nutui