Selection & Dates
@hacline/ui/date-pickerDatePicker
Choose a date using text input or a calendar popover.
Usage
Omit children for a unified input shell with an inline calendar icon trigger, optional clearable reset button, format hint, and anchored calendar popover.
Date format: MM/DD/YYYY
"use client";
import { DatePicker } from "@/components/ui/hacline/components/date-picker";
import { Field, FieldLabel } from "@/components/ui/hacline/components/field";
export const Example = () => (
<Field className="w-full max-w-xs" name="deadline">
<FieldLabel>Delivery deadline</FieldLabel>
<DatePicker
clearable
defaultMonth="2026-12"
defaultValue="2026-12-18"
hint="Date format: MM/DD/YYYY"
locale="en-US"
/>
</Field>
);Selecting Start and End Dates
Set mode="range" to render start and end inputs inside one shared container with an inline calendar trigger; the popover closes once both endpoints are chosen.
"use client";
import { DatePicker } from "@/components/ui/hacline/components/date-picker";
import { Field, FieldLabel } from "@/components/ui/hacline/components/field";
export const Example = () => (
<Field className="w-full max-w-sm" name="leave">
<FieldLabel>Leave dates</FieldLabel>
<DatePicker
clearable
defaultValue={["2026-12-15", "2026-12-18"]}
endInputLabel="Leave end date"
inputLabel="Leave start date"
locale="en-US"
mode="range"
/>
</Field>
);Variants & Sizes
Customize appearance with variant ("default" / "filled") and size ("sm" / "md" / "lg").
"use client";
import { DatePicker } from "@/components/ui/hacline/components/date-picker";
import { Field, FieldLabel } from "@/components/ui/hacline/components/field";
export const Example = () => (
<div className="grid w-full max-w-sm gap-4">
<Field name="billing-date">
<FieldLabel>Billing date (filled + small)</FieldLabel>
<DatePicker
clearable
defaultValue="2026-12-01"
locale="en-US"
size="sm"
variant="filled"
/>
</Field>
<Field name="launch-date">
<FieldLabel>Launch date (large)</FieldLabel>
<DatePicker clearable locale="en-US" placeholder="MM/DD/YYYY" size="lg" />
</Field>
</div>
);Parts
Pass custom children when you need full layout control over the input, trigger, presets, or calendar popup.
| Part | Description | Extended Props |
|---|---|---|
DatePickerClear | Clears the value and focuses the input. | size |
DatePickerContent | The popup. Without children it renders Previous, the heading, Next and a grid for each month; every Calendar part works inside it. | — |
DatePickerHint | The format to type, like "MM/DD/YYYY". The inputs are described by it. | — |
DatePickerInput | A text input that reads a date typed in the page's language on Enter or blur. end makes it a range's end. | size |
DatePickerPreset | Selects the value it holds, like the last 7 days. | size |
DatePickerTrigger | Opens the calendar. Named "Choose date" and the date chosen; pass aria-label in another language. | size |
CalendarDay | A day. Shows the day of the month unless it has children; arrow keys move between days. | — |
CalendarGrid | One month's grid, a table. offset picks which of the months shown, from 0. Without children it renders its weekdays and weeks. | — |
CalendarHeading | The months shown, like "October 2026". Screen readers hear it change. | — |
CalendarMonthSelect | A native select of the months, in the locale, that turns the first month shown. | — |
CalendarNext | Shows the month after. Named "Next month"; pass aria-label in another language. | — |
CalendarPrevious | Shows the month before. Named "Previous month"; pass aria-label in another language. | — |
CalendarWeekday | A weekday's column header. Shows its name in weekdayFormat unless it has children. | — |
CalendarWeekdays | The header row of weekday names, a weekday in each column. Its children can be a function of the column's index that renders it, like (index) => <CalendarWeekday index={index} className="…" />. | — |
CalendarWeeks | The weeks of the grid's month, a row each, with a day in each cell. Its children can be a function of a cell that renders its day, like (cell) => <CalendarDay value={cell.date} className="…" />. A cell that shows nothing stays an empty cell. | — |
CalendarYearSelect | A native select of the years from min to max, or 10 either side of the year shown. | — |
Props
Prop
Type