Checkbox & ChoiceCard
Yes/no choices inside a form.
$ npx shadcn@latest add https://mahrdesign.faizintifada.com/r/checkbox.jsonCheckbox states
With description (inside a form)
ChoiceCard
Apa yang mau diubah?
When to use
- A yes/no choice inside a form that is submitted with a button (Tanpa batas, Prorata, Wajib lampiran, Ikut BPJS).
- Several options the user can tick at once, as ChoiceCards ("Apa yang mau diubah?").
When not to use
- A setting that applies at once, outside a form → Switch.
- Exactly one of several options → RadioGroup / RadioCard.
- 2–4 short values, one at a time → SegmentedControl.
Which one?
Do and don't
Write the choice as a statement"Wajib lampiran": checked means yes. The description says what it causes.
A Switch inside a Sheet formA Switch says "this applies now". In a form that waits for Simpan, it lies. Use a Checkbox.
Installation
Add Checkbox & ChoiceCard with the shadcn CLI (your project needs a components.json and the MaHR theme: https://mahrdesign.faizintifada.com/r/theme.json), or copy the files by hand.
API
Checkbox
import { Checkbox } from "@/components/ui/checkbox"| Prop | Type | Default | Description |
|---|---|---|---|
checked · defaultChecked · onCheckedChange | boolean · (checked) => void | – | Controlled or uncontrolled. |
indeterminate | boolean | false | "Pilih semua" with a partial selection. |
disabled · required · name · value | Base UI Checkbox.Root props | – | Wrap with <Label> for the hit area. |
aria-invalid | boolean | – | 2px --danger edge. |
ChoiceCard
import { ChoiceCard } from "@/components/ui/choice-card"| Prop | Type | Default | Description |
|---|---|---|---|
label | ReactNode | – | 16 / 600. |
description | ReactNode | – | 14 grey, next to or under the label. |
…Checkbox props | Checkbox.Root props | – | checked, defaultChecked, onCheckedChange, disabled. |