Skip to content

Components

Checkbox

A checkbox under a cap of clear glass: the box and its mark are always seen through the lens.

Markdown
checkbox.tsx

Use it for

  • Choosing any number of items in a list or a form.
  • Agreeing to something that is submitted later.

Not for

  • A setting that takes effect at once: use Switch.
  • One choice out of several: use Tabs.

Installation

Coming soon
npm install @vitrumui/react
No dependencies

Usage

app.tsx
import { Checkbox } from '@vitrumui/react/controls/checkbox'

const [remember, setRemember] = useState(true)

<Checkbox label="Remember this device" checked={remember} onChange={setRemember} />

The glass cap is there at rest, not only while pressed. Needs three, like Slider.

Examples

Coming soon

API reference

PropTypeDefault
checked

Checked or not.

booleantrue
onChange

Called with the new state.

(checked: boolean) => void—
label

Text beside the box; an empty string leaves the box alone.

string'Remember this device'
description

A second, quieter line under the label.

string—
shape

A rounded square or a circle.

'rounded' | 'circle''rounded'
size

Box size 18, 22 or 28 px.

'sm' | 'md' | 'lg''md'
color

The box while checked: a hex, rgb() or named colour, not a CSS variable.

string'#3291FF'
theme

Overrides the page theme for this checkbox.

'light' | 'dark'—
disabled

Dimmed and not interactive.

booleanfalse
swell

How much the cap grows while pressed.

number1.18

Accessibility

  • A <button role="checkbox"> with aria-checked: Space toggles it.
  • The label is a real <label> tied to the button.
  • With reduced motion the mark and the cap change without springs.