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 change Improved v3.0.19 Drawn in plain WebGL2 and without three, like Slider; it looks as it did.
  1. v3.0.19 Improved Drawn in plain WebGL2 and without three, like Slider; it looks as it did.
  2. v3.0.12 Fixed Unchecked, the box no longer keeps a small white dot where the check began: the mark is drawn inside the box's clip and not at all once it has faded out. Thanks to Axyl1410 for the fix.
  3. v1.3.8 Improved A color prop for the box while checked. The examples are now the checkbox in a few colours, nothing else.
  4. v1.3.3 Improved Examples: a list of choices with descriptions, both shapes in three sizes and a disabled box.
  5. v1.3.0 New The checkbox of the first previews: always under a cap of clear glass.
  6. All changes→
checkbox.svelte

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-svelte@latest add https://liquidglass.pulse.city/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 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.

Liquid Glass Svelte is open source and MIT licensed. If it saves you time, you can support the project.