Checkbox

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

Overview

The Checkbox component allows users to select one or more options from a set, providing a binary choice with visual feedback for checked, unchecked, and indeterminate states. Built on Base UI primitives, it features customizable sizes and URL state management for seamless integration with modern web applications.

Usage

import { Checkbox } from "@tilt-legal/cubitt-components/primitives";
<Checkbox />

Examples

Checked by Default

Indeterminate

Disabled

With Description

Sizes

URL State

This example syncs with the URL parameter "demo-terms".

API Reference

Checkbox

The root component for creating checkboxes with customizable sizes and URL state management.

PropTypeDefaultDescription
checkedboolean-The controlled checked state of the checkbox.
defaultCheckedbooleanfalseThe default checked state when uncontrolled.
indeterminateboolean-Whether the checkbox is in an indeterminate state.
defaultIndeterminatebooleanfalseWhether the checkbox starts in an indeterminate state when uncontrolled.
onCheckedChange(checked: boolean, eventDetails) => void-Callback fired when the checked state changes.
disabledbooleanfalseWhether the checkbox is disabled.
requiredbooleanfalseWhether the checkbox is required in a form.
readOnlybooleanfalseWhether the user should be unable to change the checkbox state.
namestring-The name of the checkbox when used in a form.
valuestring-The value of the checkbox when used in a form.
idstring-The id attribute for the checkbox input.
size"sm" | "md" | "lg""md"The size of the checkbox.
classNamestring-Additional CSS classes to apply to the checkbox.
inputRefReact.Ref<HTMLInputElement>-A ref to access the hidden <input> element.

URL State Props

When provided with a paramName, the checkbox will sync its checked state with URL parameters via TanStack Router search params.

PropTypeDefaultDescription
paramNamestring-URL parameter name for syncing state with URL. Enables URL state management.
paramValueboolean | "indeterminate"-Controlled value for the URL parameter.
onUrlValueChange(value: boolean | "indeterminate" | null) => void-Callback when URL parameter value changes.
paramClearOnDefaultbooleantrueRemove URL param when value equals default.
paramThrottlenumber-Throttle URL updates in milliseconds.
paramDebouncenumber-Debounce URL updates in milliseconds.

On this page