DateField
Pick a date from a calendar popup.
$ npx shadcn@latest add https://mahrdesign.faizintifada.com/r/date-field.jsonSingle date
Range: two fields + computed length
2 hari kerja
Calendar popup
Empty, error, disabled
Sisa cuti tahunan 5 hari (2 hari lain menunggu HR). Pilih paling banyak 5 hari kerja.
When to use
- Tanggal mulai / selesai cuti (two fields side by side, 12 apart).
- Tanggal bergabung, tanggal lahir, akhir kontrak, tanggal keluar.
When not to use
- Show leave and holidays over a month (no picking) → MonthCalendar (composite).
- A month only (slip, payroll period) → Select with month names.
Do and don't
Count working days for the userShow "2 hari kerja" with the reason for skipped days. Users should never count days themselves.
Typed dates or a Sunday-first week"23/12/2026" typed by hand, or a US week. Indonesian users read Senin as the first day and month names, not numbers.
Installation
Add DateField 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
import { DateField } from "@/components/ui/date-field"| Prop | Type | Default | Description |
|---|---|---|---|
value · defaultValue | string | null (ISO "2026-12-23") | – | ISO in, ISO out. Display format is fixed (id-ID). |
onChange | (value: string | null) => void | – | Closes the popup after a pick. |
min · max | string (ISO) | – | Days outside are disabled in the popup. |
holidays | { date: string; name: string }[] | [] | Grey cell + red bar; the name is in the day's aria-label. |
placeholder | string | "Pilih tanggal" | |
invalid · disabled | boolean | – | Error edge / 60 %. |
id · name · className | string | – | name adds a hidden input with the ISO value. |