Active Foundation · Example
A date and a time without a zone
A date and a time without a zoneClient
Europe/Amsterdam
Value: 2026-11-02T09:00 · state: valid
Full source examples/ui/local-date-time-field.tsx
// apps/docs/examples/ui/local-date-time-field.tsx'use client';
import {useState} from 'react';
import { composePresentationContext, toIanaTimeZone, toLocalDateTimeString,} from '@workspace/active-format';import { LocalDateTimeField, type LocalDateTimeFieldState,} from '@workspace/active-ui/components/composed/local-date-time-field';import { Field, FieldDescription, FieldError, FieldLabel,} from '@workspace/active-ui/components/primitives/field';
const TODAY = '2026-10-20';const TOMORROW = toLocalDateTimeString('2026-10-21T00:00');const PRESENTATION = composePresentationContext( 'en', {}, toIanaTimeZone('Europe/Amsterdam'),);
/** * A date and a time together, as a wall-clock value without a zone * (`YYYY-MM-DDTHH:mm`). The zone it is read in is shown beside it; turning * it into a moment is the application's work. A date without a time is * incomplete and never travels out as a value. */export default function LocalDateTimeFieldExample() { const [value, setValue] = useState('2026-11-02T09:00'); const [state, setState] = useState<LocalDateTimeFieldState>({ status: 'valid', }); const invalid = state.status === 'invalid'; return ( <Field className="w-full max-w-sm" data-invalid={invalid || undefined}> <FieldLabel id="send-label" htmlFor="send-at"> Send the statements at </FieldLabel> <LocalDateTimeField id="send-at" aria-labelledby="send-label" aria-describedby="send-at-state" value={value} onValueChange={setValue} onStateChange={setState} locale={PRESENTATION} today={TODAY} min={TOMORROW} step={{unit: 'minute', value: 15}} openCalendarLabel="Choose a date" dateLabel="Date" timeLabel="Time" timeZoneLabel="Europe/Amsterdam" aria-invalid={invalid || undefined} /> {invalid ? ( <FieldError id="send-at-state"> {state.rejection === 'range' ? 'Choose a moment from tomorrow on.' : state.rejection === 'step' ? 'Choose a quarter of an hour.' : 'Write a date and a time.'} </FieldError> ) : ( <FieldDescription id="send-at-state"> Value: <code>{value || "''"}</code> · state: {state.status} </FieldDescription> )} </Field> );}