Skip to content
Pebble Pro is here at $49 one timeSee what’s included ↗
Pebble
ComponentsDocsMCPPricing
⌕ Find a component↗Log in
All components 673

Categories

Core inputs & forms46Buttons & actions33Navigation36Overlays & feedback49Data display33Charts & data viz40Cards & layout43Marketing blocks38App shells & pages37AI interfaces40Text & typography effects33Backgrounds & visual effects38Motion & transitions32Numbers & counters32Media34E-commerce333D & interactive36Themed sets40
Start with the essentials.Installation guide ↗Connect your agent ↗
← All componentsCore inputs & forms

Checkbox

A box that toggles on and off, with a dash for the mixed state.

Preview

2 of 3

Accept the terms to invite Malik and Priya.

Install

Add the editable source with the shadcn CLI. Your project also needs the shared theme tokens this component uses. Setup and requirements. The Pebble installer is not published yet.

npx shadcn@latest add https://pebbleui.com/r/checkbox.json

Props

PropTypeDefaultDescription
checkedboolean | "indeterminate"—Controlled state; "indeterminate" shows a dash
defaultCheckedboolean | "indeterminate"falseUncontrolled initial state
onCheckedChange(checked: boolean | "indeterminate") => void—Called on toggle
disabledbooleanfalseNot interactive, 50% opacity
name / valuestring—Form submission (value defaults to "on")
aria-invalidboolean—Danger border and ring
Build notes
Radix Checkbox primitive (a `button` with `role="checkbox"`), so keyboard,
`aria-checked="mixed"` and the hidden form input come from Radix. The root is
a `group/checkbox`; both SVG marks live inside one `Indicator` and swap with
`group-data-[state=indeterminate]/checkbox:` (dash shown, tick hidden), so no
React state is needed for the third state. Off is an outline and on is a fill,
matching Switch, so state reads without hue. Forced colors: the box edge
becomes `CanvasText`; checked and mixed boxes are painted `Highlight` (with
`!` so the forced background loses) and the marks `HighlightText`.

**Pebble (2026-11-03).** Unchecked box is a recessed well: `bg-card`, full-strength `border-control` edge and `inset-shadow-xs`; hover darkens the edge and fills `bg-muted`. Checked and indeterminate use the lit key (`from-key-top to-key-bottom`, `border-key-edge`, `--key-shine` plus `--elevation-xs`), pressing to `--key-press` and 92% scale. Focus is the 2 px ring with offset. The tick and dash are `motion.path` and draw in with the `{stiffness:420,damping:32,mass:0.8}` spring, but only after the user has toggled (a `touched` flag set in `onCheckedChange`), so SSR markup matches and nothing animates on load; reduced motion skips the draw.

<!-- PEBBLE-LICENSE -->
View source

registry/input/checkbox/checkbox.tsx

"use client";

/* PEBBLE-LICENSE
Built by Pebble. Component: checkbox.

First-party license: MIT

The following first-party terms apply only to original Pebble material.

MIT License

Copyright (c) 2026 Praxys Solutions LLC (Pebble)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

THIRD-PARTY NOTICES
These notices apply to identified upstream portions; Pebble terms do not replace or narrow their rights.

Upstream: https://raw.githubusercontent.com/shadcn-ui/ui/main/LICENSE.md
MIT License

Copyright (c) 2023 shadcn

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
END PEBBLE-LICENSE */

import * as React from "react";
import { Checkbox as CheckboxPrimitive } from "radix-ui";
import { motion, useReducedMotion } from "motion/react";

import { cn } from "@/lib/utils";

export type CheckboxProps = React.ComponentProps<typeof CheckboxPrimitive.Root>;

const draw = { type: "spring", stiffness: 420, damping: 32, mass: 0.8 } as const;

export function Checkbox({ className, onCheckedChange, ...props }: CheckboxProps) {
  // The mark only draws in after a real change. On first render (and on the
  // server) it is shown finished, so SSR markup and hydration match.
  const [touched, setTouched] = React.useState(false);
  const reduce = useReducedMotion();
  const animate = touched && !reduce;

  return (
    <CheckboxPrimitive.Root
      data-slot="checkbox"
      onCheckedChange={(next) => {
        setTouched(true);
        onCheckedChange?.(next);
      }}
      className={cn(
        "peer group/checkbox relative inline-grid size-4 shrink-0 cursor-pointer place-content-center rounded-[5px] border select-none",
        "transition-[background-color,border-color,box-shadow,transform,filter] duration-(--motion-fast) ease-enter motion-reduce:transition-none",
        // Unchecked is a recessed well: card fill, control edge at full
        // strength (the scripted 3:1 token) and a soft inner shade.
        "border-border-control bg-card inset-shadow-xs enabled:hover:border-muted-foreground enabled:hover:bg-muted",
        // Checked and mixed are the lit key, so state reads from fill and
        // light, not hue alone.
        "data-[state=checked]:border-key-edge data-[state=checked]:bg-linear-to-b data-[state=checked]:from-key-top data-[state=checked]:to-key-bottom data-[state=checked]:text-primary-foreground data-[state=checked]:shadow-[var(--key-shine),var(--elevation-xs)] data-[state=checked]:inset-shadow-none",
        "data-[state=indeterminate]:border-key-edge data-[state=indeterminate]:bg-linear-to-b data-[state=indeterminate]:from-key-top data-[state=indeterminate]:to-key-bottom data-[state=indeterminate]:text-primary-foreground data-[state=indeterminate]:shadow-[var(--key-shine),var(--elevation-xs)] data-[state=indeterminate]:inset-shadow-none",
        "enabled:data-[state=checked]:hover:border-key-edge enabled:data-[state=checked]:hover:brightness-110 enabled:data-[state=indeterminate]:hover:border-key-edge enabled:data-[state=indeterminate]:hover:brightness-110",
        // Press is felt: a small drop, and the key loses its shine.
        "enabled:active:scale-[0.92] enabled:data-[state=checked]:active:shadow-[var(--key-press)] enabled:data-[state=indeterminate]:active:shadow-[var(--key-press)] motion-reduce:enabled:active:scale-100",
        "outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
        "aria-invalid:border-danger aria-invalid:ring-[3px] aria-invalid:ring-danger/20 aria-invalid:focus-visible:ring-2 aria-invalid:focus-visible:ring-danger/60",
        "disabled:cursor-not-allowed disabled:opacity-50",
        // Forced colors drop author backgrounds: paint the filled states with
        // Highlight and the mark with HighlightText.
        "forced-colors:border-[CanvasText] forced-colors:data-[state=checked]:border-[Highlight] forced-colors:data-[state=checked]:bg-[Highlight]! forced-colors:data-[state=checked]:text-[HighlightText] forced-colors:data-[state=indeterminate]:border-[Highlight] forced-colors:data-[state=indeterminate]:bg-[Highlight]! forced-colors:data-[state=indeterminate]:text-[HighlightText]",
        className,
      )}
      {...props}
    >
      <CheckboxPrimitive.Indicator
        data-slot="checkbox-indicator"
        className="grid place-content-center text-current"
      >
        <svg
          data-slot="checkbox-check"
          aria-hidden="true"
          viewBox="0 0 12 12"
          fill="none"
          stroke="currentColor"
          strokeWidth={1.75}
          strokeLinecap="round"
          strokeLinejoin="round"
          className="size-3 group-data-[state=indeterminate]/checkbox:hidden"
        >
          <motion.path
            d="M2.75 6.25 5 8.5l4.25-4.75"
            initial={animate ? { pathLength: 0, opacity: 0 } : false}
            animate={{ pathLength: 1, opacity: 1 }}
            transition={{ pathLength: draw, opacity: { duration: 0.08 } }}
          />
        </svg>
        <svg
          data-slot="checkbox-dash"
          aria-hidden="true"
          viewBox="0 0 12 12"
          fill="none"
          stroke="currentColor"
          strokeWidth={1.75}
          strokeLinecap="round"
          className="hidden size-3 group-data-[state=indeterminate]/checkbox:block"
        >
          <motion.path
            d="M3.25 6h5.5"
            initial={animate ? { pathLength: 0, opacity: 0 } : false}
            animate={{ pathLength: 1, opacity: 1 }}
            transition={{ pathLength: draw, opacity: { duration: 0.08 } }}
          />
        </svg>
      </CheckboxPrimitive.Indicator>
    </CheckboxPrimitive.Root>
  );
}
Pebble

Small details.
Better interfaces.

React components to explore, make your own, and build on.

Library

  • Components
  • Installation
  • Pricing

Resources

  • For agents
  • About
  • Support

Legal

  • License
  • Terms
  • Privacy
  • Final sale

Built by Pebble

A product of Praxys Solutions LLC ↗

Pebble Pro is live

$49 one time, lifetime updates ↗