DwsTimeRangePicker
API ReferenceField labels, placeholders and tooltips
Each field has its own label, placeholder (shown while the field is empty and focused) and tooltip; TooltipPosition sets where the tooltips appear.
Show Code
TimeRangePicker.razor
<DwsTimeRangePicker Name="TimeRangePickerDemo_FieldTextsPicker" Label="Shop hours"
StartLabel="Opens" EndLabel="Closes"
StartPlaceholder="e.g. 09:00" EndPlaceholder="e.g. 18:00"
TooltipPosition="DwsTooltipPosition.Bottom" StartTooltip="When the doors open" EndTooltip="When the doors close"
@bind-StartTime="@_fieldTextStart" @bind-EndTime="@_fieldTextEnd" />TimeRangePicker.razor.cs
private TimeOnly? _fieldTextStart;
private TimeOnly? _fieldTextEnd;Default to the current time
DefaultToCurrentTime fills an empty picker with the current time, rounded up to Step, and a range of DefaultDuration (cut at MaxTime or midnight), and reports both through the changed callbacks. On Blazor Server 'now' is the server clock; pass CurrentTimeProvider for the user's time.
Show Code
TimeRangePicker.razor
<DwsTimeRangePicker Name="TimeRangePickerDemo_DefaultNow" Label="Starts now, 30 minutes" DefaultToCurrentTime="true" DefaultDuration="@_halfHour" Step="@_quarterHour"
@bind-StartTime="@_nowStart" @bind-EndTime="@_nowEnd" />TimeRangePicker.razor.cs
private readonly TimeSpan _quarterHour = TimeSpan.FromMinutes(15);
private readonly TimeSpan _halfHour = TimeSpan.FromMinutes(30);
private TimeOnly? _nowStart;
private TimeOnly? _nowEnd;Fallbacks for invalid parameters
Invalid parameters fall back and are logged once: MinTime after MaxTime ignores both, an invalid Step uses one minute, an unusable Format uses the culture's short time.
Show Code
TimeRangePicker.razor
<DwsTimeRangePicker Name="TimeRangePickerDemo_Fallbacks" Label="MinTime after MaxTime, Step 0, Format “yyyy” - all fall back"
MinTime="@_officeCloses" MaxTime="@_officeOpens" Step="@TimeSpan.Zero" Format="yyyy"
@bind-StartTime="@_fallbackStart" @bind-EndTime="@_fallbackEnd" />TimeRangePicker.razor.cs
private readonly TimeOnly _officeOpens = new(8, 0);
private readonly TimeOnly _officeCloses = new(18, 0);
private TimeOnly? _fallbackStart = new(3, 0);
private TimeOnly? _fallbackEnd = new(4, 0);Disabled and read-only
Disabled turns off both fields and every preset; Readonly shows the times but ignores input while the fields stay focusable. Permissions work as for every library component: in the permission selection mode a click on the picker selects it instead of editing it.
Show Code
TimeRangePicker.razor
<DwsTimeRangePicker Name="TimeRangePickerDemo_Disabled" Label="Disabled" Disabled="true" ShowDefaultPresets="true" StartTime="@_fixedStart" EndTime="@_fixedEnd" />
<DwsTimeRangePicker Name="TimeRangePickerDemo_Readonly" Label="Read-only" Readonly="true" StartTime="@_fixedStart" EndTime="@_fixedEnd" />TimeRangePicker.razor.cs
private readonly TimeOnly _fixedStart = new(8, 0);
private readonly TimeOnly _fixedEnd = new(12, 0);Interface-Description
| Name | Typ | Default | Description |
|---|---|---|---|
| ValidationError | DwsTimeRangeValidationError | None | Why the current range is invalid: InvalidInput, OutOfRange, Unavailable, EndBeforeStart or Required (the first that applies). |
| IsValid | bool | true | True when ValidationError is None. |
| ValidationMessage | string? | null | The message for ValidationError in the current language. |
| CurrentRange | DwsTimeRange? | null | The current range when both times are set (it may be invalid). CrossesMidnight tells a range into the next day; Duration counts over midnight. |
| Name | Typ | Parameters | Description |
|---|---|---|---|
| SetRangeAsync | Task | Sets both times as a user change would (changed callbacks, validation, OnRangeSelected / OnRangeCleared); works on a read-only picker too. AutoCorrect does not apply. | |
| ClearAsync | Task | Empties both times and raises the changed callbacks and OnRangeCleared. | |
| FocusStartAsync | Task | Moves keyboard focus to the start field (as the inherited FocusAsync does). | |
| FocusEndAsync | Task | Moves keyboard focus to the end field. |
| Name | Typ | Default | Description |
|---|---|---|---|
| StartTime | TimeOnly? | null | Start of the range, two-way bindable via @bind-StartTime. A value from the parent is validated but never changed, and does not raise StartTimeChanged. |
| StartTimeExpression | Expression<Func<TimeOnly?>>? | null | Identifies the bound start value for an EditForm; @bind-StartTime sets it. Without it the picker's messages go under a field of its own, which still blocks the form and shows in a ValidationSummary. |
| EndTime | TimeOnly? | null | End of the range, two-way bindable via @bind-EndTime. With AllowOvernight an end before the start is the next day. |
| EndTimeExpression | Expression<Func<TimeOnly?>>? | null | Identifies the bound end value for an EditForm; @bind-EndTime sets it. |
| DefaultToCurrentTime | bool | false | With neither time given on the first render, starts at the current time rounded up to Step (within MinTime / MaxTime), ends DefaultDuration later (cut at MaxTime or midnight) and reports both through the changed callbacks. |
| DefaultDuration | TimeSpan | 1 hour | Length of the range DefaultToCurrentTime creates: cut at MaxTime or midnight, or with AllowOvernight into the next day (within the window). Negative or a day or longer falls back to one hour (logged once). |
| CurrentTimeProvider | Func<TimeOnly>? | null | Returns 'now' for DefaultToCurrentTime and for arrow keys in an empty text field. Unset uses DateTime.Now - on Blazor Server the server clock. |
| MinTime | TimeOnly? | null | Earliest selectable time; a time before it is reported. After MaxTime it opens a window over midnight (20:00 - 08:00) with AllowOvernight; without it both limits are ignored (logged once). |
| MaxTime | TimeOnly? | null | Latest selectable time; a time after it is reported. The whole range must lie within MinTime / MaxTime, also over midnight. |
| Step | TimeSpan | 1 minute | Granularity of the fields' dialog lists, of the arrow keys and of DefaultToCurrentTime. Not a whole number of minutes also shows seconds. Falls back to one minute (logged once) when not a positive whole number of seconds below a day. |
| DisabledTimes | IReadOnlyList<DwsTimeRange>? | null | Unavailable slots, e.g. a lunch break. Neither time may lie inside one (the end of a slot is exclusive); entries without length are ignored (logged once). |
| AllowRangeOverDisabledTimes | bool | false | Allows a range that covers a disabled slot as a whole. |
| AllowEqualTimes | bool | true | Allows the end time to equal the start time. |
| AllowOvernight | bool | false | Allows ranges over midnight: an end before the start is the next day (a night shift 22:00 - 06:00, marked below the fields), and MinTime after MaxTime is a window over midnight. Disabled times, presets, duration and AutoCorrect count across midnight. |
| Required | bool | false | Both times must be set; a missing one is reported once the user has edited the range or a surrounding EditForm is submitted. |
| AutoCorrect | bool | false | Keeps the range ordered: a start moved past the end pushes the end along (keeping the length where it fits), an end moved before the start pulls the start back. With AllowOvernight every order is valid, so it only separates equal times when AllowEqualTimes is off. |
| Readonly | bool | false | Shows the times but ignores user input; the fields stay focusable. |
| ShowValidationMessage | bool | true | Shows the validation message below the fields, together with other validators' messages for the bound values inside an EditForm. The fields are marked invalid (aria-invalid) either way. |
| RequiredMessage | string? | null | Replaces the message for a missing time. |
| EndBeforeStartMessage | string? | null | Replaces the message for an end before the start (or equal to it when not allowed). {0} = start time, {1} = end time. |
| OutOfRangeMessage | string? | null | Replaces the message for a time - or, over midnight, a part of the range - outside MinTime / MaxTime. {0} = earliest, {1} = latest time (empty when unset). |
| DisabledTimeMessage | string? | null | Replaces the message for a range touching a disabled slot. {0} = the slot, e.g. "Lunch break (12:00 - 13:00)". |
| InvalidInputMessage | string? | null | Replaces the message for unreadable text. {0} = an example time in the format. |
| Presets | IReadOnlyList<DwsTimeRange>? | null | Quick-select buttons that set both times; Label is the caption. An invalid preset is shown disabled. Replaces ShowDefaultPresets. |
| ShowDefaultPresets | bool | false | Shows localized presets for morning (08-12), afternoon (13-17), evening (17-21) and working day (08-17) when Presets is not set. |
| Label | string | "" | Caption above the fields; also names the group for assistive technology. |
| StartLabel | string | "" | Label of the start field. Empty uses the localized "Start time". |
| EndLabel | string | "" | Label of the end field. Empty uses the localized "End time". |
| StartPlaceholder | string | "" | Placeholder of the start field (empty shows the format). |
| EndPlaceholder | string | "" | Placeholder of the end field (empty shows the format). |
| StartTooltip | string | "" | Tooltip of the start field, shown on hover (DwsTooltip); the text also describes the field for screen readers. |
| EndTooltip | string | "" | Tooltip of the end field, shown on hover (DwsTooltip); the text also describes the field for screen readers. |
| TooltipPosition | DwsTooltipPosition | DwsTooltipPosition.Top | Where the field tooltips appear. |
| ShowDuration | bool | false | Shows the length of a valid range below the fields. |
| AllowClear | bool | false | Shows a button that clears both times and moves focus to the start field. It is a DwsCloseButton (a 44px touch area on a touch screen). |
| Haptic | DwsHapticFeedback | DwsHapticFeedback.Selection | Tactile feedback for a tap on a preset, while the app has haptics switched on (IDwsHapticService). The clear button plays a light tap unless this is None. Played inside the tap, so it works on iOS too. |
| Format | string? | null | .NET time format ("hh:mm tt", "HH:mm") for display and input in the current culture. The fields (DwsTimePickers) show and read it (other common spellings are accepted; Arrow Up / Down step by Step, Page Up / Down by an hour); unset, the culture's short time (long time when Step has seconds). A culture without AM/PM (German) shows AM / PM for a tt format. An unusable format falls back to the culture's, a 12-hour format without tt is used but logged, both once. |
| Color | DwsColor | DwsColor.Primary | Accent of the selected preset and the focus ring. |
| Name | Typ | Description |
|---|---|---|
| StartTimeChanged | EventCallback<TimeOnly?> | Raised when the user changes the start time (typing, arrow keys, a preset, or AutoCorrect moving it). |
| EndTimeChanged | EventCallback<TimeOnly?> | Raised when the user changes the end time (typing, arrow keys, a preset, or AutoCorrect moving it). |
| OnRangeSelected | EventCallback<DwsTimeRange> | Raised after a user change that leaves a complete, valid range, with the range the parent accepted. |
| OnRangeCleared | EventCallback | Raised when a user change empties both times. |
| OnValidationChanged | EventCallback<DwsTimeRangeValidationError> | Raised whenever ValidationError changes. |
| Name | Typ | Default | Description |
|---|---|---|---|
| Element | ElementReference | The associated web component. May be null if accessed before the component is rendered. | |
| ComponentGuid | Guid | Unique identifier for the component. | |
| TypeString | string | The name of the component type, obtained from reflection. | |
| Authorized_RegisterEnabled | bool | false | Indicates whether this component is enabled through a permission registry. |
| Authorized_RegisterSelected | bool | false | Indicates whether this component is selected in permission selection mode. |
| GetInitializedState | bool | false | Returns whether the component is initialized. |
| GetRenderModeState | DwsRenderMode | Returns the current render mode. | |
| GetComponentState | DwsComponentStateType | Returns the current component state. | |
| GetIsInteractiveState | bool | false | Returns whether the component is interactive. |
| GetIsPrerenderingState | bool | false | Returns whether the component is prerendering. |
| GetComponentLoadingState | bool | false | Returns whether the component is loading. |
| IsFormBusy | bool | false | Whether the DwsForm (or DwsFormBusyRegion) around the component is locked because its submit handler is running. The state itself is the cascaded FormBusyState (IDwsFormBusyState). |
| Name | Typ | Parameters | Description |
|---|---|---|---|
| DebugInfo | void | Logs debug information about the component. | |
| UpdateState | void | Updates the component's state and triggers StateHasChanged. | |
| UpdateStateAsync | Task | Asynchronously updates the component's state and triggers StateHasChanged. | |
| Dispose | void | Disposes the component and releases resources. | |
| FocusAsync | ValueTask | bool containedInScrollableList | Sets focus to the component's element. |
| Name | Typ | Default | Description |
|---|---|---|---|
| Name | string | Required unique identifier for the component within its container. | |
| Visible | bool | true | Determines if the component is visible in the UI. |
| Disabled | bool | false | Disables the form control, ensuring it doesn't participate in form submission. |
| ComponentNameSpace | string | The namespace for permission-based access control. | |
| PermissionKey | string? | null | A stable key that takes the place of Name in the generated permission namespace (Page.PermissionKey): the stored permission survives a rename, and components that share a key share one permission entry. Null: keyed by Name. Read once, when the component registers; an explicit ComponentNameSpace wins. |
| Class | string | Optional CSS class names. | |
| Style | string | Optional in-line styles. | |
| Tag | object | An optional user-defined object to store any additional data with the component. | |
| BackReference | DwsReference | A reference to the enclosing component. | |
| ID | string | The HTML ID attribute for the component. | |
| AdditionalAttributes | Dictionary<string, object> | Additional HTML attributes for the component's root element. | |
| IgnorePermissionChecks | bool | false | Bypasses all permission checks for this component. |
| IgnorePermissionSelection | bool | false | Ignore permission selection mode for this component. |
| IgnoreFormBusy | bool | false | Takes the component out of the submit lock of the DwsForm (or DwsFormBusyRegion) around it: IsFormBusy stays false for it. |
| Name | Typ | Description |
|---|---|---|
| OnInitializedCallbackStarted | EventCallback | Callback when OnInitialized starts. |
| OnInitializedCallback | EventCallback | Callback during OnInitialized. |
| OnInitializedCallbackCompleted | EventCallback | Callback when OnInitialized completes. |
| OnInitializedAsyncCallbackStarted | EventCallback | Callback when OnInitializedAsync starts. |
| OnInitializedAsyncCallback | EventCallback | Callback during OnInitializedAsync. |
| OnInitializedAsyncCallbackCompleted | EventCallback | Callback when OnInitializedAsync completes. |
| OnIsComponentLoadingChanged | EventCallback<bool> | Callback when IsComponentLoading changes. |
| OnCurrentRenderModeChanged | EventCallback<DwsRenderMode> | Callback when CurrentRenderMode changes. |
| OnComponentStateChanged | EventCallback<DwsComponentStateType> | Callback when ComponentState changes. |
