DwsDateTimeRangePicker
API ReferenceLabels
StartLabel / EndLabel replace the localised labels of the two fields.
Press Enter to go to the end.
Press Shift+Enter to go back to the start.
Show Code
DateTimeRangePicker.razor
<DwsDateTimeRangePicker Name="StayRange" StartLabel="Check-in" EndLabel="Check-out"
@bind-StartDateTime="@_labelStart" @bind-EndDateTime="@_labelEnd" />DateTimeRangePicker.razor.cs
private DateTime? _labelStart = DateTime.Today.AddDays(1).AddHours(14);
private DateTime? _labelEnd = DateTime.Today.AddDays(3).AddHours(11);Tooltips
StartTooltip / EndTooltip give each field its own tooltip.
Press Enter to go to the end.
Press Shift+Enter to go back to the start.
Show Code
DateTimeRangePicker.razor
<DwsDateTimeRangePicker Name="TooltipRange" StartTooltip="When do you arrive?" EndTooltip="When do you leave?"
@bind-StartDateTime="@_tooltipStart" @bind-EndDateTime="@_tooltipEnd" />DateTimeRangePicker.razor.cs
private DateTime? _tooltipStart;
private DateTime? _tooltipEnd;Disabled
Disabled ignores input and greys the whole picker out, the clear button included.
Press Enter to go to the end.
Press Shift+Enter to go back to the start.
Show Code
DateTimeRangePicker.razor
<DwsDateTimeRangePicker Name="DisabledRange" StartLabel="Disabled start" EndLabel="Disabled end" Disabled="true" ShowClearButton="true"
StartDateTime="@_stateStart" EndDateTime="@_stateEnd" />DateTimeRangePicker.razor.cs
private readonly DateTime _stateStart = DateTime.Today.AddHours(8);
private readonly DateTime _stateEnd = DateTime.Today.AddHours(17);Interface-Description
| Name | Typ | Default | Description |
|---|---|---|---|
| CurrentRange | DwsDateTimeRange | (null, null) | The range the picker currently holds. |
| CurrentPreset | DwsDateTimeRangePreset? | null | The preset the current range was picked with, null for a custom range. |
| IsDisplayingUtc | bool | false | Whether the fields currently show UTC. |
| DwsDateTimeRange.StartUtc / EndUtc | DateTimeOffset? | null | On every DwsDateTimeRange the picker reports (CurrentRange, OnRangeSelected, preset.ResolveNow()): the ends as moments in UTC. Also StartOffset / EndOffset (with the zone's offset), Duration and TimeZone. Start / End stay wall-clock DateTime values of that zone. |
| Name | Typ | Parameters | Description |
|---|---|---|---|
| RefreshSelectedPresetAsync | Task<DwsDateTimeRange> | Applies the selected preset again as of now ("last 15 minutes" moves on to the current time) and returns the range. Without a selected preset nothing changes. | |
| SetDisplayUtcAsync | Task | bool displayUtc | Switches the fields between local time and UTC as the toggle does. |
| ClearAsync | Task | Clears both ends as the clear button does. | |
| SetRangeOffsetAsync | Task | SetRangeAsync for moments in time: both ends are shown in TimeZone, whatever offset they are passed with. | |
| SetRangeAsync | Task | DateTime? start, DateTime? end | Sets both ends from code. They are validated like parent values (an order problem moves the end) and reported like user input. |
| ApplyPresetAsync | Task | DwsDateTimeRangePreset preset | Applies a preset as its button does. |
| FocusStartAsync | ValueTask | Moves keyboard focus to the start field (also what FocusAsync does). | |
| FocusEndAsync | ValueTask | Moves keyboard focus to the end field. |
| Name | Typ | Default | Description |
|---|---|---|---|
| StartDateTime | DateTime? | null | The start of the range. Supports two-way binding via @bind-StartDateTime. A value the parent passes is validated like user input; a corrected value is reported back through StartDateTimeChanged. The picker keeps its own copy, so an unbound parent that re-renders does not reset the user's choice. |
| EndDateTime | DateTime? | null | The end of the range. Supports two-way binding via @bind-EndDateTime. An end before the start is corrected (see ValidationFallback). |
| StartOffset | DateTimeOffset? | null | The start as a moment in time, for consumers that work with DateTimeOffset. Two-way bindable. Shown in TimeZone (or UTC with DisplayUtc) whatever offset it is passed with, and reported back with the offset of TimeZone at that moment. Bind either this pair or the DateTime pair. |
| EndOffset | DateTimeOffset? | null | The end as a moment in time. See StartOffset. |
| DefaultStartDateTime | DateTime? | null | Used as the start when StartDateTime is null on the first render, and reported back through StartDateTimeChanged. Pass DateTime.Now to default to the current time. |
| DefaultEndDateTime | DateTime? | null | Used as the end when EndDateTime is null on the first render. |
| Format | string? | null | The .NET date and time format the two fields show and read, e.g. "dd.MM.yyyy HH:mm". null: "g", the short date and time of the current language. |
| MinuteStep | int | 5 | Interval of the popup's minute list, 1 to 60; typed input may use any minute. |
| CompactSheet | bool | true | Below 576 px the popup docks to the bottom of the screen at full width. |
| MinDateTime | DateTime? | null | The earliest selectable date-time; greyed in the calendars. A MinDateTime after MaxDateTime is logged as an error and both bounds are ignored. |
| MaxDateTime | DateTime? | null | The latest selectable date-time; greyed in the calendars. |
| IsDateTimeDisabled | Func<DateTime, bool>? | null | Returns true for date-times that must not be picked (weekends, holidays, night hours ...). |
| ValidationFallback | DwsDateValidationFallback | DwsDateValidationFallback.Clamp | What happens to an invalid entry. Clamp moves it onto the nearest bound (the start for an end before the start) and keeps the previous value for a disabled date-time; RejectKeepPrevious restores the last valid value; RejectClearToNull empties the field. |
| ShowValidationMessage | bool | true | Shows the message explaining a correction below the fields (role=alert, linked to the field via aria-describedby). |
| InvalidRangeMessage | string? | null | Replaces the localised message for an end before the start. |
| OutOfRangeMessage | string? | null | Replaces the localised message for a date-time outside MinDateTime / MaxDateTime. {0} and {1} are replaced with the formatted bounds. |
| DisabledDateTimeMessage | string? | null | Replaces the localised message for a date-time rejected by IsDateTimeDisabled. |
| Presets | IReadOnlyList<DwsDateTimeRangePreset>? | null | Quick-select buttons above the fields. DwsDateTimeRangePreset.Defaults holds the built-in ranges (Last 24 hours, Today, Yesterday, Last 7 days, This week, This month); new DwsDateTimeRangePreset(label, (now, culture) => range) creates your own. The button of the current range is marked with aria-pressed. |
| SelectedPreset | DwsDateTimeRangePreset? | null | The preset the range was picked with, null for a range typed or set otherwise ("Custom"). Supports two-way binding via @bind-SelectedPreset. Setting it applies the preset as of now and reports the resulting ends. It does not have to be one of Presets. Built-in presets: Last15Minutes, LastHour, Last24Hours, Today, Yesterday, Last7Days, ThisWeek, ThisMonth; the lists Defaults and LogViewerDefaults (15 min, 1 h, 24 h, 7 d). |
| ShowCustomState | bool | true | Shows a "Custom" marker next to the preset buttons while a range is set that no preset stands for. |
| ShowTimeZoneToggle | bool | false | Shows a Local / UTC switch above the fields. |
| DisplayUtc | bool | false | Shows and accepts the two fields in UTC. Supports two-way binding via @bind-DisplayUtc. Only the display changes: StartDateTime / EndDateTime stay wall-clock times of TimeZone. Day presets (Today ...) mean the UTC day while it is on. |
| TimeZone | TimeZoneInfo? | null | The zone "local" stands for: the zone the values, the bounds and the presets' "now" are wall-clock times of. null uses the clock's local zone - the server's on Blazor Server, the browser's on WebAssembly - so a Server app passes the user's zone. |
| ShowClearButton | bool | false | Shows a button that clears both ends. |
| StartLabel | string? | null | Label of the start field. Defaults to a localised "Start". |
| EndLabel | string? | null | Label of the end field. Defaults to a localised "End". |
| StartPlaceholder | string? | null | Hint shown below the empty start field. |
| EndPlaceholder | string? | null | Hint shown below the empty end field. |
| StartTooltip | string? | null | Tooltip of the start field. |
| EndTooltip | string? | null | Tooltip of the end field. |
| TooltipPosition | DwsTooltipPosition | DwsTooltipPosition.Top | Kept so existing markup still compiles: the tooltip is the browser's native title, which has no position. |
| Color | DwsColor | DwsColor.Undefined | Colour of the preset and clear buttons, resolved through the theme's CSS variables. Undefined uses the primary colour. |
| Behavior | DwsPickerBehavior | DwsPickerBehavior.EditableDialog | EditableDialog: typing, and the calendar opens with its button or Alt+ArrowDown. OnlyDialog: the calendar opens on click or Enter and typing is blocked. OnlyEditable: typing only. |
| Haptic | DwsHapticFeedback | DwsHapticFeedback.Selection | Tactile feedback for a tap on a preset, the Local / UTC toggle, or a day, hour or minute in a field's popup, 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. |
| Readonly | bool | false | Shows the range but ignores input, presets and the clear button. |
| StartDateTimeExpression | Expression<Func<DateTime?>>? | null | The bound start, set by @bind-StartDateTime. Names the start field under static SSR. |
| EndDateTimeExpression | Expression<Func<DateTime?>>? | null | The bound end, set by @bind-EndDateTime. Names the end field under static SSR. |
| Name | Typ | Description |
|---|---|---|
| StartDateTimeChanged | EventCallback<DateTime?> | Raised when the start changes by user input, a preset, the clear button, a default or a correction of the parent's value. |
| EndDateTimeChanged | EventCallback<DateTime?> | Raised when the end changes, as StartDateTimeChanged. |
| StartOffsetChanged | EventCallback<DateTimeOffset?> | Raised with the start as a moment in time, next to StartDateTimeChanged. |
| EndOffsetChanged | EventCallback<DateTimeOffset?> | Raised with the end as a moment in time, next to EndDateTimeChanged. |
| SelectedPresetChanged | EventCallback<DwsDateTimeRangePreset?> | Raised when a preset is picked, and with null when the range becomes a custom one (typing, SetRangeAsync, clearing, a new value from the parent). |
| DisplayUtcChanged | EventCallback<bool> | Raised when the user switches between local time and UTC. |
| OnRangeSelected | EventCallback<DwsDateTimeRange> | Raised when a user change (typing, preset, SetRangeAsync) leaves both ends set. |
| OnRangeCleared | EventCallback | Raised when a user change (clear button, ClearAsync, emptying the last field) leaves both ends empty. |
| OnInvalidRange | EventCallback<DwsDateTimeRange> | Raised when validation corrected a value, with the range as it was attempted. |
| 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. |
