# @salmonui/calendars/date-field API reference

> 9 exported symbols of @salmonui/calendars/date-field: 2 components, 5 interfaces and 2 types.

Canonical: https://salmonui.dev/docs/reference/calendars/date-field

```ts
import { … } from '@salmonui/calendars/date-field';
```

## Components

### DateField

Kind: component

Page: https://salmonui.dev/docs/reference/calendars/date-field/DateField

```ts
function DateField(props: DateFieldProps): import("react").JSX.Element;
```

A segmented date (or date-time) input: one spinbutton per segment, in the locale's order.

### TimeField

Kind: component

Page: https://salmonui.dev/docs/reference/calendars/date-field/TimeField

```ts
function TimeField(props: TimeFieldProps): import("react").JSX.Element;
```

A segmented time input: one spinbutton per segment, in the locale's order and hour cycle.

Props: [`TimeFieldProps`](https://salmonui.dev/docs/reference/calendars/date-field/TimeFieldProps) (its members are the props)

## Interfaces

### DateFieldDateProps

Kind: interface

Page: https://salmonui.dev/docs/reference/calendars/date-field/DateFieldDateProps

```ts
interface DateFieldDateProps extends DateFieldShared {
    readonly granularity?: 'year' | 'month' | 'day';
    readonly value?: DateInput | null;
    readonly defaultValue?: DateInput | null;
    readonly onValueChange?: (value: PlainDate | null, details: FieldChangeDetails) => void;
    readonly isDateDisabled?: (date: PlainDate) => boolean;
}
```

A date field: `granularity` `'year' | 'month' | 'day'` (default `'day'`); values are `PlainDate`.

Members (31):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `granularity` | `readonly granularity?: 'year' \| 'month' \| 'day';` | optional |  |
| `value` | `readonly value?: DateInput \| null;` | optional |  |
| `defaultValue` | `readonly defaultValue?: DateInput \| null;` | optional |  |
| `onValueChange` | `readonly onValueChange?: (value: PlainDate \| null, details: FieldChangeDetails) => void;` | optional |  |
| `isDateDisabled` | `readonly isDateDisabled?: (date: PlainDate) => boolean;` | optional | Rejects single dates (the field becomes invalid). |
| `ref` | `ref?: Ref<HTMLDivElement>;` | optional, inherited |  |
| `size` | `size?: "lg" \| "md" \| "sm";` | optional, inherited | Control size: `'sm'` 24px, `'md'` 32px (default), `'lg'` 40px tall; `data-size` on the group. |
| `label` | `label?: ReactNode;` | optional, inherited | Visible label above the segments; also names the group. |
| `description` | `description?: ReactNode;` | optional, inherited |  |
| `errorMessage` | `errorMessage?: ReactNode;` | optional, inherited | Shown when `invalid` (or a complete value is out of range / disabled). |
| `format` | `format?: DateFormat;` | optional, inherited | Display format: `Intl` options, a CLDR skeleton (`'yMMMd'`) or a pattern (`'dd/MM/yyyy'`, `'HH:mm'`); the segments follow it. |
| `hourCycle` | `hourCycle?: HourCycle;` | optional, inherited | `'h12'` or `'h23'`; default from the locale. |
| `locale` | `locale?: string;` | optional, inherited | BCP 47 locale. Default `'en-US'`; the host locale is never read. |
| `timeZone` | `timeZone?: string;` | optional, inherited | IANA zone for `Date` and offset inputs, and `details.epochMilliseconds`. |
| `inputFormats` | `inputFormats?: readonly string[];` | optional, inherited | Extra accepted paste and typed formats (patterns); ISO is always accepted. |
| `parse` | `parse?: ParseFn;` | optional, inherited | Custom text parser, tried last. |
| `strict` | `strict?: boolean;` | optional, inherited | `false` (default): an out-of-range or disabled value is kept and the field is `aria-invalid`. `true`: on blur, incomplete or disabled input reverts to the last valid value and an out-of-range value moves to the nearest bound. |
| `disabled` | `disabled?: boolean;` | optional, inherited |  |
| `readOnly` | `readOnly?: boolean;` | optional, inherited |  |
| `required` | `required?: boolean;` | optional, inherited |  |
| `invalid` | `invalid?: boolean;` | optional, inherited |  |
| `autoFocus` | `autoFocus?: boolean;` | optional, inherited |  |
| `name` | `name?: string;` | optional, inherited | Form field name: a visually hidden input posts the ISO value. |
| `form` | `form?: string;` | optional, inherited |  |
| `onFocus` | `onFocus?: ((event: FocusEvent<HTMLDivElement, Element>) => void);` | optional, inherited | Fires once when focus enters the group. |
| `onBlur` | `onBlur?: ((event: FocusEvent<HTMLDivElement, Element>) => void);` | optional, inherited | Fires once when focus leaves the group. |
| `localeText` | `localeText?: Partial<FieldLocaleText>;` | optional, inherited |  |
| `dir` | `dir?: "ltr" \| "rtl";` | optional, inherited | Direction override; inherited from the document by default. |
| `min` | `min?: DateInput;` | optional, inherited | Earliest valid value. |
| `max` | `max?: DateInput;` | optional, inherited | Latest valid value. |
| `placeholderValue` | `placeholderValue?: DateInput;` | optional, inherited | Seeds Up / Down on empty segments (default: now, read in the event handler). |

### DateFieldDateTimeProps

Kind: interface

Page: https://salmonui.dev/docs/reference/calendars/date-field/DateFieldDateTimeProps

```ts
interface DateFieldDateTimeProps extends DateFieldShared {
    readonly granularity: 'hour' | 'minute' | 'second';
    readonly value?: DateTimeInput | null;
    readonly defaultValue?: DateTimeInput | null;
    readonly onValueChange?: (value: PlainDateTime | null, details: FieldChangeDetails) => void;
    readonly isDateDisabled?: (date: PlainDateTime) => boolean;
}
```

A date-time field: `granularity` `'hour' | 'minute' | 'second'`; values are `PlainDateTime`.

Members (31):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `ref` | `ref?: Ref<HTMLDivElement>;` | optional, inherited |  |
| `size` | `size?: "lg" \| "md" \| "sm";` | optional, inherited | Control size: `'sm'` 24px, `'md'` 32px (default), `'lg'` 40px tall; `data-size` on the group. |
| `granularity` | `readonly granularity: 'hour' \| 'minute' \| 'second';` |  |  |
| `value` | `readonly value?: DateTimeInput \| null;` | optional |  |
| `defaultValue` | `readonly defaultValue?: DateTimeInput \| null;` | optional |  |
| `onValueChange` | `readonly onValueChange?: (value: PlainDateTime \| null, details: FieldChangeDetails) => void;` | optional |  |
| `isDateDisabled` | `readonly isDateDisabled?: (date: PlainDateTime) => boolean;` | optional |  |
| `label` | `label?: ReactNode;` | optional, inherited | Visible label above the segments; also names the group. |
| `description` | `description?: ReactNode;` | optional, inherited |  |
| `errorMessage` | `errorMessage?: ReactNode;` | optional, inherited | Shown when `invalid` (or a complete value is out of range / disabled). |
| `format` | `format?: DateFormat;` | optional, inherited | Display format: `Intl` options, a CLDR skeleton (`'yMMMd'`) or a pattern (`'dd/MM/yyyy'`, `'HH:mm'`); the segments follow it. |
| `hourCycle` | `hourCycle?: HourCycle;` | optional, inherited | `'h12'` or `'h23'`; default from the locale. |
| `locale` | `locale?: string;` | optional, inherited | BCP 47 locale. Default `'en-US'`; the host locale is never read. |
| `timeZone` | `timeZone?: string;` | optional, inherited | IANA zone for `Date` and offset inputs, and `details.epochMilliseconds`. |
| `inputFormats` | `inputFormats?: readonly string[];` | optional, inherited | Extra accepted paste and typed formats (patterns); ISO is always accepted. |
| `parse` | `parse?: ParseFn;` | optional, inherited | Custom text parser, tried last. |
| `strict` | `strict?: boolean;` | optional, inherited | `false` (default): an out-of-range or disabled value is kept and the field is `aria-invalid`. `true`: on blur, incomplete or disabled input reverts to the last valid value and an out-of-range value moves to the nearest bound. |
| `disabled` | `disabled?: boolean;` | optional, inherited |  |
| `readOnly` | `readOnly?: boolean;` | optional, inherited |  |
| `required` | `required?: boolean;` | optional, inherited |  |
| `invalid` | `invalid?: boolean;` | optional, inherited |  |
| `autoFocus` | `autoFocus?: boolean;` | optional, inherited |  |
| `name` | `name?: string;` | optional, inherited | Form field name: a visually hidden input posts the ISO value. |
| `form` | `form?: string;` | optional, inherited |  |
| `onFocus` | `onFocus?: ((event: FocusEvent<HTMLDivElement, Element>) => void);` | optional, inherited | Fires once when focus enters the group. |
| `onBlur` | `onBlur?: ((event: FocusEvent<HTMLDivElement, Element>) => void);` | optional, inherited | Fires once when focus leaves the group. |
| `localeText` | `localeText?: Partial<FieldLocaleText>;` | optional, inherited |  |
| `dir` | `dir?: "ltr" \| "rtl";` | optional, inherited | Direction override; inherited from the document by default. |
| `min` | `min?: DateInput;` | optional, inherited | Earliest valid value. |
| `max` | `max?: DateInput;` | optional, inherited | Latest valid value. |
| `placeholderValue` | `placeholderValue?: DateInput;` | optional, inherited | Seeds Up / Down on empty segments (default: now, read in the event handler). |

### FieldBaseProps

Kind: interface

Page: https://salmonui.dev/docs/reference/calendars/date-field/FieldBaseProps

```ts
interface FieldBaseProps extends GroupProps {
    readonly ref?: Ref<HTMLDivElement>;
    readonly size?: 'sm' | 'md' | 'lg' | undefined;
    readonly label?: ReactNode;
    readonly description?: ReactNode;
    readonly errorMessage?: ReactNode;
    readonly format?: DateFormat;
    readonly hourCycle?: HourCycle;
    readonly locale?: string;
    readonly timeZone?: string;
    readonly inputFormats?: readonly string[];
    readonly parse?: ParseFn;
    readonly strict?: boolean;
    readonly disabled?: boolean;
    readonly readOnly?: boolean;
    readonly required?: boolean;
    readonly invalid?: boolean;
    readonly autoFocus?: boolean;
    readonly name?: string;
    readonly form?: string;
    readonly onFocus?: (event: FocusEvent<HTMLDivElement>) => void;
    readonly onBlur?: (event: FocusEvent<HTMLDivElement>) => void;
    readonly localeText?: Partial<FieldLocaleText>;
    readonly dir?: 'ltr' | 'rtl';
}
```

Props shared by `DateField` and `TimeField`.

Members (23):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `ref` | `readonly ref?: Ref<HTMLDivElement>;` | optional |  |
| `size` | `readonly size?: 'sm' \| 'md' \| 'lg' \| undefined;` | optional | Control size: `'sm'` 24px, `'md'` 32px (default), `'lg'` 40px tall; `data-size` on the group. |
| `label` | `readonly label?: ReactNode;` | optional | Visible label above the segments; also names the group. |
| `description` | `readonly description?: ReactNode;` | optional |  |
| `errorMessage` | `readonly errorMessage?: ReactNode;` | optional | Shown when `invalid` (or a complete value is out of range / disabled). |
| `format` | `readonly format?: DateFormat;` | optional | Display format: `Intl` options, a CLDR skeleton (`'yMMMd'`) or a pattern (`'dd/MM/yyyy'`, `'HH:mm'`); the segments follow it. |
| `hourCycle` | `readonly hourCycle?: HourCycle;` | optional | `'h12'` or `'h23'`; default from the locale. |
| `locale` | `readonly locale?: string;` | optional | BCP 47 locale. Default `'en-US'`; the host locale is never read. |
| `timeZone` | `readonly timeZone?: string;` | optional | IANA zone for `Date` and offset inputs, and `details.epochMilliseconds`. |
| `inputFormats` | `readonly inputFormats?: readonly string[];` | optional | Extra accepted paste and typed formats (patterns); ISO is always accepted. |
| `parse` | `readonly parse?: ParseFn;` | optional | Custom text parser, tried last. |
| `strict` | `readonly strict?: boolean;` | optional | `false` (default): an out-of-range or disabled value is kept and the field is `aria-invalid`. `true`: on blur, incomplete or disabled input reverts to the last valid value and an out-of-range value moves to the nearest bound. |
| `disabled` | `readonly disabled?: boolean;` | optional |  |
| `readOnly` | `readonly readOnly?: boolean;` | optional |  |
| `required` | `readonly required?: boolean;` | optional |  |
| `invalid` | `readonly invalid?: boolean;` | optional |  |
| `autoFocus` | `readonly autoFocus?: boolean;` | optional |  |
| `name` | `readonly name?: string;` | optional | Form field name: a visually hidden input posts the ISO value. |
| `form` | `readonly form?: string;` | optional |  |
| `onFocus` | `readonly onFocus?: (event: FocusEvent<HTMLDivElement>) => void;` | optional | Fires once when focus enters the group. |
| `onBlur` | `readonly onBlur?: (event: FocusEvent<HTMLDivElement>) => void;` | optional | Fires once when focus leaves the group. |
| `localeText` | `readonly localeText?: Partial<FieldLocaleText>;` | optional |  |
| `dir` | `readonly dir?: 'ltr' \| 'rtl';` | optional | Direction override; inherited from the document by default. |

### FieldChangeDetails

Kind: interface

Page: https://salmonui.dev/docs/reference/calendars/date-field/FieldChangeDetails

```ts
interface FieldChangeDetails {
    readonly source: 'keyboard' | 'pointer' | 'api';
    readonly reason: 'input' | 'paste' | 'clear' | 'blur';
    readonly iso: string;
    readonly epochMilliseconds?: number;
}
```

Second argument of `onValueChange` on the segmented fields.

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `source` | `readonly source: 'keyboard' \| 'pointer' \| 'api';` |  |  |
| `reason` | `readonly reason: 'input' \| 'paste' \| 'clear' \| 'blur';` |  |  |
| `iso` | `readonly iso: string;` |  | ISO form value (`YYYY-MM-DD`, `YYYY-MM`, `YYYY`, `YYYY-MM-DDTHH:mm[:ss]`, `HH:mm[:ss]`); `''` when empty. |
| `epochMilliseconds` | `readonly epochMilliseconds?: number;` | optional | The instant of a date-time value when `timeZone` is given. |

### TimeFieldProps

Kind: interface

Page: https://salmonui.dev/docs/reference/calendars/date-field/TimeFieldProps

```ts
interface TimeFieldProps extends FieldBaseProps {
    readonly granularity?: 'hour' | 'minute' | 'second';
    readonly value?: TimeInput | null;
    readonly defaultValue?: TimeInput | null;
    readonly onValueChange?: (value: PlainTime | null, details: FieldChangeDetails) => void;
    readonly min?: TimeInput;
    readonly max?: TimeInput;
    readonly placeholderValue?: TimeInput;
    readonly isTimeDisabled?: (time: PlainTime) => boolean;
}
```

Members (31):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `granularity` | `readonly granularity?: 'hour' \| 'minute' \| 'second';` | optional | Deepest segment. Default `'minute'`. |
| `value` | `readonly value?: TimeInput \| null;` | optional |  |
| `defaultValue` | `readonly defaultValue?: TimeInput \| null;` | optional |  |
| `onValueChange` | `readonly onValueChange?: (value: PlainTime \| null, details: FieldChangeDetails) => void;` | optional |  |
| `min` | `readonly min?: TimeInput;` | optional |  |
| `max` | `readonly max?: TimeInput;` | optional |  |
| `placeholderValue` | `readonly placeholderValue?: TimeInput;` | optional | Seeds Up / Down on empty segments (default: now, read in the event handler). |
| `isTimeDisabled` | `readonly isTimeDisabled?: (time: PlainTime) => boolean;` | optional | Rejects single times (the field becomes invalid). |
| `ref` | `ref?: Ref<HTMLDivElement>;` | optional, inherited |  |
| `size` | `size?: "lg" \| "md" \| "sm";` | optional, inherited | Control size: `'sm'` 24px, `'md'` 32px (default), `'lg'` 40px tall; `data-size` on the group. |
| `label` | `label?: ReactNode;` | optional, inherited | Visible label above the segments; also names the group. |
| `description` | `description?: ReactNode;` | optional, inherited |  |
| `errorMessage` | `errorMessage?: ReactNode;` | optional, inherited | Shown when `invalid` (or a complete value is out of range / disabled). |
| `format` | `format?: DateFormat;` | optional, inherited | Display format: `Intl` options, a CLDR skeleton (`'yMMMd'`) or a pattern (`'dd/MM/yyyy'`, `'HH:mm'`); the segments follow it. |
| `hourCycle` | `hourCycle?: HourCycle;` | optional, inherited | `'h12'` or `'h23'`; default from the locale. |
| `locale` | `locale?: string;` | optional, inherited | BCP 47 locale. Default `'en-US'`; the host locale is never read. |
| `timeZone` | `timeZone?: string;` | optional, inherited | IANA zone for `Date` and offset inputs, and `details.epochMilliseconds`. |
| `inputFormats` | `inputFormats?: readonly string[];` | optional, inherited | Extra accepted paste and typed formats (patterns); ISO is always accepted. |
| `parse` | `parse?: ParseFn;` | optional, inherited | Custom text parser, tried last. |
| `strict` | `strict?: boolean;` | optional, inherited | `false` (default): an out-of-range or disabled value is kept and the field is `aria-invalid`. `true`: on blur, incomplete or disabled input reverts to the last valid value and an out-of-range value moves to the nearest bound. |
| `disabled` | `disabled?: boolean;` | optional, inherited |  |
| `readOnly` | `readOnly?: boolean;` | optional, inherited |  |
| `required` | `required?: boolean;` | optional, inherited |  |
| `invalid` | `invalid?: boolean;` | optional, inherited |  |
| `autoFocus` | `autoFocus?: boolean;` | optional, inherited |  |
| `name` | `name?: string;` | optional, inherited | Form field name: a visually hidden input posts the ISO value. |
| `form` | `form?: string;` | optional, inherited |  |
| `onFocus` | `onFocus?: ((event: FocusEvent<HTMLDivElement, Element>) => void);` | optional, inherited | Fires once when focus enters the group. |
| `onBlur` | `onBlur?: ((event: FocusEvent<HTMLDivElement, Element>) => void);` | optional, inherited | Fires once when focus leaves the group. |
| `localeText` | `localeText?: Partial<FieldLocaleText>;` | optional, inherited |  |
| `dir` | `dir?: "ltr" \| "rtl";` | optional, inherited | Direction override; inherited from the document by default. |

## Types

### DateFieldProps

Kind: type

Page: https://salmonui.dev/docs/reference/calendars/date-field/DateFieldProps

```ts
type DateFieldProps = DateFieldDateProps | DateFieldDateTimeProps;
```

### FieldLocaleText

Kind: type

Page: https://salmonui.dev/docs/reference/calendars/date-field/FieldLocaleText

```ts
type FieldLocaleText = {
    readonly [K in `${SegmentType}Placeholder` | `${SegmentType}Label`]: LocaleMessage;
} & {
    readonly empty: LocaleMessage;
};
```

User-visible strings of `DateField` and `TimeField`: segment placeholders and names.

Members (15):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `dayLabel` | `dayLabel: LocaleMessage;` | inherited |  |
| `dayPeriodLabel` | `dayPeriodLabel: LocaleMessage;` | inherited |  |
| `dayPeriodPlaceholder` | `dayPeriodPlaceholder: LocaleMessage;` | inherited |  |
| `dayPlaceholder` | `dayPlaceholder: LocaleMessage;` | inherited |  |
| `hourLabel` | `hourLabel: LocaleMessage;` | inherited |  |
| `hourPlaceholder` | `hourPlaceholder: LocaleMessage;` | inherited |  |
| `minuteLabel` | `minuteLabel: LocaleMessage;` | inherited |  |
| `minutePlaceholder` | `minutePlaceholder: LocaleMessage;` | inherited |  |
| `monthLabel` | `monthLabel: LocaleMessage;` | inherited |  |
| `monthPlaceholder` | `monthPlaceholder: LocaleMessage;` | inherited |  |
| `secondLabel` | `secondLabel: LocaleMessage;` | inherited |  |
| `secondPlaceholder` | `secondPlaceholder: LocaleMessage;` | inherited |  |
| `yearLabel` | `yearLabel: LocaleMessage;` | inherited |  |
| `yearPlaceholder` | `yearPlaceholder: LocaleMessage;` | inherited |  |
| `empty` | `empty: LocaleMessage;` | inherited | `aria-valuetext` of an empty segment. |
