DeepWorks Studios Blazor Component Library

Demo user Administrator · Blazor Server Library 20261206222504-6e8ff32.dirty

DwsDateRangePicker

API Reference

Min / max date

MinDate and MaxDate limit the selectable days; the calendar also stops paging at them. The fields refuse typed dates outside the limits the same way (and so do the browser's date dialogs with UseNativeInput).

Show Code
DateRangePicker.razor

<DwsDateRangePicker Name="LimitedRange" MinDate="@_today" MaxDate="@_today.AddDays(90)" @bind-StartDate="@_limitsStart" @bind-EndDate="@_limitsEnd" />
<span>Bookable from @_today.ToShortDateString() to @_today.AddDays(90).ToShortDateString(). Selected: @FormatRange(_limitsStart, _limitsEnd)</span>
DateRangePicker.razor.cs

private static DateOnly _today => DateOnly.FromDateTime(DateTime.Today);

private DateOnly? _limitsStart;
private DateOnly? _limitsEnd;

private static string FormatRange(DateOnly? start, DateOnly? end) =>
    $"{start?.ToShortDateString() ?? "-"} – {end?.ToShortDateString() ?? "-"}";

Default dates

DefaultStartDate / DefaultEndDate fill an empty range on the first render and report it to the parent. CalendarMode None shows only the two fields.

Show Code
DateRangePicker.razor

<DwsDateRangePicker Name="DefaultRange" CalendarMode="DwsDateRangeCalendarMode.None" DefaultStartDate="@_today" DefaultEndDate="@_today.AddDays(6)"
                    @bind-StartDate="@_defaultsStart" @bind-EndDate="@_defaultsEnd" />
<span>Fields only, defaulted to this week: @FormatRange(_defaultsStart, _defaultsEnd)</span>
DateRangePicker.razor.cs

private static DateOnly _today => DateOnly.FromDateTime(DateTime.Today);

private DateOnly? _defaultsStart;
private DateOnly? _defaultsEnd;

private static string FormatRange(DateOnly? start, DateOnly? end) =>
    $"{start?.ToShortDateString() ?? "-"} – {end?.ToShortDateString() ?? "-"}";

Read-only

Readonly shows the range - calendar included - without letting it change.

Show Code
DateRangePicker.razor

<DwsDateRangePicker Name="ReadonlyRange" Readonly="true" StartDate="@_today" EndDate="@_today.AddDays(3)" />
DateRangePicker.razor.cs

private static DateOnly _today => DateOnly.FromDateTime(DateTime.Today);

Disabled

Disabled greys out the fields and the calendar button.

Show Code
DateRangePicker.razor

<DwsDateRangePicker Name="DisabledRange" Disabled="true" StartDate="@_today" EndDate="@_today.AddDays(3)" />
DateRangePicker.razor.cs

private static DateOnly _today => DateOnly.FromDateTime(DateTime.Today);

Browser's date inputs

UseNativeInput switches to the browser's own date inputs, each with the browser's date dialog, as before the themed fields.

Show Code
DateRangePicker.razor

<DwsDateRangePicker Name="NativeRange" UseNativeInput="true" StartLabel="Native - start" EndLabel="Native - end"
                    @bind-StartDate="@_nativeStart" @bind-EndDate="@_nativeEnd" />
<span>Native range: @FormatRange(_nativeStart, _nativeEnd)</span>
DateRangePicker.razor.cs

private static DateOnly _today => DateOnly.FromDateTime(DateTime.Today);

private DateOnly? _nativeStart = _today;
private DateOnly? _nativeEnd = _today.AddDays(2);

private static string FormatRange(DateOnly? start, DateOnly? end) =>
    $"{start?.ToShortDateString() ?? "-"} – {end?.ToShortDateString() ?? "-"}";

Interface-Description

Name Typ Default Description
Range DwsDateRange? null The selected range (Start, End, DayCount, Contains), or null while a date is missing.
IsCalendarOpen bool false Whether the calendar popover is open.
Name Typ Parameters Description
SetRangeAsync Task Sets the range as if the user had picked it: validated, raising the change callbacks and OnRangeSelected, and showing it in the calendar.
ClearAsync Task Clears both dates and raises OnRangeCleared.
OpenCalendarAsync Task Opens the calendar popover (CalendarMode Popup).
CloseCalendarAsync Task Closes the calendar popover and drops a half-picked range.
Name Typ Default Description
StartDate DateOnly? null First day of the range. Two-way bindable via @bind-StartDate.
EndDate DateOnly? null Last day of the range (included). Two-way bindable via @bind-EndDate.
DefaultStartDate DateOnly? null Start date used when both dates are empty on the first render; reported through StartDateChanged.
DefaultEndDate DateOnly? null End date used when both dates are empty on the first render; reported through EndDateChanged.
MinDate DateOnly? null Earliest selectable date. Ignored (logged once) when it lies after MaxDate.
MaxDate DateOnly? null Latest selectable date.
IsDateDisabled Func<DateOnly, bool>? null Returns true for days that cannot be a start or end date (weekends, holidays). A range may still span them.
MinRangeDays int? null Fewest days a range may span, both ends included. Values below 1, a minimum above MaxRangeDays or one that does not fit between MinDate and MaxDate are ignored (logged once).
MaxRangeDays int? null Most days a range may span, both ends included.
ValidationFallback DwsDateValidationFallback DwsDateValidationFallback.Clamp How an invalid range from the parent, a preset, SetRangeAsync or a typed date is corrected: Clamp, RejectKeepPrevious or RejectClearToNull. A new start after the end always moves the end along.
ShowValidationMessage bool true Shows a localised message under the fields describing the last correction.
CalendarMode DwsDateRangeCalendarMode DwsDateRangeCalendarMode.Popup Where the range calendar is shown: Popup (a popover opened with the calendar button), Inline (always visible) or None (fields only).
MonthsShown int 2 Months shown side by side, 1 to 3. Other values fall back to 2 (logged once). Narrow screens wrap them.
FirstDayOfWeek DayOfWeek? null First column of the calendar and start of "This week". Unset uses the current culture.
ShowPresets bool false Shows quick presets next to the calendar, plus Custom range.
Presets IReadOnlyList<DwsDateRangePreset>? null Own presets. Unset uses DwsDateRangePreset.CreateDefaults (Today, Yesterday, Last 7 / 30 days, This week, This month, Last month, This year). Presets that break the limits are disabled.
CloseOnSelect bool true Closes the calendar popover once a range is picked in it or a preset is chosen.
StartLabel string? null Label of the start field. Unset uses the localised "Start date".
EndLabel string? null Label of the end field. Unset uses the localised "End date".
Color DwsColor DwsColor.Primary Color of the selected days and the range band.
Width int? null Width in px. Unset fills the container.
ShowClearButton bool true Shows a button that clears both dates while a date is set.
Behavior DwsPickerBehavior DwsPickerBehavior.EditableDialog Themed fields: EditableDialog types or opens the range calendar with Alt+Down arrow, OnlyDialog makes the fields read-only and opens the range calendar on click, Enter, Space or Down arrow, OnlyEditable types only. With UseNativeInput it is handed to the browser's date inputs (see DwsDatePicker).
UseNativeInput bool false false: the library's themed text fields in the short date of the current language, without a popup of their own. true: the browser's <input type="date"> fields with their own date dialogs, as before.
Readonly bool false Shows the range, calendar included, without letting the user change it.
CompactSheet bool true Whether the popup calendar opens as a sheet across the bottom of the screen at phone width (below 576 px), with a Done button, instead of a popover beside the fields - where it did not fit and scrolled inside. Wider viewports are not affected.
ShowMonthYearJump bool true Whether the single month shown at phone width (below 576 px) gets a month and a year select in its header, so a date far away takes two taps instead of one per month. The years run from MinDate to MaxDate, or ten years either side of the month shown. Wider viewports keep the plain month title. The selects are DwsNativeSelects, so a phone shows its system picker.
Haptic DwsHapticFeedback DwsHapticFeedback.Selection Tactile feedback for a tap on a day or a preset, while the app has haptics switched on (IDwsHapticService). The clear button and the sheet's Done play a light tap unless this is None. Played inside the tap, so it works on iOS too.
StartDateExpression Expression<Func<DateOnly?>>? null The bound start, set by @bind-StartDate. Names the start field (Model.From) for a statically rendered form.
EndDateExpression Expression<Func<DateOnly?>>? null The bound end, set by @bind-EndDate. Names the end field (Model.To) for a statically rendered form.
Name Typ Description
StartDateChanged EventCallback<DateOnly?> Raised when the start date changes - by the user, or when the picker corrects or defaults the parent's value.
EndDateChanged EventCallback<DateOnly?> Raised when the end date changes - by the user, or when the picker corrects or defaults the parent's value.
OnRangeSelected EventCallback<DwsDateRange> Raised when the user completes a range: in the calendar, with a preset, SetRangeAsync or by typing the second date.
OnRangeCleared EventCallback Raised when the range is cleared (clear button, ClearAsync or emptying both fields).
OnPresetSelected EventCallback<DwsDateRangePreset> Raised when a preset is picked, after its range was applied.
OnInvalidRange EventCallback<DwsDateRangeInvalidEventArgs> Raised when a range had to be corrected: Error (OutOfRange, DisabledDate, EndBeforeStart, RangeTooShort, RangeTooLong), the attempted and the corrected dates.
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.
An error has occurred. This app may no longer respond until reloaded.