Selection & Dates
@hacline/ui/time-inputTimeInput
Edit hours and minutes in locale-aware segmented time fields.
Usage
Type directly or use the arrow keys to adjust any segment. Setting hourCycle={24} displays 24-hour time while submitting a standard time string.
"use client";
import { useState } from "react";
import { Field, FieldLabel } from "@/components/ui/hacline/components/field";
import { TimeInput } from "@/components/ui/hacline/components/time-input";
export const Example = () => {
const [time, setTime] = useState<string | null>("14:30");
return (
<Field className="w-full max-w-xs" name="reminder-time">
<FieldLabel>Daily reminder time</FieldLabel>
<TimeInput
hourCycle={24}
locale="en-US"
onValueChange={setTime}
value={time}
/>
<output className="text-hl-fg-muted text-xs">
Form time: {time ?? "Incomplete"}
</output>
</Field>
);
};12-Hour Clock and Seconds
Use granularity="second" to add a seconds segment and hourCycle={12} to display AM and PM.
Displays AM / PM in the UI and submits a 24-hour value.
"use client";
import {
Field,
FieldDescription,
FieldLabel,
} from "@/components/ui/hacline/components/field";
import { TimeInput } from "@/components/ui/hacline/components/time-input";
export const Example = () => (
<Field className="w-full max-w-xs" name="scheduled-time">
<FieldLabel>Scheduled time</FieldLabel>
<TimeInput
defaultValue="13:05:30"
granularity="second"
hourCycle={12}
locale="en-US"
/>
<FieldDescription>
Displays AM / PM in the UI and submits a 24-hour value.
</FieldDescription>
</Field>
);Variants, Sizes & Clearable Addons
Customize appearance with variant ("default" / "filled"), size ("sm" / "md" / "lg"), leading prefix / trailing suffix addons, and a built-in clearable reset button.
UTC
"use client";
import { Field, FieldLabel } from "@/components/ui/hacline/components/field";
import { TimeInput } from "@/components/ui/hacline/components/time-input";
const ClockIcon = () => (
<svg
aria-hidden="true"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={1.75}
viewBox="0 0 16 16"
>
<circle cx="8" cy="8" r="6" />
<path d="M8 4.75V8l2.25 1.5" />
</svg>
);
export const Example = () => (
<div className="grid w-full max-w-sm gap-4">
<Field name="standup-time">
<FieldLabel>Standup time (prefix + clearable)</FieldLabel>
<TimeInput
clearable
defaultValue="09:30"
hourCycle={24}
locale="en-US"
prefix={<ClockIcon />}
suffix="UTC"
/>
</Field>
<Field name="quiet-hours">
<FieldLabel>Quiet hours (filled + small)</FieldLabel>
<TimeInput
clearable
defaultValue="22:00"
hourCycle={24}
locale="en-US"
size="sm"
variant="filled"
/>
</Field>
<Field name="alarm-time">
<FieldLabel>Alarm time (large)</FieldLabel>
<TimeInput defaultValue="07:15" hourCycle={12} locale="en-US" size="lg" />
</Field>
</div>
);Parts
Pass a custom children render function when you need full segment layout control.
| Part | Description |
|---|---|
TimeInputSegment | A segment, like the hour: an input arrow keys step and digits fill, named by its unit. The text between segments renders as a span. |
Props
Prop
Type