Checkbox

사용자가 선택/해제 상태를 전환할 수 있는 컨트롤입니다.

부가적인 설명이 들어갑니다.

부가적인 설명이 들어갑니다.

examples/krds/checkbox-demo.tsx
"use client"

import { Checkbox } from "@/components/ui/checkbox"

설치

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

사용법

import { Checkbox } from "@/components/ui/checkbox"
<Checkbox />

선택 상태

Use defaultChecked for uncontrolled checkboxes, or checked and onCheckedChange to control the state.

import * as React from "react"

export function Example() {
  const [checked, setChecked] = React.useState(false)

  return <Checkbox checked={checked} onCheckedChange={setChecked} />
}

유효하지 않은 상태

Set aria-invalid on the checkbox and data-invalid on the field wrapper to show the invalid styles.

examples/krds/checkbox-invalid.tsx
import { Checkbox } from "@/components/ui/checkbox"
import { Field, FieldGroup, FieldLabel } from "@/components/ui/field"

예제

Basic

Pair the checkbox with Field and FieldLabel for proper layout and labeling.

examples/krds/checkbox-basic.tsx
import { Checkbox } from "@/components/ui/checkbox"
import { Field, FieldGroup, FieldLabel } from "@/components/ui/field"

Description

Use FieldContent and FieldDescription for helper text.

By clicking this checkbox, you agree to the terms and conditions.

examples/krds/checkbox-description.tsx
import { Checkbox } from "@/components/ui/checkbox"
import {
  Field,

Disabled

Use the disabled prop to prevent interaction and add the data-disabled attribute to the <Field> component for disabled styles.

examples/krds/checkbox-disabled.tsx
import { Checkbox } from "@/components/ui/checkbox"
import { Field, FieldGroup, FieldLabel } from "@/components/ui/field"

Group

Use multiple fields to create a checkbox list.

Show these items on the desktop:

Select the items you want to show on the desktop.

examples/krds/checkbox-group.tsx
import { Checkbox } from "@/components/ui/checkbox"
import {
  Field,

Table

NameEmailRole
Sarah Chensarah.chen@example.comAdmin
Marcus Rodriguezmarcus.rodriguez@example.comUser
Priya Patelpriya.patel@example.comUser
David Kimdavid.kim@example.comEditor
examples/krds/checkbox-table.tsx
"use client"

import * as React from "react"

RTL

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

بالنقر على هذا المربع، فإنك توافق على الشروط.

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

import * as React from "react"

API 참조

Radix UI 문서를 참고하세요.