Switch

사용자가 켜짐/꺼짐 상태를 전환할 수 있는 컨트롤입니다.

examples/krds/switch-demo.tsx
import { Label } from "@/components/ui/label"
import { Switch } from "@/components/ui/switch"

설치

pnpm dlx shadcn@latest add https://krdscn.gwlee.kr/r/switch.json

사용법

import { Switch } from "@/components/ui/switch"
<Switch />

예제

Description

Focus is shared across devices, and turns off when you leave the app.

examples/krds/switch-description.tsx
import {
  Field,
  FieldContent,

Choice Card

Card-style selection where FieldLabel wraps the entire Field for a clickable card pattern.

examples/krds/switch-choice-card.tsx
import {
  Field,
  FieldContent,

Disabled

Add the disabled prop to the Switch component to disable the switch. Add the data-disabled prop to the Field component for styling.

examples/krds/switch-disabled.tsx
import { Field, FieldLabel } from "@/components/ui/field"
import { Switch } from "@/components/ui/switch"

Invalid

Add the aria-invalid prop to the Switch component to indicate an invalid state. Add the data-invalid prop to the Field component for styling.

You must accept the terms and conditions to continue.

examples/krds/switch-invalid.tsx
import {
  Field,
  FieldContent,

Size

size prop으로 Switch 크기를 변경합니다.

examples/krds/switch-sizes.tsx
import { Field, FieldGroup, FieldLabel } from "@/components/ui/field"
import { Switch } from "@/components/ui/switch"

RTL

RTL 지원을 활성화하려면 RTL 설정 가이드를 참고하세요.

يتم مشاركة التركيز عبر الأجهزة، ويتم إيقاف تشغيله عند مغادرة التطبيق.

examples/krds/switch-rtl.tsx
"use client"

import * as React from "react"

API 참조

Radix Switch 문서를 참고하세요.