Time picker
A time typed or chosen: spinbuttons, AM and PM in 12 hours, a list every few minutes.
import { TimePicker } from "@forgeron/ui";1430
14:30import { TimePicker } from "@forgeron/ui";
import { useState } from "react";
export default function Hours24() {
const [time, setTime] = useState<string | null>("14:30");
return (
<div style={{ display: "grid", gap: 8 }}>
<TimePicker label="Start time" value={time} onChange={setTime} />
<code>{time ?? "none"}</code>
</div>
);
}0930
import { TimePicker } from "@forgeron/ui";
export default function Hours12() {
return <TimePicker label="Reminder" hour12 step={30} defaultValue="09:30" />;
}API → Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | — | Names the field for assistive technology. |
value / defaultValue | string | null | — | Controlled or not. `HH:mm`, always 24 hours. |
onChange | (value: string | null) => void | — | On every change. |
hour12 | boolean | false | Writes it in 12 hours with AM and PM; the value stays HH:mm. |
step | number | 15 | Minutes between the times of the list, and of the arrows on minutes. |
disabled | boolean | — | Not editable. |
id / aria-describedby / aria-invalid | string / string / boolean | — | From `Field`'s function form: the label, hint and error stay tied. |
className | string | — | Extra classes. |