DateTimePicker
Un día y una hora en un control: un momento. El día se puede elegir en un calendario; la hora se escribe.
import { DateTimePicker } from '@sypnia/ui/react'
En esta página
Un momento
Escribe la hora, elige el día. La pista lo muestra como lo diría una persona.
21 nov 2026, 2:30, in the time zone of the project. Saved as 2026-11-21T02:30.
Código
import { useState } from 'react';
import { DateTimePicker, Field, FormGrid, useSypnia } from '@sypnia/ui/react';
export default function Basic() {
const { format } = useSypnia();
const [at, setAt] = useState<string | null>('2026-11-21T02:30');
return (
<FormGrid>
<Field label="Start the maintenance at" hint={at ? <>{format.dateTime(at)}, in the time zone of the project. Saved as <code>{at}</code>.</> : 'Choose a quiet moment.'}>
<DateTimePicker value={at} onChange={setAt} min="2026-11-17" />
</Field>
</FormGrid>
);
} Estados
Con un error que dice cómo arreglarlo, y desactivado.
That moment has passed. Choose one after now.
Made by the nightly job.
Código
import { DateTimePicker, Field, FormGrid } from '@sypnia/ui/react';
export default function States() {
return (
<FormGrid>
<Field label="Run the export at" error="That moment has passed. Choose one after now.">
<DateTimePicker defaultValue="2026-11-10T09:00" />
</Field>
<Field label="Last backup" hint="Made by the nightly job.">
<DateTimePicker disabled defaultValue="2026-11-17T03:00" />
</Field>
</FormGrid>
);
} Cuándo usarlo
Úsalo cuando
- Algo pasa una vez, en un momento exacto: un mantenimiento, una exportación programada, el fin de una oferta.
- Día y hora solo tienen sentido juntos.
No lo uses cuando
- Solo importa el día: DatePicker.
- Se repite cada día a la misma hora: TimePicker.
- Es un período: DateRangePicker.
Para todos
- Cada parte (día, mes, año, hora, minuto) es un
spinbutton: escribir la llena y salta a la siguiente; las flechas la cambian y se mueven entre partes. - El botón abre el calendario; elegir un día conserva la hora escrita.
- El valor es texto ISO sin zona horaria (
2026-11-17T14:30): di al lado a qué zona se refiere. - Dentro de un Field toma la etiqueta, la pista y el error por sí solo; suelto, dale un
aria-label.
Props
| DateTimePicker | Tipo | Por defecto |
|---|---|---|
aria-describedby | string | |
aria-labelThe name for screen readers when there is no Field around it. | string | |
aria-labelledby | string | |
className | string | |
defaultValue | string | |
disabled | boolean | |
hourCycle12 or 24 hours. By default, what the language uses. | 12 | 24 | |
idInside a Field it comes from the Field. | string | |
invalidMarks the value as wrong. Inside a `<Field error>` it is set for you. | boolean | |
maxThe last day that can be chosen. | string | |
minThe first day that can be chosen, as `2026-11-01`. | string | |
nameThe name of the value when it travels in a form. | string | |
onChange | ((dateTime: string | null) => void) | |
unavailableDays that cannot be chosen: return true for them. | ((date: string) => boolean) | |
valueThe moment, as `2026-11-17T14:30`, or null while it is empty. | string | null |