DateField

Pick a date from a calendar popup.

$ npx shadcn@latest add https://mahrdesign.faizintifada.com/r/date-field.json

Single date

The trigger is RAISED like Select. The value shows the weekday: "Rab, 2 Des 2026". Click to open the calendar.

Range: two fields + computed length

The second field gets min = the first value. Holidays and weekends inside the range are not counted; the app says so.

Lama · 25 Des libur (Natal) dan akhir pekan, tidak dihitung2 hari kerja

Calendar popup

Senin first. Day 40 × 40: today = inset 2px --foreground; selected = primary; weekend and holiday = --muted; holiday = red 16 × 4 bar. Always 6 week rows, so the popup never changes height. Motion: the popup uses transitions.dev menu dropdown: grows from the field edge, open 250 / close 150. Month change with ‹ / › (as MonthCalendar): the weeks enter 8 px from the click side with a fade + 3 px blur, 250 ms, and the caption swaps (04 Text swap). Arrow keys and Page Up / Down change the month at once. Reduced motion: no slide.

Desember 2026

Empty, error, disabled

Range errors go on the field that caused them (end before start, over the balance).

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

DoCount working days for the userShow "2 hari kerja" with the reason for skipped days. Users should never count days themselves.
Don'tTyped 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.

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

API

import { DateField } from "@/components/ui/date-field"
PropTypeDefaultDescription
value · defaultValuestring | 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 · maxstring (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.
placeholderstring"Pilih tanggal"
invalid · disabledboolean–Error edge / 60 %.
id · name · classNamestring–name adds a hidden input with the ISO value.