Componentes
- 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
- Direction
- 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
- Toast
- Toggle
- Toggle Group
- Tooltip
- Typography
Checkbox
A control that allows the user to toggle between checked and not checked.
Installation#
pnpm add @ag/uiUsage#
import { Checkbox } from "@ag/ui"<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.
Examples#
Basic#
Pair the checkbox with Field and FieldLabel for proper layout and labeling.
Description#
Use FieldContent and FieldDescription for helper text.
Disabled#
Use the disabled prop to prevent interaction and add the data-disabled attribute to the <Field> component for disabled styles.
Group#
Use multiple fields to create a checkbox list.
Table#
RTL#
To enable RTL support in shadcn/ui, see the RTL configuration guide.
API Reference#
See the Radix UI documentation for more information.