Prototyper UI
Prototyper UI
Gallery

Getting Started

IntroductionGetting StartedInstallationCLI ReferenceMachine Mode PackageThemingFormsIntroductionDesign PrinciplesDesign Tokens

For AI Agents

Agent SetupLLMs.txtMCP ServerAgent Skills

Live Canvas

Getting StartedMCP Tools ReferenceAPI Reference

Compose

ComposeGetting StartedSpec FormatDynamic ExpressionsStreamingActions & EventsConditional RenderingValidationDX HelpersType SafetyStore AdaptersPrompt EngineeringComponent CatalogDevToolsCode ExportMCP IntegrationAPI Reference

Components

Actions

ButtonSegmented ControlToggleToggle GroupToolbar

Forms

AutocompleteCheckboxCheckbox GroupColor PickerComboboxFieldFieldsetFormFormFieldInputInputGroupLabelNumberFieldRadio GroupSelectSliderSwitchTextFieldTextarea

Overlays

Alert DialogCommand PaletteContext MenuDialogDrawerMenuMenubarPopoverHover CardTooltip

Navigation

BreadcrumbNavigation MenuTabs

Layout

AccordionCardCollapsibleColumnsContainerResizable PanelRowScroll AreaSectionSeparator

Data Display

AvatarBadgeTree View

Feedback

AlertMeterProgressSkeletonSpinnerToastChangelog

Checkbox

A checkbox with label and validation support built on Base UI

Loading...

Installation

pnpm dlx shadcn@latest add https://prototyper-ui.com/r/checkbox.json
npx shadcn@latest add https://prototyper-ui.com/r/checkbox.json
yarn dlx shadcn@latest add https://prototyper-ui.com/r/checkbox.json
bunx --bun shadcn@latest add https://prototyper-ui.com/r/checkbox.json

This will add the following files to your project:

  • components/ui/checkbox.tsx

Usage

import {
  Checkbox,
  CheckboxControl,
  CheckboxIndicator,
} from "@/components/ui/checkbox";

<Checkbox>
  <CheckboxControl>
    <CheckboxIndicator />
  </CheckboxControl>
  Accept terms and conditions
</Checkbox>;

Anatomy

<Checkbox>
  <CheckboxControl>
    <CheckboxIndicator />
  </CheckboxControl>
  {/* label text */}
</Checkbox>
Sub-componentdata-slotPurposeRequired
CheckboxcheckboxRoot provider, manages checked stateYes
CheckboxControlcheckbox-controlVisual box that displays the check indicatorYes
CheckboxIndicatorcheckbox-indicatorCheckmark or indeterminate iconYes

Examples

Disabled

Loading...

Indeterminate

Loading...

Read Only

Loading...

Validation

Loading...

Styling

Data Slots

Use data-slot attributes to target specific parts of the checkbox:

Slot nameElement
checkboxRoot wrapper (label + control container)
checkbox-controlThe visual box element
checkbox-indicatorThe checkmark / indeterminate icon

Customization Examples

/* Make all checkbox controls larger */
[data-slot="checkbox-control"] {
  @apply size-5 rounded-md;
}

/* Custom checked color */
[data-slot="checkbox-control"] {
  @apply group-data-checked:bg-green-600 group-data-checked:border-green-600;
}
{
  /* Override styles via className */
}
<Checkbox className="gap-4">
  <CheckboxControl className="size-5 rounded-md">
    <CheckboxIndicator />
  </CheckboxControl>
  Larger checkbox
</Checkbox>;

API Reference

Checkbox

Root component that manages checked/unchecked/indeterminate state and renders as a label.

Prop

Type

All Base UI Checkbox.Root props are forwarded via ...props.

CheckboxControl

The visual box element that displays the check indicator.

Prop

Type

All standard span props are forwarded via ...props.

CheckboxIndicator

The checkmark or indeterminate icon rendered inside the control.

Prop

Type

All Base UI Checkbox.Indicator props are forwarded via ...props.

Accessibility

Keyboard Interactions

KeyAction
SpaceToggles the checkbox checked state
TabMoves focus to / away from the checkbox

ARIA Attributes

  • Renders with role="checkbox" via Base UI.
  • aria-checked is set to true, false, or mixed (indeterminate) based on state.
  • aria-disabled is set when the checkbox is disabled.
  • aria-readonly is set when the checkbox is read-only.
  • aria-required is set when the checkbox is required.
  • Screen readers announce the checkbox label and its checked/unchecked/mixed state.

Compose

This component is available in @prototyperco/compose.

Catalog Definition

checkbox.catalog.ts
import { z } from "zod";
import { defineComponent } from "@prototyperco/compose/catalog";

export default defineComponent({
  description: "A checkbox toggle for boolean values",
  props: z.object({
    label: z
      .string()
      .optional()
      .describe("Label displayed next to the checkbox"),
    checked: z.boolean().optional().describe("Whether the checkbox is checked"),
    disabled: z
      .boolean()
      .optional()
      .describe("Whether the checkbox is disabled"),
  }),
  events: ["change"],
  example: { label: "I agree to the terms", checked: false },
});

Example Spec

{
  "root": "check",
  "elements": {
    "check": {
      "type": "Checkbox",
      "props": {
        "label": "I agree to the terms",
        "checked": false
      },
      "$bindState": { "path": "/agreed", "event": "change" }
    }
  }
}

Learn more in the Compose documentation.

Related

Related Components

Checkbox Groupused by

A group of checkboxes with shared state and select-all support built on Base UI.

Autocomplete

text input with suggestions and free-form input capability

Checkbox Group

group of checkboxes with shared state and select-all support

On this page

InstallationUsageAnatomyExamplesDisabledIndeterminateRead OnlyValidationStylingData SlotsCustomization ExamplesAPI ReferenceCheckboxCheckboxControlCheckboxIndicatorAccessibilityKeyboard InteractionsARIA AttributesComposeCatalog DefinitionExample SpecRelated
Unsubscribe
Subscribe
Subscribe
Agree
Subscribe