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

DateTimePicker

A DatePicker and a TimeInput. It sends a value only when both parts are set. name posts "YYYY-MM-DDTHH:mm", a wall time with no zone: the app decides the zone.

import { DateTimePicker } from "@percentsa/ui";

Examples

value: —

Code
export function DateTimePickerExample() {
  const t = useT();
  const [value, setValue] = useState<{ date: PlainDate; time: string } | null>(null);
  return (
    <Stack gap={3}>
      <Field label={t("Appointment", "الموعد")}>
        <DateTimePicker value={value} onValueChange={setValue} name="at" />
      </Field>
      <Text size="sm" tone="subtle" dir="ltr">value: {value ? `${value.date}T${value.time}` : "—"}</Text>
    </Stack>
  );
}

/** mode="range": the first click sets the start, the second the end (they swap when the end is earlier); a third starts again. */