Skip to content

Components

Checkbox

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

Latest changeImprovedv1.3.8A color prop for the box while checked. The examples are now the checkbox in a few colours, nothing else.
  1. v1.3.8ImprovedA color prop for the box while checked. The examples are now the checkbox in a few colours, nothing else.
  2. v1.3.3ImprovedExamples: a list of choices with descriptions, both shapes in three sizes and a disabled box.
  3. v1.3.0NewThe checkbox of the first previews: always under a cap of clear glass.
  4. All changes →
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

npx shadcn@latest add https://onemorethink.dev/r/checkbox.json

Usage

app.tsx
import { Checkbox } from '@/components/liquid-glass/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 and UI SDK, like Slider.

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—
name

Submits with the form around it under this name.

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.