bx

Checkbox

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

tsx
<Checkbox id="terms" />
<Label htmlFor="terms">Accept terms</Label>

Checkbox — case à cocher stylée. En PRISM c'est un <div data-ui="checkbox"> avec l'état dans data-state. Toggle géré par l'island au clic.

Installation

Terminal
$ bext ui add checkbox

Usage

tsx
import { Checkbox, Label } from "@bext-stack/ui/primitives"

<div className="flex items-center gap-2">
  <Checkbox id="terms" />
  <Label htmlFor="terms">Accept terms and conditions</Label>
</div>

Anatomy

<Checkbox id="cb-id" checked={boolean} />

API Reference

Checkbox

Prop Type Default Description
id string Pour lier au Label.
checked boolean État initial. Toggle par l'island au clic.
name string Pour form submission.
value string Valeur postée quand checked.
disabled boolean undefined

Data Attributes

Attributs qu'on peut cibler en CSS custom pour override le style par état.

Attribute On Values Description
data-ui="checkbox" root L'island toggle data-state au clic.
data-state root "checked" | "unchecked" Reflète l'état actuel.

Keyboard

Key Action
Space Toggle la case.
Tab Focus / défocus.

Accessibility

Devrait porter role="checkbox" aria-checked. Toujours accompagner d'un <Label htmlFor>.

Examples

Checked par défaut

tsx
<Checkbox id="x" checked />
Try it live
Open in play

Edit this component live in the bext playground. The PRISM + signals version is the bext-native idiom — fine-grained reactivity, no virtual DOM.

src/app/page.tsx 2 files · signals · runs in your browser
Pure PRISM + real bext signals — fine-grained, no re-render.