{
  "schemaVersion": 1,
  "target": "react",
  "name": "checkbox",
  "version": "0.1.1",
  "category": "forms",
  "title": "Checkbox",
  "description": "A checkbox with a label, description, indeterminate state, and a check that draws itself, plus a group with a select-all parent.",
  "tags": [
    "form",
    "checkbox",
    "indeterminate",
    "group",
    "base-ui"
  ],
  "requires": {
    "projectTypes": [
      "next",
      "vite-react"
    ],
    "styling": "tailwind-v4"
  },
  "npmDependencies": {
    "@base-ui/react": "^1.9.0"
  },
  "registryDependencies": [],
  "docsPath": "/components/checkbox",
  "props": [
    {
      "name": "label",
      "type": "ReactNode",
      "description": "Text beside the box. Clicking it toggles the checkbox."
    },
    {
      "name": "description",
      "type": "ReactNode",
      "description": "A secondary line under the label, linked with aria-describedby."
    },
    {
      "name": "checked / defaultChecked",
      "type": "boolean",
      "description": "Controlled or initial state."
    },
    {
      "name": "onCheckedChange",
      "type": "(checked: boolean) => void",
      "description": "Called when the box is ticked or cleared."
    },
    {
      "name": "indeterminate",
      "type": "boolean",
      "default": "false",
      "description": "Shows a dash for a partly selected set."
    },
    {
      "name": "parent",
      "type": "boolean",
      "default": "false",
      "description": "Inside a CheckboxGroup with allValues: becomes a select-all box that goes indeterminate automatically."
    },
    {
      "name": "value",
      "type": "string",
      "description": "Identifies the checkbox in a CheckboxGroup's value."
    },
    {
      "name": "label / description (CheckboxGroup)",
      "type": "ReactNode",
      "description": "Names and describes the group with aria-labelledby and aria-describedby."
    },
    {
      "name": "allValues",
      "type": "string[]",
      "description": "CheckboxGroup: every child value, needed for a parent checkbox."
    }
  ],
  "accessibility": [
    "Base UI renders role=\"checkbox\" with aria-checked (\"mixed\" when indeterminate) and a hidden native input for forms.",
    "The wrapping <label> gives the checkbox its accessible name and makes the text a click target.",
    "Space toggles the focused box; the focus ring shows on keyboard focus only.",
    "A 32px invisible hit area surrounds the 16px box.",
    "The check draws and the dash grows only with motion allowed; under reduced motion they appear in place."
  ],
  "states": [
    "unchecked",
    "checked",
    "indeterminate",
    "focus-visible",
    "invalid",
    "disabled"
  ],
  "files": [
    {
      "path": "ui/checkbox.tsx",
      "content": "\"use client\";\n\nimport { Checkbox as BaseCheckbox } from \"@base-ui/react/checkbox\";\nimport { CheckboxGroup as BaseCheckboxGroup } from \"@base-ui/react/checkbox-group\";\nimport { type ReactNode, useId } from \"react\";\n\ntype ClassName<State> = string | ((state: State) => string | undefined) | undefined;\n\nfunction cx(...classes: (string | false | null | undefined)[]) {\n  return classes.filter(Boolean).join(\" \");\n}\n\n/** Prepends base classes while keeping Base UI's state-function form of className working. */\nfunction withBase<State>(base: string, className: ClassName<State>) {\n  return typeof className === \"function\" ? (state: State) => cx(base, className(state)) : cx(base, className);\n}\n\nconst box = cx(\n  \"group/checkbox relative inline-flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-[5px] border outline-none\",\n  // A larger invisible hit area, so the 16px box is easy to tap on its own.\n  \"after:absolute after:-inset-2 after:content-['']\",\n  \"border-zinc-950/25 bg-white shadow-[0_1px_1px_rgb(0_0_0/0.04)] hover:border-zinc-950/40\",\n  \"dark:border-white/25 dark:bg-black dark:shadow-none dark:hover:border-white/40\",\n  \"data-[checked]:border-zinc-950 data-[checked]:bg-zinc-950 data-[checked]:text-white\",\n  \"data-[indeterminate]:border-zinc-950 data-[indeterminate]:bg-zinc-950 data-[indeterminate]:text-white\",\n  \"dark:data-[checked]:border-white dark:data-[checked]:bg-white dark:data-[checked]:text-black\",\n  \"dark:data-[indeterminate]:border-white dark:data-[indeterminate]:bg-white dark:data-[indeterminate]:text-black\",\n  \"data-[invalid]:border-red-500 dark:data-[invalid]:border-red-400\",\n  // Colors ease over 150ms; the press answers in 100ms.\n  \"transition-[background-color,border-color,color,scale] duration-150 ease-out active:duration-100\",\n  \"motion-safe:active:scale-[0.92] motion-reduce:transition-none\",\n  \"focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-sky-500\",\n  \"data-[disabled]:cursor-not-allowed data-[disabled]:opacity-45 data-[disabled]:active:scale-100\",\n);\n\nexport interface CheckboxProps extends BaseCheckbox.Root.Props {\n  /** Text beside the box. Clicking it toggles the checkbox. */\n  label?: ReactNode;\n  /** A secondary line under the label, linked with `aria-describedby`. */\n  description?: ReactNode;\n  /** Classes for the wrapper that holds the box, label, and description. `className` styles the box. */\n  containerClassName?: string;\n}\n\n/**\n * A checkbox with an optional label and description. The check draws itself in 200ms when ticked\n * and retracts faster when cleared; `indeterminate` shows a dash for a partly selected group.\n * Under reduced motion the mark appears without drawing.\n */\nexport function Checkbox({ label, description, containerClassName, className, \"aria-describedby\": describedBy, ...props }: CheckboxProps) {\n  const descriptionId = useId();\n  const root = (\n    <BaseCheckbox.Root\n      aria-describedby={cx(description != null && descriptionId, describedBy) || undefined}\n      className={withBase(box, className)}\n      {...props}\n    >\n      <BaseCheckbox.Indicator keepMounted className=\"pointer-events-none flex size-full items-center justify-center\">\n        <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" className=\"size-3.5\">\n          <path\n            d=\"M4 8.4l2.6 2.6L12 5.4\"\n            stroke=\"currentColor\"\n            strokeWidth=\"1.75\"\n            strokeLinecap=\"round\"\n            strokeLinejoin=\"round\"\n            pathLength={1}\n            className={cx(\n              \"[stroke-dasharray:1] [stroke-dashoffset:1] opacity-0\",\n              \"transition-[stroke-dashoffset,opacity] duration-100 ease-out motion-reduce:transition-none\",\n              \"group-data-[checked]/checkbox:[stroke-dashoffset:0] group-data-[checked]/checkbox:opacity-100\",\n              \"group-data-[checked]/checkbox:duration-200 group-data-[checked]/checkbox:ease-[cubic-bezier(0.65,0,0.35,1)]\",\n              \"group-data-[indeterminate]/checkbox:opacity-0\",\n            )}\n          />\n          <path\n            d=\"M4.5 8h7\"\n            stroke=\"currentColor\"\n            strokeWidth=\"1.75\"\n            strokeLinecap=\"round\"\n            className={cx(\n              \"origin-center scale-x-0 opacity-0\",\n              \"transition-[scale,opacity] duration-100 ease-out motion-reduce:transition-none\",\n              \"group-data-[indeterminate]/checkbox:scale-x-100 group-data-[indeterminate]/checkbox:opacity-100\",\n              \"group-data-[indeterminate]/checkbox:duration-200 group-data-[indeterminate]/checkbox:ease-[cubic-bezier(0.22,1,0.36,1)]\",\n            )}\n          />\n        </svg>\n      </BaseCheckbox.Indicator>\n    </BaseCheckbox.Root>\n  );\n\n  if (label == null && description == null) return root;\n\n  return (\n    <div className={cx(\"group/field grid grid-cols-[auto_1fr] gap-x-2.5 gap-y-0.5\", containerClassName)}>\n      <label className=\"group/label col-span-2 grid cursor-pointer grid-cols-subgrid items-start has-[[data-disabled]]:cursor-not-allowed\">\n        <span className=\"flex h-5 items-center\">{root}</span>\n        <span className=\"text-sm leading-5 text-zinc-950 select-none group-has-[[data-disabled]]/label:opacity-50 dark:text-white\">\n          {label}\n        </span>\n      </label>\n      {description != null ? (\n        <p\n          id={descriptionId}\n          className=\"col-start-2 text-sm leading-5 text-zinc-500 group-has-[[data-disabled]]/field:opacity-50 dark:text-zinc-400\"\n        >\n          {description}\n        </p>\n      ) : null}\n    </div>\n  );\n}\n\nexport interface CheckboxGroupProps extends BaseCheckboxGroup.Props {\n  /** Names the group. Linked with `aria-labelledby`. */\n  label?: ReactNode;\n  /** A sentence under the label about the whole group. */\n  description?: ReactNode;\n}\n\n/**\n * Shares one value (an array of checkbox `value`s) across the checkboxes inside it. For a\n * \"select all\" box, pass `allValues` here and `parent` on that Checkbox: it turns indeterminate\n * while only some children are ticked.\n */\nexport function CheckboxGroup({ label, description, className, children, ...props }: CheckboxGroupProps) {\n  const id = useId();\n  const labelId = `${id}-label`;\n  const descriptionId = `${id}-description`;\n  return (\n    <BaseCheckboxGroup\n      aria-labelledby={label != null ? labelId : undefined}\n      aria-describedby={description != null ? descriptionId : undefined}\n      className={withBase(\"grid content-start gap-3\", className)}\n      {...props}\n    >\n      {label != null || description != null ? (\n        <div className=\"grid gap-0.5\">\n          {label != null ? (\n            <div id={labelId} className=\"text-sm leading-5 font-medium text-zinc-950 dark:text-white\">\n              {label}\n            </div>\n          ) : null}\n          {description != null ? (\n            <p id={descriptionId} className=\"text-sm leading-5 text-zinc-500 dark:text-zinc-400\">\n              {description}\n            </p>\n          ) : null}\n        </div>\n      ) : null}\n      {children}\n    </BaseCheckboxGroup>\n  );\n}\n"
    }
  ],
  "example": {
    "content": "\"use client\";\n\nimport { useState } from \"react\";\nimport { Checkbox, CheckboxGroup } from \"@/components/shaken/ui/checkbox\";\n\nconst events = [\n  { value: \"run-failed\", label: \"Run failed\", description: \"A step errored and the run stopped.\" },\n  { value: \"approval-requested\", label: \"Approval requested\", description: \"An agent is waiting on a person.\" },\n  { value: \"run-finished\", label: \"Run finished\" },\n];\n\nexport default function CheckboxExample() {\n  const [value, setValue] = useState<string[]>([\"run-failed\", \"approval-requested\"]);\n\n  return (\n    <div className=\"grid w-full max-w-sm gap-6\">\n      <CheckboxGroup\n        label=\"Email me when\"\n        value={value}\n        onValueChange={setValue}\n        allValues={events.map((event) => event.value)}\n      >\n        <Checkbox parent label=\"All run events\" />\n        <div className=\"grid gap-3 pl-6.5\">\n          {events.map((event) => (\n            <Checkbox key={event.value} value={event.value} label={event.label} description={event.description} />\n          ))}\n        </div>\n      </CheckboxGroup>\n      <Checkbox\n        defaultChecked\n        label=\"Include the full trace\"\n        description=\"Attaches tool inputs and outputs as a JSON file.\"\n      />\n      <Checkbox disabled label=\"Send to Slack\" description=\"Connect Slack in Integrations first.\" />\n    </div>\n  );\n}\n"
  }
}
