Forms

Checkbox group.

Named multiple choices with group validation and native form ownership.

LIVE PREVIEWTry it. It works.

Install the source

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/checkbox-group.json

Registry setup · Examples · API and behavior · Open the playground

COMPLETE EXAMPLES

Use it in context.

Each example includes its imports, data and state. The preview runs that same source. Include the stylesheet once in your application.

Grouped validation, native reset and external forms

Choose delivery channels with a group minimum, submit stable repeated values and reset an uncontrolled collection. Read-only choices remain submitted; disabled choices do not.

Keyboard

  • Tab visits native checkboxes. Space changes an editable choice.
  • Submitting without a delivery channel focuses the first enabled choice.
  • Reset restores the uncontrolled defaults unless Prevent reset is checked; controlled values remain owned by the host.

States covered

  • External native form
  • Required group validation
  • Repeated values
  • Read-only submission
  • Disabled exclusion
  • Uncontrolled and controlled reset
  • Prevented reset

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-checkbox-group-native-form.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import '@bld8/ui/styles.css';
import {useId,useState} from 'react';
import {Button,Checkbox,CheckboxGroup} from '@bld8/ui';
const channels=[{value:'email',label:'Email',description:'A review link in your inbox.'},{value:'in-app',label:'In-app',description:'An entry in your review queue.'},{value:'legacy',label:'Legacy feed',disabled:true}];
export default function CheckboxGroupFormExample(){
  const id=useId(),[prevent,setPrevent]=useState(false),[owned,setOwned]=useState<string[]>(['in-app']),[result,setResult]=useState('No delivery selection submitted.'),[reversed,setReversed]=useState(false);
  return <div style={{display:'grid',gap:24,maxWidth:600}}>
    <CheckboxGroup label="Delivery channels" name="delivery" form={id} options={reversed?[...channels].reverse():channels} defaultValue={['email']} required hint="Choose at least one available channel."/>
    <Button variant="ghost" onClick={()=>setReversed(value=>!value)}>Reverse delivery choice order</Button>
    <CheckboxGroup label="Host-owned channels" name="owned" form={id} options={channels} value={owned} onValueChange={setOwned}/>
    <CheckboxGroup label="Read-only channels" name="locked" form={id} options={channels} defaultValue={['email']} readOnly/>
    <CheckboxGroup label="Disabled channels" name="disabled" form={id} options={channels} defaultValue={['email']} disabled/>
    <Checkbox label="Prevent channel reset" checked={prevent} onCheckedChange={setPrevent}/>
    <form id={id} aria-label="Delivery channel submission" onReset={event=>{if(prevent){event.preventDefault();return;}setOwned(['in-app']);setResult('Delivery defaults restored.');}} onSubmit={event=>{event.preventDefault();const data=new FormData(event.currentTarget);setResult('Delivery: '+data.getAll('delivery').join(', ')+' | Host: '+data.getAll('owned').join(', ')+' | Locked: '+data.getAll('locked').join(', ')+' | Disabled: '+data.has('disabled'));}}>
      <div style={{display:'flex',gap:12,flexWrap:'wrap'}}><Button type="submit">Read delivery values</Button><Button variant="secondary" type="reset">Reset delivery choices</Button></div>
    </form><p role="status">{result}</p>
  </div>;
}

Quick reference

React / TypeScript
<CheckboxGroup label="Channels" name="channels"
  options={options} value={channels} onValueChange={setChannels} />

In the workspace or ZIP starter, import components from @bld8/ui and include @bld8/ui/styles.css once. Registry installations use your local bld8/ source path. Wrap overlays in UIProvider.

API & behaviour

Canonical repeated values, group labels, native required/min/max feedback, external forms and reset. Read-only choices remain submitted; disabled choices are excluded. Controlled state remains application-owned. Validate business rules again on the server.

CheckboxGroup

CheckboxGroup public properties
PropTypeDefault
labelRequiredstring—
optionsRequiredreadonly Option[]—
classNamestring | undefined—
defaultValuereadonly string[] | undefined[]
disabledboolean | undefinedfalse
errorstring | undefined—
formstring | undefined—
hintstring | undefined—
idstring | undefined—
inputRefRef<HTMLInputElement> | undefined—
maxSelectednumber | undefined—
minSelectednumber | undefined

Bounds apply to enabled submitted choices. Required sets a minimum of one.

0
namestring | undefined—
onBlurFocusEventHandler<HTMLInputElement> | undefined—
onValueChange((value: string[]) => void) | undefined—
readOnlyboolean | undefinedfalse
requiredboolean | undefinedfalse
valuereadonly string[] | undefined—

Tables come from the public TypeScript declarations. Related types and function parameters are shown alongside their component. A dash means no default is declared at the public function boundary.

Related controls

Notes to self

Test this component with real content, keyboard input and both themes. The example is a starting point; labels, error handling and behaviour still need to fit the application.