tossnet / Blazor-Color-Picker

Opens a palette with the Material colors for Blazor application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Blazor-Color-Picker

NuGet BlazorColorPicker Nuget Package

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

Blazor Color Picker

Installation

Latest version in here: NuGet

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" />

Usage

@page "/"
@using BlazorColorPicker

<h1>Hello, world!</h1>

<button class="btn btn-primary" @onclick="OpenModal">
    <div style="background-color:@color" class="buttonColor"></div> Select a Color
</button>

<ColorPicker Title="My Blazor ColorPicker" IsOpened="isOpened" Closed="ClosedEvent" MyColor="@color">
</ColorPicker>

@code {
    bool isOpened = false;
    string color = "#F1F7E9";

    void OpenModal()
    {
        isOpened = true;
    }

    void ClosedEvent(string value)
    {
        color = value;
        isOpened = false;
    }
}

Release Notes

Version 2.2.0
  • Remove the internal use of IJSRuntime

⚠️ Breaking changes ⚠️

Version 2.1.0
  • no need to declare the _content/BlazorColorPicker/colorpicker.js file

About

Opens a palette with the Material colors for Blazor application

License:GNU General Public License v3.0


Languages

Language:C# 40.1%Language:CSS 33.7%Language:HTML 26.3%