Select

Pick one of 5+ values from a list.

$ npx shadcn@latest add https://mahrdesign.faizintifada.com/r/select.json

Default

The trigger is RAISED (click to open). Open = focus recipe; the chevron turns 180°. Selected item: grey fill (bg-muted), dark text, the same weight, no tick. Motion: the list uses transitions.dev menu dropdown: grows from the trigger edge, scale .97 → 1 + fade, open 250 / close 150.

Sizes

default 48 in forms; sm 44 only as a toolbar filter (label visually hidden). Codes get their meaning: "K/0 · Kawin, tanpa tanggungan".

People (SelectPerson)

Choosing a person (Atasan, Kepala departemen, Penyetuju): every item AND the chosen value show the same face, avatar 32 + "name · jabatan" on one line. No photo → grey initials. The trigger and the items take an 8 px left padding by themselves when an avatar is inside; items stay 44 high. Never text-only items under a field that shows an avatar.

Atasan menyetujui cuti Putri.

Placeholder, error, disabled

Placeholder is "Pilih …" when no example value fits. Keyboard: Enter/Space opens, arrows move, Enter picks, Esc closes.

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

DoOrder options the way people thinkSuami, Istri, Orang tua, Anak, Saudara, Lainnya. "Lainnya" always last.
Don'tA 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.

terminal
bunx --bun shadcn@latest add https://mahrdesign.faizintifada.com/r/select.json

API

Select (Root)

import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from "@/components/ui/select"
PropTypeDefaultDescription
value · defaultValue · onValueChangestring · (value) => void–Controlled or uncontrolled.
items{ value; label }[]–Lets SelectValue show the label for a coded value (PTKP).
disabled · required · nameBase UI Select.Root props–Wrap in <Field> for label, helper, error.

SelectTrigger

<SelectTrigger size aria-invalid>
PropTypeDefaultDescription
size"default" | "sm""default"48 full width / 44 fit (toolbar).
aria-invalidboolean–Error edge.

SelectValue · SelectItem

<SelectValue placeholder /> · <SelectItem value disabled>
PropTypeDefaultDescription
placeholderstring–An example value or "Pilih …".
SelectItem value · disabledstring · boolean–Children = visible label.
SelectPerson name · meta · srcstring · 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.