- Accordion
- Alert Dialog
- Alert
- Autocomplete
- Avatar
- Badge
- Button Group
- Button
- Card
- Carousel
- Chart
- Checkbox
- Clipboard
- Collapsible
- Combobox
- Command
- Context Menu
- Date Picker
- Dialog
- Editable
- Field
- File Upload
- Floating Panel
- Hover Card
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Marquee
- Menu
- Native Select
- Number Input
- Pagination
- Popover
- Progress
- QR Code
- Radio Group
- Rating Group
- Scroll Area
- Select
- Separator
- Sheet
- Skeleton
- Slider
- Spinner
- Splitter
- Steps
- Switch
- Table
- Tabs
- Textarea
- Toast
- Toggle Group
- Toggle
- Tooltip
- Tour
- Tree View
You'll receive a notification when someone posts a comment
Installation
pnpm dlx shadcn@latest add @shark-ui/checkbox
Usage
import { Checkbox } from "@/components/ui/checkbox";
<Checkbox />
Controlled
Use the checked prop to control the checkbox.
Terms were not accepted
Invalid State
Use the invalid prop to indicate an invalid state.
You must accept the terms to continue
You can pass invalid prop to the <Field /> to disable the label and description or <Checkbox /> to disable just the checkbox.
Examples
With Description
Use <FieldDescription /> to add a description to the checkbox.
You'll receive a notification when someone posts a comment on your post
Disabled
Use the disabled prop to disable the checkbox.
Indeterminate
Use the checked="indeterminate" prop to set the checkbox to an indeterminate state.
Group
Use <CheckboxGroup /> to group multiple checkboxes together.
Select the items you want to show on the desktop.
Use defaultValue to set the default checked values.
<CheckboxGroup defaultValue={["value-1", "value-2"]}> <Checkbox value="value-1" /> <Checkbox value="value-2" /> <Checkbox value="value-3" /> </CheckboxGroup>
Card Style
Use <FieldLabel /> to add a label to the checkbox.
API Reference
Checkbox
Root element of the checkbox. Renders a button
| Prop | Type | Default |
|---|---|---|
checked | boolean | 'indeterminate' | - |
defaultChecked | boolean | false |
disabled | boolean | false |
name | string | - |
value | string | - |
onCheckedChange | ({ checked }: CheckedChangeDetails) => void | - |
className | string | - |
CheckboxGroup
Container for a group of checkboxes. Renders a div
| Prop | Type | Default |
|---|---|---|
value | string[] | - |
defaultValue | string[] | - |
onValueChange | (checkedValues: string[]) => void | - |
name | string | - |
className | string | - |
For a complete list of props, see the Ark UI documentation.