navius

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: 09:30

Features

  • Shares the segment engine of Date Input: each unit is a role="spinbutton", edited from the keyboard.
  • HourCycle picks 12 or 24 (defaults from the culture); the day-period segment toggles on arrows and on the a / p keys.
  • Granularity adds or drops the seconds column; MinuteStep / SecondStep size the arrow step.
  • Owns a TimeOnly?. Controlled via @bind-Value, uncontrolled via DefaultValue; a hidden input submits ISO HH:mm[:ss] under Name.

Installation

Install the brain, or copy just this primitive in with the CLI.

Anatomy

A single element. The segments are rendered internally from the hour cycle and granularity.

API Reference

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 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.

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).