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.
- v1.3.8ImprovedA
colorprop for the box while checked. The examples are now the checkbox in a few colours, nothing else. - v1.3.3ImprovedExamples: a list of choices with descriptions, both shapes in three sizes and a disabled box.
- v1.3.0NewThe checkbox of the first previews: always under a cap of clear glass.
- 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.jsonNo dependenciesOr 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 three and UI SDK, like Slider.
API reference
| Prop | Type | Default |
|---|---|---|
checkedChecked or not. | boolean | true |
onChangeCalled with the new state. | (checked: boolean) => void | — |
labelText beside the box; an empty string leaves the box alone. | string | 'Remember this device' |
descriptionA second, quieter line under the label. | string | — |
nameSubmits with the form around it under this name. | string | — |
shapeA rounded square or a circle. | 'rounded' | 'circle' | 'rounded' |
sizeBox size 18, 22 or 28 px. | 'sm' | 'md' | 'lg' | 'md' |
colorThe box while checked: a hex, | string | '#3291FF' |
themeOverrides the page theme for this checkbox. | 'light' | 'dark' | — |
disabledDimmed and not interactive. | boolean | false |
swellHow 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.