# Time field

> Clock entry in the UI's locale, for the hours that are not attached to a day. A native time input is drawn in the BROWSER's language, so a German page in an English-US Chrome asks for AM/PM.

- Group: Forms
- Status: stable
- Aliases: timepicker, time-picker, clock, hours
- HTML page: https://design.ipmnx.com/components/time-field/
- Spec: https://design.ipmnx.com/design/#nx-time-field

## Preview

**Opening time** Reads and writes HH:mm; the locale decides whether that is 14:30 or 2:30 PM.

```html
<div class="nx-field nx-timefield">
  <label class="nx-field__label" for="open1">Öffnet</label>
  <input id="open1" class="nx-field__input nx-timefield__input"
      value="09:00" inputmode="numeric" placeholder="09:00">
</div>
```

```tsx
<NxTimeField
  label="Öffnet"
  value={from}
  onChange={setFrom}
  locale="de-DE"
  name="heureOuverture"
/>
```

## Variants

### A pair, in a row

Two of them are an opening and a closing; keep them in one row and let the field be as wide as a time.

```html
<div style="display:flex;gap:16px">
  <div class="nx-field nx-timefield">
    <label class="nx-field__label" for="open2">Öffnet</label>
    <input id="open2" class="nx-field__input nx-timefield__input"
        value="09:00" inputmode="numeric">
  </div>
  <div class="nx-field nx-timefield">
    <label class="nx-field__label" for="close2">Schließt</label>
    <input id="close2" class="nx-field__input nx-timefield__input"
        value="20:00" inputmode="numeric">
  </div>
</div>
```

```tsx
<>
  <NxTimeField label="Öffnet" value={from} onChange={setFrom} />
  <NxTimeField label="Schließt" value={to} onChange={setTo} />
</>
```

## API

### React props (NxKit)

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `label` | `string` | `—` | yes | Visible label, tied to the input. |
| `value` | `string` | `—` | yes | "" or "HH:mm" — what a native time input would have submitted. |
| `onChange` | `(value: string) => void` | `—` | yes | Called with HH:mm, or "" when cleared — never with a half-typed time. |
| `locale` | `string` | `runtime default` |   | BCP-47 tag of the UI. de reads 14:30 where en-US reads 2:30 PM. |
| `name` | `string` | `undefined` |   | Emits a hidden input, so the field works in a plain FormData submit. |
| `required` | `boolean` | `false` |   | Lands on the visible input. Still validate on the server. |
| `hideLabel` | `boolean` | `false` |   | Keeps the label for screen readers and takes it off the screen. |
| `disabled` | `boolean` | `false` |   | Disables the input. |
| `hint` | `React.ReactNode` | `undefined` |   | Help text under the control. |
| `error` | `React.ReactNode` | `undefined` |   | Error text; also sets aria-invalid. |

### Classes

| Class | Description |
| --- | --- |
| `.nx-timefield` | Wrapper, used with .nx-field |
| `.nx-timefield__input` | The input, as wide as a time and tabular-nums |

## States

### error

```html
<div class="nx-field nx-timefield"><label class="nx-field__label" for="open3">Öffnet</label><input id="open3" class="nx-field__input nx-timefield__input" value="25:00" aria-invalid="true"><span class="nx-field__error"><span aria-hidden="true">✕</span> Diese Uhrzeit gibt es nicht.</span></div>
```

### disabled

```html
<div class="nx-field nx-timefield"><label class="nx-field__label" for="open4">Öffnet</label><input id="open4" class="nx-field__input nx-timefield__input" value="09:00" disabled></div>
```

## Accessibility

- The label is a real `<label>` tied by htmlFor; hideLabel moves it off screen with .nx-sr-only rather than removing it.
- Typing is never corrected mid-keystroke: the box that has focus is left alone until blur.

## Do / Don't

- Do: Use it for an hour with no day — opening times, a send time, a shift.
- Don't pair it with a separate date field; NxDateField withTime keeps the two halves one value.
- Do: Let it keep its width: a time is eight characters.
- Don't stretch it across the form; it reads as a text field then.

## Related

- [Date field](https://design.ipmnx.com/components/date-field.md)
- [Field](https://design.ipmnx.com/components/field.md)

---

Source: registry.js (NX Design System)
