Ir al contenido

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
  1. Un momento
  2. Estados
  3. Cuándo usarlo
  4. Para todos
  5. Props

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

DateTimePickerTipoPor defecto
aria-describedby string
aria-label

The name for screen readers when there is no Field around it.

string
aria-labelledby string
className string
defaultValue string
disabled boolean
hourCycle

12 or 24 hours. By default, what the language uses.

12 | 24
id

Inside a Field it comes from the Field.

string
invalid

Marks the value as wrong. Inside a `<Field error>` it is set for you.

boolean
max

The last day that can be chosen.

string
min

The first day that can be chosen, as `2026-11-01`.

string
name

The name of the value when it travels in a form.

string
onChange ((dateTime: string | null) => void)
unavailable

Days that cannot be chosen: return true for them.

((date: string) => boolean)
value

The moment, as `2026-11-17T14:30`, or null while it is empty.

string | null
  1. Un momento
  2. Estados
  3. Cuándo usarlo
  4. Para todos
  5. Props

    Busca páginas, secciones y términos