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.
Preview
Opening time Reads and writes HH:mm; the locale decides whether that is 14:30 or 2:30 PM.
<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><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.
<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><>
<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 | — | Required | Visible label, tied to the input. |
value | string | — | Required | "" or "HH:mm" — what a native time input would have submitted. |
onChange | (value: string) | — | Required | 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
Diese Uhrzeit gibt es nicht.
disabled
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.