BlazorColorPicker 4.2.0
dotnet add package BlazorColorPicker --version 4.2.0
NuGet\Install-Package BlazorColorPicker -Version 4.2.0
<PackageReference Include="BlazorColorPicker" Version="4.2.0" />
<PackageVersion Include="BlazorColorPicker" Version="4.2.0" />
<PackageReference Include="BlazorColorPicker" />
paket add BlazorColorPicker --version 4.2.0
#r "nuget: BlazorColorPicker, 4.2.0"
#:package BlazorColorPicker@4.2.0
#addin nuget:?package=BlazorColorPicker&version=4.2.0
#tool nuget:?package=BlazorColorPicker&version=4.2.0
Blazor-Color-Picker
Sometimes HTML5 colorpicker doesn't suit me for an application. I prefer to offer the user a predefined color palette
DEMO : https://tossnet.github.io/Blazor-Color-Picker/
Opens a palette with the Material colors
Installation
The implementation has been improved: version 4.0 uses a service declared via dependency injection
To Install
Install-Package BlazorColorPicker
or
dotnet add package BlazorColorPicker
For client-side and server-side Blazor - add script section to index.html or _Host.cshtml (head section)
<link href="_content/BlazorColorPicker/colorpicker.css" rel="stylesheet" />
In program.cs, declare
builder.Services.AddColorPicker();
ColorPicker are rendered by the <BlazorColorPicker.ColorPicker />. This component needs to be added to the main layout of your application/site. You typically do this in the MainLayout.razor file at the end of the <main> section.
Usage
@page "/"
@using BlazorColorPicker
@inject IColorPickerService ColorPickerService
<button class="btn btn-primary" @onclick="OpenModal">
<div style="background-color:@color" class="buttonColor"></div> Select a Color
</button>
@code {
private string color = "#F1F7E9";
private async Task OpenModal()
{
var parameters = new ColorPickerParameters
{
ColorSelected = color,
};
color = await ColorPickerService.ShowColorPicker(parameters);
}
}
Find Closest Color
When the selected color doesn't exist in the palette, you can enable automatic matching to the closest available color using the FindClosestIfNotFound parameter:
var parameters = new ColorPickerParameters
{
ColorSelected = "#8B4513", // SaddleBrown - not in the default palette
FindClosestIfNotFound = true,
};
color = await ColorPickerService.ShowColorPicker(parameters);
The algorithm uses a weighted Euclidean distance in RGB color space, which accounts for human color perception (green differences are more noticeable than red or blue).
Color comparison is case-insensitive: #ec407a will match #EC407A in the palette.
<a name="ReleaseNotes"></a>Release Notes
<details open="open"><summary>Version 4.2.0</summary>
- New feature:
FindClosestIfNotFoundparameter - when the selected color is not in the palette, automatically highlights the closest matching color- Color comparison is now case-insensitive (
#ec407amatches#EC407A)- Uses weighted Euclidean distance algorithm for perceptually accurate color matching </details>
<details><summary>Version 4.1.1</summary>
- Performance & memory optimization: default colors are now static and shared across all instances
- Fixed memory leak in OnParametersSet() that caused unbounded list growth
- Zero allocations when using default color palette </details>
<details><summary>Version 4.0.2</summary>
- Added AddColorPicker() to simplify declaration </details>
<details><summary>Version 4.0.1</summary>
- increase the z-index to 9999 </details>
<details><summary>Version 4.0.0</summary>
- the implementation has been improved: version 4.0 uses a service declared via dependency injection </details>
⚠️ Breaking changes ⚠️
<details><summary>Version 3.1.0</summary>
- you can customise the size of the palette using your CSS styles
- A red colour of the first column was not correct
- Re-addition of .NET7 compatibility </details>
<details><summary>Version 2.2.0</summary>
- Remove the internal use of IJSRuntime </details>
<details><summary>Version 2.1.0</summary>
- no need to declare the _content/BlazorColorPicker/colorpicker.js file </details>
| 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 is compatible. 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 is compatible. 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. |
-
net10.0
- Microsoft.AspNetCore.Components.Web (>= 10.0.2)
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.23)
-
net9.0
- Microsoft.AspNetCore.Components.Web (>= 9.0.12)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on BlazorColorPicker:
| Package | Downloads |
|---|---|
|
PrototyperThemeRCL
Do not use yet. A Razor Class Library that provides user built themes to attach to pages and components. Themes are divided into 'Sets' and a set is applied to a page or component. No knowledge of CSS is required to set up a Theme. |
|
|
PrototyperMenuRCL
Do not try to use this yet. A Razor Class Library that provides data driven menus. The current version only allows very graphical menu buttons. Menu 'Sets' contain menu 'Rows' which in turn contain 'buttons'. Clicking on a button can (1) go to another menu set (2) go to a page in the host app (3) load a component from the host or the RCL. Provides easy maintence of the data and easy to implement. |
|
|
KristofferStrube.Blazor.SVGEditor
A SVG Editor that is implemented in and for Blazor. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on BlazorColorPicker:
| Repository | Stars |
|---|---|
|
KristofferStrube/Blazor.SVGEditor
A basic SVG editor written in Blazor.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 4.2.0 | 131 | 1/23/2026 |
| 4.1.1 | 148 | 1/17/2026 |
| 4.1.0 | 124 | 1/14/2026 |
| 4.0.2 | 5,844 | 3/16/2025 |
| 4.0.1 | 262 | 3/15/2025 |
| 4.0.0 | 311 | 3/15/2025 |
| 3.1.2 | 6,884 | 11/15/2024 |
| 3.1.1 | 13,779 | 3/31/2024 |
| 3.1.0 | 528 | 3/30/2024 |
| 3.0.0 | 1,920 | 1/26/2024 |
| 2.3.1 | 4,684 | 11/15/2023 |
| 2.3.0 | 15,232 | 12/2/2022 |
| 2.2.0 | 5,072 | 10/22/2022 |
| 2.1.0 | 38,217 | 4/4/2022 |
| 2.0.1 | 1,695 | 2/16/2022 |
| 2.0.0 | 4,601 | 12/16/2021 |
| 1.2.1 | 17,882 | 6/15/2021 |
| 1.2.0 | 844 | 5/17/2021 |
| 1.1.2 | 9,313 | 1/16/2021 |
| 1.1.1 | 7,642 | 11/1/2020 |
| 1.1.0 | 1,882 | 10/14/2020 |
| 1.0.9 | 1,933 | 5/27/2020 |
| 1.0.8 | 721 | 5/26/2020 |
| 1.0.7 | 975 | 5/25/2020 |
| 1.0.6 | 719 | 5/25/2020 |
| 1.0.5 | 675 | 5/25/2020 |
| 1.0.2 | 679 | 5/25/2020 |
| 1.0.1 | 663 | 5/25/2020 |
Add .NET 10 support, remove .NET 7