Skip to content
  • System
  • Light
  • Dark
  • High contrast

DateInput

Use DateInput when the user already knows the date they need to enter — date of birth, start of an audit period, invoice date, reporting deadline.

Controlled usage with value and onChange.

import { useState } from 'react';
import { DateInput } from '@eekodigital/raster';
import type { DateValue } from '@eekodigital/raster';

function DateInputDemo() {
  const [value, setValue] = useState<DateValue>({ day: '', month: '', year: '' });
  return <DateInput label="Date of birth" value={value} onChange={setValue} />;
}

Use hint to provide an example date format.

For example, 27 3 2025Error: Enter a valid date
<DateInput
  label="Date of audit"
  hint="For example, 27 3 2025"
  value={value}
  onChange={setValue}
/>

Pass an error string to show a validation message and highlight the fields.

For example, 27 3 2025Error: Enter a valid date
<DateInput
  label="Date of audit"
  hint="For example, 27 3 2025"
  error="Enter a valid date"
  defaultValue={{ day: '32', month: '13', year: '2025' }}
/>
<DateInput
  label="Date of birth"
  defaultValue={{ day: '12', month: '3', year: '1985' }}
  disabled
/>
PropTypeDefaultDescription
labelstringVisible label above the fields.
hintstringOptional hint text shown below the label.
errorstringValidation error message. Highlights the fields when present.
namestring

Base name used to derive field names (e.g. dob-day, dob-month, dob-year).

valueDateValue

Controlled value object with day, month, and year string fields.

defaultValueDateValueUncontrolled initial value.
onChange(value: DateValue) => voidCallback fired when any field changes.
disabledbooleanfalseDisables all three input fields.