Selection & Dates
@hacline/ui/date-inputDateInput
Edit dates segment by segment in locale-aware order.
Usage
Edit the year, month, or day segment with digits or arrow keys, or paste a complete date into any segment. Once all fields are filled, an ISO-formatted value is emitted.
"use client";
import { useState } from "react";
import { DateInput } from "@/components/ui/hacline/components/date-input";
import { Field, FieldLabel } from "@/components/ui/hacline/components/field";
export const Example = () => {
const [date, setDate] = useState<string | null>("2026-12-15");
return (
<Field className="w-full max-w-xs" name="start-date">
<FieldLabel>Project start date</FieldLabel>
<DateInput locale="en-US" onValueChange={setDate} value={date} />
<output className="text-hl-fg-muted text-xs">
ISO date: {date ?? "Incomplete"}
</output>
</Field>
);
};Locale Segment Order and Bounds
UK dates (en-GB) follow day, month, year order while keeping the submitted value in ISO format. Use min and max to constrain the valid expense date range.
Choose a date in December 2026.
"use client";
import { DateInput } from "@/components/ui/hacline/components/date-input";
import {
Field,
FieldDescription,
FieldLabel,
} from "@/components/ui/hacline/components/field";
export const Example = () => (
<Field className="w-full max-w-xs" name="expense-date">
<FieldLabel>Expense date</FieldLabel>
<DateInput
defaultValue="2026-12-08"
locale="en-GB"
max="2026-12-31"
min="2026-12-01"
/>
<FieldDescription>Choose a date in December 2026.</FieldDescription>
</Field>
);Variants, Sizes & Clearable Addons
Customize appearance with variant ("default" / "filled"), size ("sm" / "md" / "lg"), leading prefix icons, clearable reset buttons, and granularity="minute" for date-and-time editing.
"use client";
import { DateInput } from "@/components/ui/hacline/components/date-input";
import { Field, FieldLabel } from "@/components/ui/hacline/components/field";
const CalendarIcon = () => (
<svg
aria-hidden="true"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={1.75}
viewBox="0 0 16 16"
>
<rect height="11" rx="2" width="12" x="2" y="3" />
<path d="M5.5 1.75V4M10.5 1.75V4M2 6.5h12" />
</svg>
);
export const Example = () => (
<div className="grid w-full max-w-sm gap-4">
<Field name="release-date">
<FieldLabel>Release date (prefix + clearable)</FieldLabel>
<DateInput
clearable
defaultValue="2026-12-15"
locale="en-US"
prefix={<CalendarIcon />}
/>
</Field>
<Field name="invoice-date">
<FieldLabel>Invoice date (filled + small)</FieldLabel>
<DateInput
clearable
defaultValue="2026-12-01"
locale="en-GB"
size="sm"
variant="filled"
/>
</Field>
<Field name="meeting-datetime">
<FieldLabel>Meeting date & time (large)</FieldLabel>
<DateInput
defaultValue="2026-12-20T09:30"
granularity="minute"
locale="en-US"
size="lg"
/>
</Field>
</div>
);Parts
Pass a custom children render function when you need full segment layout control.
| Part | Description |
|---|---|
DateInputSegment | A segment, like the month: an input arrow keys step and digits fill, named by its unit. The text between segments renders as a span. |
Props
Prop
Type