Par3aa.PersianDatePicker 1.0.1

dotnet add package Par3aa.PersianDatePicker --version 1.0.1
                    
NuGet\Install-Package Par3aa.PersianDatePicker -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Par3aa.PersianDatePicker" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Par3aa.PersianDatePicker" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Par3aa.PersianDatePicker" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Par3aa.PersianDatePicker --version 1.0.1
                    
#r "nuget: Par3aa.PersianDatePicker, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Par3aa.PersianDatePicker@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Par3aa.PersianDatePicker&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Par3aa.PersianDatePicker&version=1.0.1
                    
Install as a Cake Tool

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 DateTime and DateTime?
  • πŸ”½ 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" />

ShowClearButton is valid only when bound to DateTime?.


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-label and aria-disabled on interactive elements
  • tabindex set to -1 when 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 159 1/8/2026
1.0.0 172 1/8/2026