ReScript Shadcn
Get started
  • Installation
Components
  • Accordion
  • Alert
  • AlertDialog
  • AspectRatio
  • Attachment
  • Avatar
  • Badge
  • Breadcrumb
  • Bubble
  • Button
  • ButtonGroup
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Collapsible
  • Combobox
  • Command
  • ContextMenu
  • DataTable
  • DatePicker
  • Dialog
  • Direction
  • Drawer
  • DropdownMenu
  • Empty
  • Field
  • HoverCard
  • Input
  • InputGroup
  • InputOtp
  • Item
  • Kbd
  • Label
  • Marker
  • Menubar
  • Message
  • MessageScroller
  • NativeSelect
  • NavigationMenu
  • Pagination
  • Popover
  • Progress
  • RadioGroup
  • Resizable
  • ScrollArea
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Skeleton
  • Slider
  • Sonner
  • Spinner
  • Switch
  • Table
  • Tabs
  • Textarea
  • Toast
  • Toggle
  • ToggleGroup
  • Tooltip
  • Typography

Checkbox

A control that allows the user to toggle between checked and not checked.

By clicking this checkbox, you agree to the terms.

Installation#

npx shadcn@latest add @rescript-shadcn/Checkbox

Usage#

<Checkbox />

Checked State#

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

module Example = {
  @react.component
  let make = () => {
    let (checked, setChecked) = React.useState(() => false)
 
    <Checkbox checked onCheckedChange={v => setChecked(_ => v)} />
  }
}

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.

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

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.

Show these items on the desktop:

Select the items you want to show on the desktop.

Table#

NameEmailRole
Sarah Chensarah.chen@example.comAdmin
Marcus Rodriguezmarcus.rodriguez@example.comUser
Priya Patelpriya.patel@example.comUser
David Kimdavid.kim@example.comEditor

API Reference#

See the Base UI documentation for more information.

@@directive("'use client'")

@react.component
@react.component
let make = () =>
  <Field.Group className="mx-auto w-56">
@react.component
let make = () =>
  <Field.Group className="mx-auto w-72">
@react.component
let make = () =>
  <Field.Group className="mx-auto w-56">
@react.component
let make = () =>
  <Field.Group className="mx-auto w-56">
@react.component
let make = () =>
  <Field.Set>
@@directive("'use client'")

type row = {