Skip to content
العربية
Saudi forms and dates

TimeInput

A time of day on the 12-hour clock: an hour 1–12, a minute (steps of minuteStep, default 5) and AM/PM, ص/م in Arabic. It reads left to right in both languages. A step from 11 to 12 crosses noon or midnight, as on a clock. The value is "HH:mm" in 24 hours, and name posts it. hourCycle="h23" (or the PercentProvider setting) shows hours 00–23 and no AM/PM; the value does not change. formatTimeOfDay takes the same option.

import { TimeInput, splitTime, joinTime, formatTimeOfDay } from "@percentsa/ui";

Examples

value: 09:00

Code
export function TimeInputExample() {
  const t = useT();
  const [time, setTime] = useState<string | null>("09:00");
  return (
    <Stack gap={3}>
      <Field label={t("Opens at", "يفتح الساعة")}>
        <TimeInput value={time} onValueChange={setTime} name="opens" />
      </Field>
      <Text size="sm" tone="subtle" dir="ltr">value: {time}</Text>
      <Field label={t("Closes at (24 hours)", "يغلق الساعة (24 ساعة)")}>
        <TimeInput value={time} onValueChange={setTime} hourCycle="h23" />
      </Field>
    </Stack>
  );
}

/** It sends a value only when the date and the time are both set. */