A Radix checkbox with checked and indeterminate (mixed) states, a check or minus icon, focus ring and invalid styling, for forms and select-all lists.
What changed
- 1.0.1 Oct 11, 2026Switch track, thumb travel, and checkbox and radio size follow the platform feel tokens (--bm-switch-*, --bm-check-size); select and command surfaces take the feel's frosting. Unchanged without a feel.
- 1.0.0 Sep 28, 2026First release.
You agree to our Terms of Service and Privacy Policy.
import { Checkbox } from "@/components/ballmac/checkbox"
import { Label } from "@/components/ballmac/label"
export default function CheckboxDemo() {
return (
<div className="flex w-full max-w-sm flex-col gap-5">
<div className="flex items-start gap-3">
<Checkbox id="terms" defaultChecked aria-describedby="terms-description" />
<div className="grid gap-1.5">
<Label htmlFor="terms">Accept terms and conditions</Label>
<p id="terms-description" className="text-sm text-muted-foreground">
You agree to our Terms of Service and Privacy Policy.
</p>
</div>
</div>
<div className="flex items-center gap-3">
<Checkbox id="updates" />
<Label htmlFor="updates">Email me product updates</Label>
</div>
<div className="flex items-center gap-3">
<Checkbox id="beta" disabled />
<Label htmlFor="beta">Join the beta (invite only)</Label>
</div>
</div>
)
}Installation
The default, and what a Radix-style project installs.
$ pnpm dlx shadcn@latest add @ballmac/checkboxInstall the dependencies.
$ pnpm add radix-ui lucide-reactCopy the source into your project.
components/ballmac/checkbox.tsx// Ballmac UI: Checkbox. https://ui.ballmac.com/components/checkbox // Based on shadcn/ui's Checkbox (MIT, Copyright (c) 2023 shadcn), restyled with an indeterminate state. "use client" import * as React from "react" import { CheckIcon, MinusIcon } from "lucide-react" import { Checkbox as CheckboxPrimitive } from "radix-ui" import { cn } from "@/lib/utils" type CheckboxProps = React.ComponentProps<typeof CheckboxPrimitive.Root> function Checkbox({ className, ...props }: CheckboxProps) { return ( <CheckboxPrimitive.Root data-slot="checkbox" className={cn( "peer relative size-[var(--bm-check-size,calc(var(--spacing)*4))] shrink-0 rounded-[4px] border border-input bg-background shadow-xs outline-none transition-[color,background-color,border-color,box-shadow] duration-150 dark:bg-input/30", "after:absolute after:-inset-2 after:content-['']", "hover:border-foreground/30 focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50", "disabled:cursor-not-allowed disabled:opacity-50", "aria-invalid:border-destructive aria-invalid:ring-destructive/20", "data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground", "data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground", className )} {...props} > <CheckboxPrimitive.Indicator data-slot="checkbox-indicator" className="group/indicator flex items-center justify-center text-current transition-none" > <CheckIcon className="size-3.5 group-data-[state=indeterminate]/indicator:hidden" strokeWidth={3} aria-hidden="true" /> <MinusIcon className="hidden size-3.5 group-data-[state=indeterminate]/indicator:block" strokeWidth={3} aria-hidden="true" /> </CheckboxPrimitive.Indicator> </CheckboxPrimitive.Root> ) } export { Checkbox, type CheckboxProps }Update the import paths to match your project setup.
$ pnpm dlx shadcn@latest add https://ui.ballmac.com/r/base/checkbox.jsonInstall the dependencies.
$ pnpm add lucide-react @base-ui/react@^1.9.0Add the Ballmac items it builds on (their Base UI versions where they have one).
$ pnpm dlx shadcn@latest add https://ui.ballmac.com/r/base/fieldset.jsonCopy the source into your project.
components/ballmac/checkbox.tsx// Ballmac UI: Checkbox. https://ui.ballmac.com/components/checkbox // Based on shadcn/ui's Checkbox (MIT, Copyright (c) 2023 shadcn), restyled with an indeterminate state. "use client" import * as React from "react" import { CheckIcon, MinusIcon } from "lucide-react" import { Checkbox as CheckboxPrimitive } from "@base-ui/react/checkbox" import { useFieldsetDisabled } from "@/lib/ballmac/fieldset" import { cn } from "@/lib/utils" type CheckboxProps = Omit<React.ComponentProps<typeof CheckboxPrimitive.Root>, "checked" | "onCheckedChange" | "indeterminate" | "className"> & { className?: string /** `true`, `false` or "indeterminate" (some of a group is ticked). */ checked?: boolean | "indeterminate" onCheckedChange?: (checked: boolean) => void } function Checkbox({ className, checked, onCheckedChange, disabled, ref, ...props }: CheckboxProps) { const fieldset = useFieldsetDisabled<HTMLElement>(disabled, ref as React.Ref<HTMLElement>) const indeterminate = checked === "indeterminate" return ( <CheckboxPrimitive.Root ref={fieldset.ref} disabled={fieldset.disabled} data-slot="checkbox" checked={checked === undefined ? undefined : indeterminate ? false : checked} indeterminate={indeterminate || undefined} onCheckedChange={onCheckedChange} className={cn( "peer relative size-[var(--bm-check-size,calc(var(--spacing)*4))] shrink-0 rounded-[4px] border border-input bg-background shadow-xs outline-none transition-[color,background-color,border-color,box-shadow] duration-150 dark:bg-input/30", "after:absolute after:-inset-2 after:content-['']", "hover:border-foreground/30 focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50", "data-disabled:cursor-not-allowed data-disabled:opacity-50", "aria-invalid:border-destructive aria-invalid:ring-destructive/20", "data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground", "data-indeterminate:border-primary data-indeterminate:bg-primary data-indeterminate:text-primary-foreground", className )} {...props} > <CheckboxPrimitive.Indicator data-slot="checkbox-indicator" className="group/indicator flex items-center justify-center text-current transition-none" > <CheckIcon className="size-3.5 group-data-indeterminate/indicator:hidden" strokeWidth={3} aria-hidden="true" /> <MinusIcon className="hidden size-3.5 group-data-indeterminate/indicator:block" strokeWidth={3} aria-hidden="true" /> </CheckboxPrimitive.Indicator> </CheckboxPrimitive.Root> ) } export { Checkbox, type CheckboxProps }Update the import paths to match your project setup.
Usage
import { Checkbox } from "@/components/ballmac/checkbox"The full example is in the Code tab above.
Examples
Select all
"use client"
import * as React from "react"
import { Checkbox } from "@/components/ballmac/checkbox"
import { Label } from "@/components/ballmac/label"
const events = [
{ id: "deploy", label: "Deployment finished" },
{ id: "invoice", label: "Invoice paid" },
{ id: "comment", label: "New comment" },
{ id: "member", label: "Member joined" },
]
export default function CheckboxIndeterminate() {
const [selected, setSelected] = React.useState<string[]>(["deploy", "comment"])
const all = selected.length === events.length
const state = all ? true : selected.length > 0 ? "indeterminate" : false
return (
<fieldset className="w-full max-w-xs rounded-xl border bg-card p-4">
<legend className="sr-only">Notify me about</legend>
<div className="flex items-center gap-3 border-b pb-3">
<Checkbox
id="events-all"
checked={state}
onCheckedChange={(checked) => setSelected(checked === true ? events.map((e) => e.id) : [])}
/>
<Label htmlFor="events-all">All events</Label>
<span className="ms-auto text-xs text-muted-foreground tabular-nums">
{selected.length}/{events.length}
</span>
</div>
<div className="flex flex-col gap-3 pt-3 ps-7">
{events.map((event) => (
<div key={event.id} className="flex items-center gap-3">
<Checkbox
id={`events-${event.id}`}
checked={selected.includes(event.id)}
onCheckedChange={(checked) =>
setSelected((prev) => (checked === true ? [...prev, event.id] : prev.filter((id) => id !== event.id)))
}
/>
<Label htmlFor={`events-${event.id}`} className="font-normal">
{event.label}
</Label>
</div>
))}
</div>
</fieldset>
)
}Accessibility
| Key | Action |
|---|---|
| Space | Toggles the checkbox |
| Tab | Moves focus to the checkbox |
Quality scorecard
Every applicable check passes
Measured in Chromium 153.0.8010.12 on October 19, 2026, on version 1.0.1, across 2 examples.
Passed: Accessibility scan
No serious or critical issues in light and dark, on a phone and a desktop (axe-core 4.13.0, WCAG 2.1 AA and best-practice rules).
Passed: Small screens
No sideways scrolling at 360, 390 or 1280 px wide.
Passed: Reduced motion
No endless animation to begin with.
Passed: Right to left
Mirrors correctly in Arabic, Hebrew, Persian and Urdu layouts (0% of elements off the mirror, limit 15%).
Passed: Clean console
No console errors or React hydration errors while loading.
Passed: Keyboard
7 tab stops, each showing a visible change when it takes focus. 2 documented keys.
Not applicable: Loading, empty and error
Does not show data or take submissions.
Passed: Automated tests
Covered by checkbox.test.tsx.
For information: Footprint
0.8 KB of source (gzip) in 1 file. Installs radix-ui, lucide-react.
Automated checks find a subset of problems and do not replace testing with a screen reader and a keyboard in your own app. What they miss.
Use with AI
Binary or tri-state choice. Pass checked="indeterminate" for a parent row whose children are partly selected; aria-checked becomes "mixed". Pair with Label via id/htmlFor. With the shadcn MCP server set up (guide), ask your agent:
Add the Ballmac UI Checkbox (@ballmac/checkbox) to this project with the shadcn MCP, then use it where it fits.
Use it for
- Agreeing to terms or opting into emails
- Multi-select lists and table row selection
- A select-all control that reflects partial selection
Not for
- Settings that apply immediately (use switch)
- Choosing exactly one option from several (use a radio group or select)
Registry JSON: https://ui.ballmac.com/r/checkbox.json
Credits
Based on shadcn/ui Checkbox, adapted by Ballmac. Free to use in personal and commercial projects.
- Registry
- shadcn/utils
Pairs well with
Label
An accessible form label built on Radix Label that dims itself when the paired peer control is disabled and never selects text on double-click.
Button
A button with six variants, three sizes, a pill shape and a built-in loading state. buttonVariants() styles links the same way.
Accordion
Vertically stacked disclosure sections on Radix Accordion, single or multiple open, with hairline dividers, a rotating plus and height animation.
Avatar
A Radix avatar with image and initials fallback, three sizes, an optional presence dot, and AvatarGroup for overlapping stacks with a +N overflow counter.
Ballmac UI Pro
Need the whole screen, not one piece?
311 premium blocks (dashboards, settings, calendars, mail, shops, onboarding), a private shadcn registry and Figma tokens. Blocks that show data come with loading, empty and error states built in.
Not ready? Try three Pro blocks free
Leave your email and the blocks appear right here, ready to copy. Yours to use in any project.