Select
Pick one of 5+ values from a list.
$ npx shadcn@latest add https://mahrdesign.faizintifada.com/r/select.jsonDefault
Sizes
People (SelectPerson)
Placeholder, error, disabled
Pilih hubungan kontak ini.
When to use
- Pick one value from 5 or more: Hubungan, Departemen, Jabatan, Bank, Status PTKP.
- A toolbar filter (size sm, 44): "Semua departemen".
When not to use
- 2–4 short options → SegmentedControl (all choices stay visible).
- Options need a description → RadioGroup / RadioCard.
- More than one value → ChoiceCard group.
- Actions, not values → DropdownMenu.
Do and don't
Order options the way people thinkSuami, Istri, Orang tua, Anak, Saudara, Lainnya. "Lainnya" always last.
A Select for 3 optionsJenis cuti (Tahunan · Penting · Sakit) hidden in a list costs a click and a memory. Use SegmentedControl.
Installation
Add Select 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
Select (Root)
import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from "@/components/ui/select"| Prop | Type | Default | Description |
|---|---|---|---|
value · defaultValue · onValueChange | string · (value) => void | – | Controlled or uncontrolled. |
items | { value; label }[] | – | Lets SelectValue show the label for a coded value (PTKP). |
disabled · required · name | Base UI Select.Root props | – | Wrap in <Field> for label, helper, error. |
SelectTrigger
<SelectTrigger size aria-invalid>| Prop | Type | Default | Description |
|---|---|---|---|
size | "default" | "sm" | "default" | 48 full width / 44 fit (toolbar). |
aria-invalid | boolean | – | Error edge. |
SelectValue · SelectItem
<SelectValue placeholder /> · <SelectItem value disabled>| Prop | Type | Default | Description |
|---|---|---|---|
placeholder | string | – | An example value or "Pilih …". |
SelectItem value · disabled | string · boolean | – | Children = visible label. |
SelectPerson name · meta · src | string · string? · string? | – | A person option: avatar 32 (decorative) + "name · meta". Use it in the items AND in the SelectValue render function, so both show the same face. Trigger and item get pl-2 by themselves. |