Checkbox
A control that allows the user to toggle between checked and not checked.
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
$ bext ui add checkbox
Copy and paste the following into src/components/ui/checkbox.tsx.
This component is interactive — make sure the shared island is loaded (see Islands). It reacts to data-ui="checkbox" hooks.
Usage
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
<Checkbox id="x" checked />
Edit this component live in the bext playground. The PRISM + signals version is the bext-native idiom — fine-grained reactivity, no virtual DOM.
Pure PRISM + real bext signals — fine-grained, no re-render.
The React idiom — same UI, for comparison.
On This Page