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.
- v3.0.19 Improved Drawn in plain WebGL2 and without
three, like Slider; it looks as it did. - 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.
- v1.3.8 Improved A
colorprop for the box while checked. The examples are now the checkbox in a few colours, nothing else. - v1.3.3 Improved Examples: a list of choices with descriptions, both shapes in three sizes and a disabled box.
- v1.3.0 New The checkbox of the first previews: always under a cap of clear glass.
- All changes→
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.jsonNo dependencies Or copy the files by hand →
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
| Prop | Type | Default |
|---|---|---|
checked Checked or not. | boolean | true |
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, | string | '#3291FF' |
theme Overrides the page theme for this checkbox. | 'light' | 'dark' | — |
disabled Dimmed and not interactive. | boolean | false |
swell How much the cap grows while pressed. | number | 1.18 |
Accessibility
- A
<button role="checkbox">witharia-checked: Space toggles it. - The
labelis 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.