- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Avatar
- Badge
- Breadcrumb
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input
- Input Group
- Input OTP
- Item
- Kbd
- Label
- Menubar
- Native Select
- Navigation Menu
- Pagination
- Popover
- Progress
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Tooltip
- Typography
By clicking this checkbox, you agree to the terms.
"use client";
import { Checkbox } from "@/components/ui/checkbox";
import {
Field,
FieldContent,Installation
$ pnpm dlx shadcn@latest add https://shadcn-cssinjs.com/r/checkbox.json
Usage
import { Checkbox } from "@/components/ui/checkbox";<Checkbox />Checked State
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} />;
}Invalid State
Set aria-invalid on the checkbox and data-invalid on the field wrapper to
show the invalid styles.
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.
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.
import { Checkbox } from "@/components/ui/checkbox";
import {
Field,
FieldContent,
FieldDescription,
FieldGroup,Disabled
Use the disabled prop to prevent interaction and add the data-disabled attribute to the <Field> component for disabled styles.
import { Checkbox } from "@/components/ui/checkbox";
import {
Field,
FieldGroup,
FieldLabel,
} from "@/components/ui/field";Group
Use multiple fields to create a checkbox list.
import { Checkbox } from "@/components/ui/checkbox";
import {
Field,
FieldDescription,
FieldGroup,
FieldLabel,Table
| Name | Role | ||
|---|---|---|---|
| Sarah Chen | sarah.chen@example.com | Admin | |
| Marcus Rodriguez | marcus.rodriguez@example.com | User | |
| Priya Patel | priya.patel@example.com | User | |
| David Kim | david.kim@example.com | Editor |
"use client";
import * as React from "react";
import { Checkbox } from "@/components/ui/checkbox";
import {RTL
To enable RTL support in shadcn/ui, see the RTL configuration guide.
بالنقر على هذا المربع، فإنك توافق على الشروط.
"use client";
import * as React from "react";
import { useTranslation } from "@/components/language-selector";
import type { Translations } from "@/components/language-selector";API Reference
See the Base UI documentation for more information.