Checkbox
A control that allows the user to toggle between checked and not checked.
Installation
Command
Manual
Use the JGuang UI Registry URL provided on /systems/jguang-ui#install.
Install the following dependencies:
npm install @base-ui/react
Copy and paste the following code into your project.
View complete source: components/ui/checkbox.tsx
Update the import paths to match your project setup.
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.
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 JGuang UI, see the RTL configuration guide.
API Reference
See the Base UI documentation for more information.
Source: components/base/checkbox.mdx
Technical documentation for JGuang UI.