Checkbox
Token-styled checkbox control with indeterminate support.
Preview
A live, theme-aware example rendered with the published component.
Loading preview…
Import
Import from the focused entry point below, or use the same named export from @tavojs/ui. Both are public APIs; measure the built application when comparing their bundle cost.
tsximport { Checkbox } from "@tavojs/ui/checkbox";The component import loads compiled component CSS. Enable tavoUi() for your project theme variables, or import @tavojs/ui/theme.css once for the package default theme. The equivalent CSS-safe component alias is @tavojs/ui/css/checkbox.
When to use
Use it when
Choose something else when
Examples
These examples include imports and local state where interaction requires it. Render the exported component in a page after completing UI installation. Demo state stays in the mounted component; connect file handling, persistence, and data loading to your application as needed.
Checkbox example
tsximport { Checkbox } from "@tavojs/ui/checkbox";
export function CheckboxExample1() {
return (
<>
<Checkbox defaultChecked aria-label="Enable notifications" />
</>
);
}Common props and defaults
A curated starting point. The complete TypeScript API below includes additional props and compound member contracts.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Optional class hook applied to the public root element owned by the component. |
checked | boolean | — | Configures checked for this component. |
defaultChecked | boolean | — | Configures defaultChecked for this component. |
indeterminate | boolean | — | Configures indeterminate for this component. |
disabled | boolean | — | Configures disabled for this component. |
size | Size | — | Configures size for this component. |
tone | "primary" | "secondary" | "neutral" | — | Configures tone for this component. |
Complete TypeScript API
Import from @tavojs/ui/checkbox. Published exports: Checkbox, CheckboxProps.
CheckboxProps
| Property | Type | Required | Description |
|---|---|---|---|
children | Child | No | Inherited children attribute accepted by Checkbox. |
className | string | No | Optional class hook applied to the public root element owned by the component. |
sx | Sx | No | Inherited sx attribute accepted by Checkbox. |
id | string | No | Inherited id attribute accepted by Checkbox. |
role | string | No | Inherited role attribute accepted by Checkbox. |
style | Record<string, unknown> | No | Inherited style attribute accepted by Checkbox. |
title | string | No | Inherited title attribute accepted by Checkbox. |
tabIndex | number | No | Inherited tabIndex attribute accepted by Checkbox. |
hidden | boolean | No | Inherited hidden attribute accepted by Checkbox. |
disabled | boolean | No | Configures disabled for this component. |
onClick | TavoEventHandler<MouseEvent> | No | Inherited onClick attribute accepted by Checkbox. |
onChange | TavoEventHandler<Event> | No | Inherited onChange attribute accepted by Checkbox. |
onInput | TavoEventHandler<Event> | No | Inherited onInput attribute accepted by Checkbox. |
onKeyDown | TavoEventHandler<KeyboardEvent> | No | Inherited onKeyDown attribute accepted by Checkbox. |
onFocus | TavoEventHandler<FocusEvent> | No | Inherited onFocus attribute accepted by Checkbox. |
onBlur | TavoEventHandler<FocusEvent> | No | Inherited onBlur attribute accepted by Checkbox. |
checked | boolean | No | Configures checked for this component. |
defaultChecked | boolean | No | Configures defaultChecked for this component. |
indeterminate | boolean | No | Configures indeterminate for this component. |
size | Size | No | Configures size for this component. |
tone | "neutral" | "primary" | "secondary" | No | Configures tone for this component. |
State ownership and DOM target
| Concern | Contract |
|---|---|
| State | Use checked to supply rendered state. Update it through the documented callback or native event handler. For browser-owned initial values, use defaultChecked instead. |
| DOM target | Native input attributes target the owned form control; wrapper-specific props stay on the documented component root. |
Anatomy and related components
This component exposes one public component root rather than a compound member API.
Limitations
Avoid Checkbox when wrapping controls without labels or accessible names.
Use only the documented props, entry points, and compound members. Internal DOM nesting and CSS class names can change without becoming part of the public component contract.
Accessibility
Use with `FormControlLabel` or provide `aria-label`.
Use with `FormControlLabel` or provide `aria-label`.
Component status
| Contract | Current value |
|---|---|
| Maturity | stable |
| Category | forms |
| Component import | @tavojs/ui/checkbox |
| Explicit CSS import | @tavojs/ui/css/checkbox |
| Preview | Interactive preview available on this page |