# TimeField

> A segmented time input with hour, minute, optional second and day period segments, the locale's or an explicit hour cycle, bounds and disabled times; values are PlainTime.

Canonical: https://salmonui.dev/docs/calendars/time-field

`TimeField` is the time counterpart of [DateField](https://salmonui.dev/docs/calendars/date-field),
exported from `@salmonui/calendars/time-picker`. It has the same keyboard,
paste, partial-value, `strict`, field shell and form behavior; the
[TimePicker](https://salmonui.dev/docs/calendars/time-picker) in the same subpath adds a list
popup to it.

```tsx
import { TimeField } from '@salmonui/calendars/time-picker';
import '@salmonui/calendars/time-picker/styles.css';

<TimeField label="Start" locale="en-US" defaultValue="14:30" onValueChange={(time) => console.log(String(time))} />;
```

### Live demo: Segmented time fields

Live demo: https://salmonui.dev/demos/calendars/time-field

TimeField on the locale's 12-hour or 24-hour clock, an hourCycle override with seconds, and min, max and isTimeDisabled marking invalid times.

`Demo.tsx`:

```tsx
'use client';

import { useState } from 'react';
import { TimeField, type PlainTime } from '@salmonui/calendars/time-picker';

/** Time fields on a 12-hour and a 24-hour clock, with seconds, bounds and disabled times. */
export default function TimeFieldDemo() {
  const [time, setTime] = useState<PlainTime | null>(null);
  return (
    <div style={{ display: 'flex', flexWrap: 'wrap', gap: 24, alignItems: 'flex-start' }}>
      <TimeField label="Start (12-hour)" locale="en-US" defaultValue="14:30" onValueChange={setTime} />
      <TimeField label="Beginn (24-hour)" locale="de-DE" defaultValue="14:30" />
      <TimeField label="Lap time" locale="en-GB" granularity="second" hourCycle="h23" defaultValue="00:04:05" />
      <TimeField
        label="Office hours"
        errorMessage="Choose a time between 09:00 and 17:00, not over lunch."
        locale="en-US"
        min="09:00"
        max="17:00"
        isTimeDisabled={(t) => t.hour === 12}
        placeholderValue="09:00"
      />
      <p className="demo-status" aria-live="polite" style={{ flexBasis: '100%' }}>
        First field: <code>{time ? String(time) : '14:30:00 (default)'}</code>
      </p>
    </div>
  );
}
```

## Value

`value` / `defaultValue` take a `TimeInput` (`{ hour, minute, second? }`,
an ISO time such as `'14:30'` or `'14:30:05'`, a `Temporal.PlainTime` or a
`Date` read as wall time in `timeZone`); `onValueChange` receives a frozen
`PlainTime` whose `toString()` is `HH:mm:ss`, and `details.iso` is `HH:mm`
(or `HH:mm:ss` with seconds). A `Date` value carries a meaningless date and
shifts with the time zone, so it is accepted as input only.

## Segments

- `granularity`: `'hour'`, `'minute'` (default) or `'second'`.
- `hourCycle`: `'h12'` or `'h23'`; the default comes from the locale
  (12-hour in `en-US`, 24-hour in `de-DE`). A 12-hour clock adds the day
  period segment: type `a` / `p` (or the first letter of the locale's day
  period) or step it with Up / Down.
- `format`: `Intl` options or a pattern (`'HH:mm'`, `'hh:mm a'`).

## Bounds and disabled times

`min` and `max` (`TimeInput`) and `isTimeDisabled(time)` mark a complete
time as invalid (`aria-invalid` and `errorMessage`); with `strict` an
out-of-range time moves to the nearest bound on blur. `placeholderValue`
seeds Up / Down on empty segments.

```tsx
<TimeField min="09:00" max="17:00" isTimeDisabled={(t) => t.hour === 12} errorMessage="Office hours only" />
```

## API reference

The API reference for
[`@salmonui/calendars/time-picker`](https://salmonui.dev/docs/reference/calendars/time-picker) lists
every prop, method and type. Open state, focus, forms and events shared by
the pickers are in [Picker behavior and
forms](https://salmonui.dev/docs/calendars/picker-behavior); server rendering, accessibility
coverage and budgets in [SSR, accessibility and
performance](https://salmonui.dev/docs/calendars/platform).
