Date Input
A segmented date editor: culture-ordered spinbutton fields for day, month and year, edited entirely from the keyboard, with no popup calendar.
Value:
<NaviusDateInput @bind-Value="_date" Granularity="day"
class="inline-flex items-center rounded-md border px-3 py-2
[&_[data-segment]:focus]:bg-primary
[&_[data-segment]:focus]:text-primary-foreground
[&_[data-placeholder]]:text-muted-foreground" />
@code { private DateOnly? _date = new(2026, 7, 4); }Features
- Each unit is an APG
role="spinbutton"segment; segment order and separators follow the culture's short-date pattern (Culture). - Arrows step (and wrap), digits type and auto-advance to the next segment, Backspace clears; all value logic runs in C#, no popup.
- Owns a
DateOnly?. Controlled via@bind-Value, uncontrolled viaDefaultValue. -
Granularitytrims to day / month / year;MinValue/MaxValuesurface asdata-invalidwithout snapping the value. - Field-aware: adopts a
NaviusField's control id and reports filled / dirty / touched / valid. A hidden input submits ISOyyyy-MM-ddunderName.
Installation
Install the brain, or copy just this primitive in with the CLI.
navius add date-inputAnatomy
A single element. The segments are rendered internally from the culture and granularity.
@using Navius.Primitives.Components.DateInput
<NaviusDateInput @bind-Value="_date" />API Reference
NaviusDateInput
The segmented date 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 | DateOnly? | - |
| ValueChanged | EventCallback<DateOnly?> | - |
| DefaultValue | DateOnly? | - |
| Granularity | string | "day" |
| MinValue | DateOnly? | - |
| MaxValue | DateOnly? | - |
| PlaceholderValue | DateOnly? | today |
| 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-date-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-date-input-segment, data-segment ("year" | "month" | "day") and data-placeholder while empty; the separators carry data-segment="literal". Style off these hooks.
Accessibility
Each segment is an APG spinbutton with aria-valuenow / aria-valuemin / aria-valuemax / aria-valuetext; the group carries aria-invalid and, under a Field, aria-describedby. Left / Right navigation mirrors under rtl.
Keyboard interactions
| Key | Description |
|---|---|
| Arrow Up / Arrow Down | Steps the focused segment by one (wrapping at the segment's min/max). |
| Page Up / Page Down | Steps by a larger amount (5 years, 3 months, 7 days). |
| Home / End | Jumps the focused segment to its minimum / maximum. |
| 0-9 | Types into the focused segment and auto-advances once it can hold no more digits. |
| Backspace / Delete | Clears the focused segment. |
| Arrow Left / Arrow Right | Moves between segments (mirrored under rtl). |