Skip to content
Klarhimmel UI

Checkbox

npx shadcn add @klarhimmel/checkbox

Examples

  • States

  • Group

  • Invalid

DetailsAbout, usage, props and more

A box that is on, off or mixed, with its label inside a 44 px row. Built on Radix Checkbox.

When to use

  • Use for

    Choices that are submitted with a form, and lists where several can be picked.

  • Not for

    A setting that applies right away. Use Switch.

  • Pairs with

    Field rows, fieldset and legend, Button.

Preview

Anyone in your organisation can see it.

You need to accept the terms to continue.

checkbox.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { Checkbox } from '@/components/klarhimmel/ui/checkbox';

export default function Example() {
  return (
    <Theme theme="brand">
      <Checkbox label="Send me the weekly summary" defaultChecked />
    </Theme>
  );
}

Import

Import

import { Checkbox } from '@/components/klarhimmel/ui/checkbox';
Files
checkbox.tsx, in components/klarhimmel/ui/. With it: theme, utils. npm: lucide-react.
Render in
Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.

Props

PropTypeDefaultDescription
labelReactNode-Visible label. Without one, pass aria-label.
hintReactNode-Help text under the label, wired as the description.
invalidboolean-Marks the box invalid; the hint turns into the error text.
checkedboolean | 'indeterminate'-Controlled or uncontrolled state. "indeterminate" shows a dash.
defaultCheckedbooleanfalseControlled or uncontrolled state. "indeterminate" shows a dash.
onCheckedChange(checked: boolean) => void-Called when the state changes.
namestring-With a name, the checkbox posts `value` (default "on") when checked.
valuestring'on'
requiredboolean-
native attributesButtonHTMLAttributes-Every native attribute of the element passes through, className included.

Accessibility

KeyDoes
SpaceChecks or unchecks
TabMoves focus; the ring is always visible

A group needs a fieldset and legend so the question is read with each box.

Accessibility