DeepWorks Studios Blazor Component Library

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

DwsDatePicker

API Reference

Disabled

Disabled switches the field off completely: it cannot be focused, typed into or opened.

Show Code
DatePicker.razor

<DwsDatePicker Name="DisabledPicker" Label="Disabled" @bind-Value="@_stateDate" IconLabel="@Icons.BS.Calendar" Tooltip="The field is disabled" Disabled="true"></DwsDatePicker>
DatePicker.razor.cs

private DateOnly? _stateDate = DateOnly.FromDateTime(DateTime.Today.AddDays(30));

Read-only

Readonly shows the value and keeps it selectable, but the user cannot change it.

Show Code
DatePicker.razor

<DwsDatePicker Name="ReadOnlyPicker" Label="Read-only with icon" @bind-Value="@_readOnlyDate" IconLabel="@Icons.BS.Calendar2" Tooltip="The value is visible but cannot be edited" Readonly="true"></DwsDatePicker>
DatePicker.razor.cs

private DateOnly? _readOnlyDate = DateOnly.FromDateTime(DateTime.Today.AddDays(30));

Highlights

Info, warning and error highlights.



Show Code
DatePicker.razor

<DwsDatePicker Name="InfoPicker" Label="Info Highlight" IconLabel="@Icons.BS.Calendar" Highlight="DwsHighlightType.INFO" @bind-Value="@_infoDate" Tooltip="Info highlight"></DwsDatePicker><br />

<DwsDatePicker Name="WarningPicker" Label="Warning Highlight" IconLabel="@Icons.BS.Calendar2" Highlight="DwsHighlightType.WARNING" @bind-Value="@_warningDate" Tooltip="Warning highlight"></DwsDatePicker><br />

<DwsDatePicker Name="ErrorPicker" Label="Error Highlight" IconLabel="@Icons.BS.Calendar2" Highlight="DwsHighlightType.ERROR" @bind-Value="@_errorDate" Tooltip="Error highlight"></DwsDatePicker>
DatePicker.razor.cs

private DateOnly? _infoDate = DateOnly.FromDateTime(DateTime.Today.AddDays(1));
private DateOnly? _warningDate = DateOnly.FromDateTime(DateTime.Today.AddDays(7));
private DateOnly? _errorDate = DateOnly.FromDateTime(DateTime.Today.AddDays(14));

Min / max date

Limits the selectable dates to an allowed period. The calendar greys the days outside it and does not let them be picked.

Show Code
DatePicker.razor

<DwsDatePicker Name="CurrentMonthPicker" Label="Current month" IconLabel="@Icons.BS.Calendar" @bind-Value="@_rangeDate" MinDate="@_rangeMinDate" MaxDate="@_rangeMaxDate" Tooltip="Only dates in the current month can be picked"></DwsDatePicker>
DatePicker.razor.cs

private readonly DateOnly _rangeMinDate = new(DateTime.Today.Year, DateTime.Today.Month, 1);
private readonly DateOnly _rangeMaxDate = new(DateTime.Today.Year, DateTime.Today.Month, DateTime.DaysInMonth(DateTime.Today.Year, DateTime.Today.Month));
private DateOnly? _rangeDate = DateOnly.FromDateTime(DateTime.Today);

Browser's own date input

UseNativeInput keeps the browser's date control, as before the themed calendar: its format, first day of the week and look follow the browser / OS, and days that are not allowed are only refused after picking.

Show Code
DatePicker.razor

<DwsDatePicker Name="NativePicker" Label="Native input" IconLabel="@Icons.BS.Calendar" UseNativeInput="true" @bind-Value="@_nativeDate" MinDate="@_rangeMinDate" MaxDate="@_rangeMaxDate" IsDateDisabled="@IsWeekend" Tooltip="The browser's own date control"></DwsDatePicker>
DatePicker.razor.cs

private readonly DateOnly _rangeMinDate = new(DateTime.Today.Year, DateTime.Today.Month, 1);
private readonly DateOnly _rangeMaxDate = new(DateTime.Today.Year, DateTime.Today.Month, DateTime.DaysInMonth(DateTime.Today.Year, DateTime.Today.Month));
private DateOnly? _nativeDate = DateOnly.FromDateTime(DateTime.Today);

private static bool IsWeekend(DateOnly date) => date.DayOfWeek is DayOfWeek.Saturday or DayOfWeek.Sunday;

Interface-Description

Name Typ Default Description
CurrentValue DateOnly? null The currently shown (validated) date.
Name Typ Parameters Description
FocusAsync Task Moves focus to the DatePicker from code (inherited from DwsBaseBlazorComponent).
OpenAsync Task Opens the calendar popup. Does nothing with UseNativeInput or while the field cannot be edited.
CloseAsync Task Closes the calendar popup.
Name Typ Default Description
Value DateOnly? null The selected date. Supports two-way binding with @bind-Value. A value set by the parent raises ValueChanged only when it had to be corrected.
UseNativeInput bool false false: the library's own field and calendar popup (localized format and week start, greyed days). true: the browser's <input type="date">, as before fix batch 41.
Format string? null The .NET date format the field shows and reads, e.g. "yyyy-MM-dd". null: the short date of the current language. Not used with UseNativeInput.
CompactSheet bool true Below 576 px the calendar docks to the bottom of the screen at full width. Not used with UseNativeInput.
ShowWeekNumbers bool false Shows the week number in front of every week of the calendar. Not used with UseNativeInput.
Haptic DwsHapticFeedback DwsHapticFeedback.Selection Tactile feedback for a tap on a day or Today in the calendar, while the app has haptics switched on (IDwsHapticService); Clear and Done play a light tap unless this is None. Not used with UseNativeInput.
MinDate DateOnly? null The earliest selectable date. No lower limit when null.
MaxDate DateOnly? null The latest selectable date. No upper limit when null.
IsDateDisabled Func<DateOnly, bool>? null Predicate that excludes single dates, e.g. weekends or holidays.
ValidationFallback DwsDateValidationFallback DwsDateValidationFallback.Clamp What happens to an invalid value: clamp it, keep the previous value, or set it to null.
DefaultValue DateOnly? null Optional initial value, used only when Value is null on initialization.
ShowValidationMessage bool true Shows the hint below the field after a correction. Components with their own message (e.g. DwsDateRangePicker) switch it off.
Label string string.Empty The field caption (floating label).
IconLabel string string.Empty Optional icon before the label, e.g. a calendar icon.
DisplayFormatType DwsDateFormatType DwsDateFormatType.Short Format of the optional localized hint below the field.
CustomDisplayFormat string? null Custom .NET date format, used when DisplayFormatType = CustomFormat.
ShowFormatHint bool false Shows the localized format hint below the field.
Behavior DwsPickerBehavior DwsPickerBehavior.EditableDialog Whether only the dialog, only the keyboard, or both are allowed.
Readonly bool false Shows the value but prevents changes by the user.
Disabled bool false Disables the field completely.
Hidden bool false Hides the field without removing the component.
Autofocus bool false Focuses the field automatically when rendered.
Tooltip string string.Empty Tooltip text with additional hints.
TooltipPosition DwsTooltipPosition DwsTooltipPosition.Top Kept so existing markup still compiles: the tooltip is the browser's native title, which has no position.
Highlight DwsHighlightType DwsHighlightType.NONE Visual highlight, e.g. INFO, WARNING or ERROR.
ValueExpression Expression<Func<DateOnly?>>? null The bound field, set by @bind-Value. Names the browser's date input (UseNativeInput, and always under static SSR) after it (Model.Birthday), so a static form posts an ISO date.
Name Typ Description
ValueChanged EventCallback<DateOnly?> Raised when the user picks or types a date, and when a value from the parent or DefaultValue was corrected or applied.
OnBlur EventCallback<DateOnly?> Raised when the field loses focus. Passes the current value.
OnInvalidValue EventCallback<DateOnly?> Raised when Value was outside the allowed range and was corrected by ValidationFallback. Passes the value that 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.
An error has occurred. This app may no longer respond until reloaded.