Checkbox

A tick box with a visible label, including a mixed state.

'use client';

import { useState } from 'react';
import { Checkbox } from '@brand-studio/ui';

const bags = ['Ethiopia Guji', 'Colombia Huila', 'Kenya Nyeri'];

export default function CheckboxDemo() {
  const [picked, setPicked] = useState(['Ethiopia Guji']);
  const toggle = (bag: string, on: boolean) => setPicked((current) => (on ? [...current, bag] : current.filter((item) => item !== bag)));
  return (
    <div style={{ display: 'grid', gap: 14, maxWidth: 360 }}>
      <Checkbox
        label="All three bags"
        checked={picked.length === bags.length}
        indeterminate={picked.length > 0 && picked.length < bags.length}
        onCheckedChange={(on) => setPicked(on ? bags : [])}
      />
      <div style={{ display: 'grid', gap: 12, paddingLeft: 32 }}>
        {bags.map((bag) => <Checkbox key={bag} label={bag} checked={picked.includes(bag)} onCheckedChange={(on) => toggle(bag, on)} />)}
      </div>
    </div>
  );
}

Installation

pnpm add @brand-studio/ui

Usage

import { Checkbox } from '@brand-studio/ui';
<Checkbox label="Grind for filter" defaultChecked />

Accessibility

  • Renders a native <button role="checkbox"> with a real <label>. Space toggles it.
  • indeterminate sets aria-checked="mixed" for a parent box whose group is partly ticked.
  • description is linked with aria-describedby.

API Reference

PropTypeDefault
labelstring
description?string
checked?boolean
defaultChecked?boolean
indeterminate?boolean
onCheckedChange?((checked: boolean) => void)
disabled?boolean
name?string
value?string
className?string''

Still, Deskhand and Hollis are fictional brands. The coffee photographs are original generated artwork. @brand-studio/ui is MIT licensed.