Time Input
A segmented time editor: spinbutton fields for hours, minutes and optional seconds, with 12- or 24-hour modes and a day-period toggle.
Value:
<NaviusTimeInput @bind-Value="_time" HourCycle="12"
class="inline-flex items-center rounded-md border px-3 py-2
[&_[data-segment]:focus]:bg-primary
[&_[data-segment]:focus]:text-primary-foreground" />
@code { private TimeOnly? _time = new(9, 30); }Features
- Shares the segment engine of Date Input: each unit is a
role="spinbutton", edited from the keyboard. -
HourCyclepicks 12 or 24 (defaults from the culture); the day-period segment toggles on arrows and on thea/pkeys. -
Granularityadds or drops the seconds column;MinuteStep/SecondStepsize the arrow step. - Owns a
TimeOnly?. Controlled via@bind-Value, uncontrolled viaDefaultValue; a hidden input submits ISOHH:mm[:ss]underName.
Installation
Install the brain, or copy just this primitive in with the CLI.
navius add time-inputAnatomy
A single element. The segments are rendered internally from the hour cycle and granularity.
@using Navius.Primitives.Components.TimeInput
<NaviusTimeInput @bind-Value="_time" Granularity="minute" />API Reference
NaviusTimeInput
The segmented time field. Renders a div with role=group holding the auto-generated segments and a hidden bubble input. Value is two-way bindable.
| Prop | Type | Default |
|---|---|---|
| Value | TimeOnly? | - |
| ValueChanged | EventCallback<TimeOnly?> | - |
| DefaultValue | TimeOnly? | - |
| Granularity | string | "minute" |
| HourCycle | int? | culture |
| MinuteStep | int | 1 |
| SecondStep | int | 1 |
| MinValue | TimeOnly? | - |
| MaxValue | TimeOnly? | - |
| PlaceholderValue | TimeOnly? | now |
| Disabled | bool | false |
| ReadOnly | bool | false |
| Required | bool | false |
| Invalid | bool | false |
| ForceLeadingZeros | bool | false |
| Culture | CultureInfo? | current |
| Dir | string? | - |
| Name | string? | - |
| ChildContent | RenderFragment? | - |
| …attributes | IDictionary<string, object>? | - |
Data attributes
| Data attribute | Values |
|---|---|
| [data-navius-time-input] | Present on the group |
| [data-disabled] | Present when disabled |
| [data-readonly] | Present when read-only |
| [data-invalid] | Present when invalid or out of range |
| [data-filled] | Present when any segment holds a value |
| [data-dirty] | Present after the first edit |
| [data-focused] | Present while a segment has focus |
| [data-touched] | Present after focus has left the group |
Each editable segment renders a <span role="spinbutton"> carrying data-navius-time-input-segment, data-segment ("hour" | "minute" | "second" | "dayPeriod") and data-placeholder while empty; the separators carry data-segment="literal".
Accessibility
Each segment is an APG spinbutton. The day-period segment exposes aria-valuetext (AM / PM) rather than a numeric range. The group carries aria-invalid and, under a Field, aria-describedby.
Keyboard interactions
| Key | Description |
|---|---|
| Arrow Up / Arrow Down | Steps the focused segment (wrapping); toggles AM/PM on the day-period segment. |
| Page Up / Page Down | Steps by a larger amount (2 hours, 15 minutes / seconds). |
| Home / End | Jumps the focused numeric segment to its minimum / maximum. |
| a / p | On the day-period segment, sets AM / PM directly. |
| 0-9 | Types into the focused segment and auto-advances when full. |
| Backspace / Delete | Clears the focused segment. |
| Arrow Left / Arrow Right | Moves between segments (mirrored under rtl). |