Atoms / Time picker

Time picker

A time typed or chosen: spinbuttons, AM and PM in 12 hours, a list every few minutes.

import { TimePicker } from "@forgeron/ui";
/01 → 24 hours
1430
14:30
import { 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>
  );
}
/02 → 12 hours
0930
import { TimePicker } from "@forgeron/ui";

export default function Hours12() {
  return <TimePicker label="Reminder" hour12 step={30} defaultValue="09:30" />;
}
API → Props
PropTypeDefaultDescription
labelstring—Names the field for assistive technology.
value / defaultValuestring | null—Controlled or not. `HH:mm`, always 24 hours.
onChange(value: string | null) => void—On every change.
hour12booleanfalseWrites it in 12 hours with AM and PM; the value stays HH:mm.
stepnumber15Minutes between the times of the list, and of the arrows on minutes.
disabledboolean—Not editable.
id / aria-describedby / aria-invalidstring / string / boolean—From `Field`'s function form: the label, hint and error stay tied.
classNamestring—Extra classes.