Skip to content

Checkbox

A yes/no choice for forms, with a checked, unchecked and indeterminate state and a springy tick.

Base UI1.6 kB gzipSource Registry JSON

Checkbox playground

Props

Installation

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

The CLI writes components/ikada/checkbox.tsx and merges the ikada theme into your CSS. Or take it from the package: import { Checkbox } from "@sproutboat/ikada";

Usage

import { Checkbox } from "@/components/ikada/checkbox";

<Checkbox label="Preview builds" description="Build every pull request on its own URL." defaultChecked />

Examples

States

A box bobs once as it fills. Checked is a solid green fill, 3:1 against the unchecked box.

Invalid

Without a label

Pass aria-label so the box still has a name.

Props

CheckboxProps
PropTypeDescription
classNamestringClasses merged onto the root element, after ikada's own.
labelReactNodeVisible label. Without one, pass aria-label.
descriptionReactNodeMuted line under the label, linked to the checkbox as its description.
invalidbooleanMarks the checkbox invalid: danger ring and aria-invalid.
styleCSSProperties | ((state: CheckboxRootState) => CSSProperties)Style applied to the element, or a function that returns a style object based on the component's state.
renderReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, CheckboxRootState>Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.

Also takes every prop of Omit<ComponentProps<typeof BaseCheckbox.Root>, "className" | "children">.

Source: src/components/checkbox.tsx