Par3aa.PersianDatePicker
1.0.1
dotnet add package Par3aa.PersianDatePicker --version 1.0.1
NuGet\Install-Package Par3aa.PersianDatePicker -Version 1.0.1
<PackageReference Include="Par3aa.PersianDatePicker" Version="1.0.1" />
<PackageVersion Include="Par3aa.PersianDatePicker" Version="1.0.1" />
<PackageReference Include="Par3aa.PersianDatePicker" />
paket add Par3aa.PersianDatePicker --version 1.0.1
#r "nuget: Par3aa.PersianDatePicker, 1.0.1"
#:package Par3aa.PersianDatePicker@1.0.1
#addin nuget:?package=Par3aa.PersianDatePicker&version=1.0.1
#tool nuget:?package=Par3aa.PersianDatePicker&version=1.0.1
PersianDatePicker
A Blazor Razor Class Library providing a Persian (Jalali) date picker built on System.Globalization.PersianCalendar. It supports binding to DateTime and DateTime?, two input modes (dropdowns or numeric inputs), and global defaults configured once per application.
Features
- π
Persian (Jalali) calendar via
System.Globalization.PersianCalendar - π Two-way binding for
DateTimeandDateTime? - π½ DropDown mode or π’ TextBox mode
- π Configurable year range with automatic normalization
- π§° Optional Today and Clear actions
- βοΈ Global defaults (
PersianDatePicker.Defaults) so parameters arenβt repeated in every instance - π¨ Minimal CSS; integrates cleanly with popular UI libraries
- βΏ Accessibility-conscious (ARIA and focus handling)
- π§© Customizable SVG icons
Installation
dotnet add package Par3aa.PersianDatePicker
Getting Started
Add the namespace:
@using Par3aa
Bind to DateTime:
<PersianDatePicker TValue="DateTime"
@bind-Value="MyDate"
SelectionMode="PersianDatePicker.SelectionMode.DropDown"
ShowTodayButton="true"
StartYear="1350"
EndYear="1450" />
Bind to DateTime? (nullable):
<PersianDatePicker TValue="DateTime?"
@bind-Value="MyNullableDate"
SelectionMode="PersianDatePicker.SelectionMode.TextBox"
ShowClearButton="true"
ShowTodayButton="true" />
ShowClearButtonis valid only when bound toDateTime?.
Configure Once, Use Everywhere
Set global defaults at application startup:
using Par3aa;
// Example defaults
PersianDatePicker.Defaults.SelectionMode = PersianDatePicker.SelectionMode.DropDown;
PersianDatePicker.Defaults.ShowTodayButton = true;
PersianDatePicker.Defaults.ShowClearButton = true;
PersianDatePicker.Defaults.StartYear = 1320;
PersianDatePicker.Defaults.EndYear = PersianCalendar.GetYear(DateTime.Today);
// Optional styling defaults
PersianDatePicker.Defaults.InputClass = "my-input";
PersianDatePicker.Defaults.ButtonClass = "my-button";
PersianDatePicker.Defaults.Style = "border: 1px solid #e6e6e6; border-radius: 6px;";
PersianDatePicker.Defaults.Color = "slategray";
Any instance parameter overrides the corresponding default.
Color and Theming
Button and icon color is driven by a CSS variable with a broad fallback chain across popular frameworks:
:root {
--button-color:
var(--rz-primary, /* Radzen */
var(--mud-palette-primary, /* MudBlazor */
var(--kendo-color-primary, /* Kendo/Telerik */
var(--e-primary-color, /* Syncfusion */
var(--dxbl-primary, /* DevExpress Blazor */
var(--bs-primary, /* Blazorise / Bootstrap */
#7f00ff /* Fallback (Blazor violet) */
)))));
}
Icons use fill="currentColor", so they inherit --button-color.
You can add fill="currentColor" to your own SVG files to have them inherit the color dynamically too.
Set per instance:
<PersianDatePicker TValue="DateTime?" @bind-Value="MyNullableDate" Color="#2d6a4f" ShowClearButton="true" ShowTodayButton="true" />Set globally:
PersianDatePicker.Defaults.Color = "#2d6a4f";Customize icons (globally or per instance) by supplying inline SVG:
PersianDatePicker.Defaults.TodayIcon = "<svg ... fill=\"currentColor\">...</svg>"; PersianDatePicker.Defaults.ClearIcon = "<svg ... fill=\"currentColor\">...</svg>";
Accessibility
aria-labelandaria-disabledon interactive elementstabindexset to-1when not interactive- Native inputs that support keyboard navigation
- Invalid date combinations revert to last valid value
API Overview
Key parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
TValue |
Either DateTime or DateTime? |
β | Bound value type. Can be ignored, it is auto-detected from Value. |
Value |
TValue |
β | Bound date value. |
ValueChanged |
EventCallback<TValue> |
β | Invoked on value changes. |
Change |
EventCallback<TValue> |
β | Alias event for value changes. |
SelectionMode |
SelectionMode |
TextBox |
DropDown or TextBox inputs. |
StartYear |
int |
1300 |
Minimum selectable Persian year. If the bound Value is earlier than this, the range automatically extends to include it. |
EndYear |
int |
1500 |
Maximum selectable Persian year. If the bound Value is later than this, the range automatically extends to include it. |
ShowTodayButton |
bool |
false |
Shows a π button that sets Value to DateTime.Today. |
ShowClearButton |
bool |
false |
Shows a β button that sets Value to null (nullable DateTime? only). |
SeparatorCharacter |
string |
"-" |
Separator between inputs. (e.g. 1404 - 01 - 27) |
ReadOnly |
bool |
false |
Prevent interaction but show value. |
Disabled |
bool |
false |
Disable control. |
Color |
string? |
null |
Overrides --button-color for this instance. |
TodayIcon |
string |
bundled | Inline SVG for Today Button (add fill=\"currentColor\" to your custom icons). |
ClearIcon |
string |
bundled | Inline SVG for Clear Button (add fill=\"currentColor\" to your custom icons). |
Class, Style |
string |
"" |
Root element styling. |
ButtonClass, ButtonStyle |
string |
"" |
Button styling. |
InputClass, InputStyle |
string |
"" |
Input styling. (used for both TextBox and DropDown SelectionModes) |
Selected parts (two-way binding):
| Parameter | Type | Description |
|---|---|---|
SelectedYear |
int? |
Current Persian year. |
SelectedMonth |
int? |
Current Persian month (1β12). |
SelectedDay |
int? |
Current Persian day-of-month. |
Tooltips:
| Parameter | Default |
|---|---|
YearTooltip |
Year |
MonthTooltip |
Month |
DayTooltip |
Day |
How To Use
Option 1: Build and pack locally
dotnet pack -c Release
Option 2: Install from NuGet
dotnet add package Par3aa.PersianDatePicker
License
MIT License file available in root directory.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.22)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.