4.0 KiB
4.0 KiB
SbDatePicker
A date picker component with calendar dropdown, supporting multiple calendar systems (Gregorian, Persian, Hijri), date constraints, and keyboard navigation.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| Value | DateOnly? | null | The selected date (two-way bindable) |
| ValueChanged | EventCallback<DateOnly?> | - | Callback when date changes |
| CalendarSystem | SbCalendarSystem? | null | Calendar system; when null, uses current UI culture (e.g. Farsi → Persian/Jalali) |
| Min | DateOnly? | null | Minimum selectable date |
| Max | DateOnly? | null | Maximum selectable date |
| DisableWeekends | bool | false | When true, disables weekend days (e.g. Sat/Sun for Gregorian, Friday for Persian) |
| IsDateDisabled | Func<DateOnly, bool>? | null | Function to disable specific dates (use for custom rules) |
| Format | string? | null | Date format string |
| Placeholder | string? | null | Placeholder when no date selected; when null, uses localized default |
| Clearable | bool | true | Whether to show clear button |
| Disabled | bool | false | Whether the picker is disabled |
| Label | string? | null | Label text displayed above the picker |
| Class | string? | null | Additional CSS classes |
| Style | string? | null | Inline styles |
Events
| Event | Type | Description |
|---|---|---|
| ValueChanged | EventCallback<DateOnly?> | Fired when the selected date changes |
CSS Classes
sb-datepicker- Base classsb-datepicker__label- Label elementsb-datepicker__trigger- Button that opens the calendarsb-datepicker__trigger--disabled- Disabled trigger statesb-datepicker__value- Selected value displaysb-datepicker__placeholder- Placeholder textsb-datepicker__clear- Clear buttonsb-datepicker__icon- Calendar iconsb-datepicker__dropdown- Calendar dropdownsb-datepicker__dropdown--flip-up- Dropdown flips upwardsb-datepicker__header- Month/year navigation headersb-datepicker__nav-btn- Navigation buttonssb-datepicker__title- Month/year titlesb-datepicker__day-names- Day names rowsb-datepicker__day-name- Individual day namesb-datepicker__days- Days gridsb-datepicker__day- Individual day buttonsb-datepicker__day--other-month- Day from adjacent monthsb-datepicker__day--today- Today's datesb-datepicker__day--selected- Selected datesb-datepicker__day--disabled- Disabled datesb-datepicker__footer- Footer with today button
Accessibility
- Keyboard navigation: Arrow keys to move, Enter to select
aria-labelon navigation buttons- Clear button has aria-label
- Supports RTL for Persian/Arabic calendars
Examples
Basic Usage
<SbDatePicker @bind-Value="selectedDate" Label="Birth Date" />
With Constraints
<SbDatePicker @bind-Value="checkInDate"
Label="Check-in Date"
Min="@DateOnly.FromDateTime(DateTime.Today)"
Max="@DateOnly.FromDateTime(DateTime.Today.AddMonths(6))" />
Persian Calendar
<SbDatePicker @bind-Value="persianDate"
CalendarSystem="SbCalendarSystem.Persian"
Label="تاریخ" />
Disable Weekends
<SbDatePicker @bind-Value="appointmentDate"
Label="Appointment Date"
DisableWeekends="true" />
Weekends follow the current calendar (e.g. Saturday/Sunday for Gregorian, Friday only for Persian). For custom rules, use IsDateDisabled.
Custom Format
<SbDatePicker @bind-Value="eventDate"
Label="Event Date"
Format="MMMM dd, yyyy" />
Required Field
<SbDatePicker @bind-Value="dueDate"
Label="Due Date"
Clearable="false"
Placeholder="Select due date (required)" />
Disabled State
<SbDatePicker Value="@fixedDate"
Label="Registration Date"
Disabled="true" />