Switch
on/off를 오가는 토글 스위치예요. 상태 값, 크기, 아이콘, 로딩 표시 등을 자유롭게 조절할 수 있어요. 설정 화면의 기능 켜기/끄기에 많이 쓰여요.
출처: 문서
본문
저는 닌텐도 Switch를 갖고 있지만 플레이할 시간은 없어요. 이게 어릴 적 NDS를 하던 시절이 생각나네요... 더 행복했던 시절이었죠.
Demos
basic.vue
size.vue
content.vue
loading.vue
event.vue
customize-value.vue
shape.vue
color.vue
icon.vue
API
Switch Props
| 이름 | 타입 | 기본값 | 설명 | 버전 |
|---|---|---|---|---|
| checked-value | string | boolean | number |
true |
켜진(on) 상태의 값. | |
| default-value | boolean |
false |
기본값. | |
| disabled | boolean |
false |
스위치를 비활성화할지 여부. | |
| loading | boolean |
false |
로딩 상태를 표시할지 여부. | |
| rail-style | (info: { focused: boolean, checked: boolean }) => (CSSProperties | string) |
undefined |
레일(rail) 스타일 생성기. | |
| round | boolean |
true |
스위치에 둥근 모서리를 적용할지 여부. | |
| rubber-band | boolean |
true |
스위치 버튼에 고무줄 효과(rubber band)를 적용할지 여부. | 2.28.3 |
| size | 'small' | 'medium' | 'large' |
'medium' |
스위치의 크기. | |
| spin-props | { strokeWidth?: number, stroke?: string, scale?: number, radius?: number } |
undefined |
로딩 아이콘 속성. | 2.44.0 |
| unchecked-value | string | boolean | number |
false |
꺼진(off) 상태의 값. | |
| value | string | number | boolean | undefined |
undefined |
직접 설정할 때의 값. | |
| on-update:value | (value: boolean) => void |
undefined |
컴포넌트의 값이 바뀔 때의 콜백. |
Switch Slots
| 이름 | 파라미터 | 설명 | 버전 |
|---|---|---|---|
| checked | () |
스위치가 켜졌을 때의 콘텐츠. | |
| checked-icon | () |
켜졌을 때 스위치 버튼의 아이콘. | 2.25.3 |
| icon | () |
스위치 버튼의 아이콘. | 2.25.3 |
| unchecked | () |
스위치가 꺼졌을 때의 콘텐츠. | |
| unchecked-icon | () |
꺼졌을 때 스위치 버튼의 아이콘. | 2.25.3 |
더 알아보기 (Learn more)
상태를 직접 제어하는 방법은 event, customize-value 데모를 참고하세요. 체크 상태 UI가 필요하면 Checkbox 컴포넌트 문서도 함께 보세요.