Table of Contents

Class MudColorPicker

Namespace
MudBlazor
Assembly
MudBlazor.dll

Represents a sophisticated and customizable pop-up for choosing a color.

public class MudColorPicker : MudPicker<MudColor>, IComponent, IHandleEvent, IHandleAfterRender, IMudStateHasChanged, IFormComponent, IAsyncDisposable
Inheritance
MudColorPicker
Implements
Inherited Members
Extension Methods

Constructors

MudColorPicker()

public MudColorPicker()

Properties

CloseIcon

The custom icon to dislay for the close button.

[Parameter]
[Category("Picker appearance")]
public string CloseIcon { get; set; }

Property Value

string

Remarks

Defaults to Close.

ColorPickerMode

The initial color channels shown.

[Parameter]
[Category("Picker behavior")]
public ColorPickerMode ColorPickerMode { get; set; }

Property Value

ColorPickerMode

Remarks

Defaults to RGB. Other values are HEX for hexadecimal values and HSL for hue/saturation/lightness mode.

ColorPickerView

The initial view.

[Parameter]
[Category("Picker behavior")]
public ColorPickerView ColorPickerView { get; set; }

Property Value

ColorPickerView

Remarks

Defaults to Spectrum. The view can be changed if ShowToolbar is true.

DragEffect

Continues to update the selected color while the mouse button is down.

[Parameter]
[Category("Picker behavior")]
public bool DragEffect { get; set; }

Property Value

bool

Remarks

Defaults to true. When false, conditions like long latency are better supported and can be adjusted via the ThrottleInterval property.

GridIcon

The icon to display for the grid mode button.

[Parameter]
[Category("Picker appearance")]
public string GridIcon { get; set; }

Property Value

string

Remarks

Defaults to Apps.

ImportExportIcon

The icon to display for the import/export button.

[Parameter]
[Category("Picker appearance")]
public string ImportExportIcon { get; set; }

Property Value

string

Remarks

Defaults to ImportExport.

Palette

The list of quick colors to display.

[Parameter]
[Category("Picker behavior")]
public IEnumerable<MudColor> Palette { get; set; }

Property Value

IEnumerable<MudColor>

Remarks

Defaults to a list of 35 colors. The first five colors show as the quick colors when the preview dot is clicked.

PaletteIcon

The icon to display for the custom palette button.

[Parameter]
[Category("Picker appearance")]
public string PaletteIcon { get; set; }

Property Value

string

Remarks

Defaults to Palette.

PickerContent

Gets the content to be rendered inside the picker. Override this property to provide custom content for the picker.

protected override RenderFragment PickerContent { get; }

Property Value

RenderFragment

RightToLeft

[CascadingParameter(Name = "RightToLeft")]
public bool RightToLeft { get; set; }

Property Value

bool

ShowAlpha

Shows alpha transparency options.

[Parameter]
[Category("Picker behavior")]
public bool ShowAlpha { get; set; }

Property Value

bool

Remarks

Defaults to true. When true, alpha options will be displayed and color output will be RGBA, HSLA or HEXA instead of RGB, HSL or HEX.

ShowColorField

Displays the color field.

[Parameter]
[Category("Picker behavior")]
public bool ShowColorField { get; set; }

Property Value

bool

Remarks

Defaults to true.

ShowInputs

Displays the text inputs, current mode, and mode switch.

[Parameter]
[Category("Picker behavior")]
public bool ShowInputs { get; set; }

Property Value

bool

Remarks

Defaults to true.

ShowModeSwitch

Displays the switch to change the color mode.

[Parameter]
[Category("Picker behavior")]
public bool ShowModeSwitch { get; set; }

Property Value

bool

Remarks

Defaults to true.

ShowPreview

Displays a preview of the color.

[Parameter]
[Category("Picker behavior")]
public bool ShowPreview { get; set; }

Property Value

bool

Remarks

Defaults to true. When true, the preview color can be used as a button for collection colors.

ShowSliders

Displays hue and alpha sliders.

[Parameter]
[Category("Picker behavior")]
public bool ShowSliders { get; set; }

Property Value

bool

Remarks

Defaults to true.

SpectrumIcon

The icon to display for the spectrum mode button.

[Parameter]
[Category("Picker appearance")]
public string SpectrumIcon { get; set; }

Property Value

string

Remarks

Defaults to Tune.

ThrottleInterval

The delay, in milliseconds, between updates to the selected color when DragEffect is true.

[Parameter]
[Category("Picker behavior")]
public int ThrottleInterval { get; set; }

Property Value

int

Remarks

Defaults to 300 milliseconds between updates.

UpdateBindingIfOnlyHSLChanged

Limits updates to the bound value to when HSL values change.

[Parameter]
[Category("Behavior")]
public bool UpdateBindingIfOnlyHSLChanged { get; set; }

Property Value

bool

Remarks

Defaults to false. When true, the bound value changes when HSL values change, even if the RGB values have not changed.

Value

The currently selected color as a MudColor.

[Parameter]
[Category("Data")]
public MudColor? Value { get; set; }

Property Value

MudColor

Remarks

You can use properties in MudColor to get color channel values such as RGB, HSL, HEX and more. When this value changes, the ValueChanged event occurs.

ValueChanged

Occurs when the Value property has changed.

[Parameter]
public EventCallback<MudColor> ValueChanged { get; set; }

Property Value

EventCallback<MudColor>

Methods

BuildRenderTree(RenderTreeBuilder)

protected override void BuildRenderTree(RenderTreeBuilder __builder)

Parameters

__builder RenderTreeBuilder

ChangeMode()

Refreshes the current color change mode.

public void ChangeMode()

ChangeView(ColorPickerView)

Changes to the specified color selection view.

public void ChangeView(ColorPickerView value)

Parameters

value ColorPickerView

The new view to display.

OnInitialized()

protected override void OnInitialized()

SetAlpha(double)

Sets the transparency channel of the selected color.

public void SetAlpha(double value)

Parameters

value double

A value between 0.0 (fully transparent) and 1.0 (solid).

SetAlpha(int)

Sets the transparency channel of the selected color.

public void SetAlpha(int value)

Parameters

value int

A value between 0 (fully transparent) and 1 (solid).

SetB(int)

Sets the blue channel of the selected color.

public void SetB(int value)

Parameters

value int

A value between 0 (no blue) and 255 (max blue).

Remarks

Often used with SetR(int) and SetG(int).

SetG(int)

Sets the green channel of the selected color.

public void SetG(int value)

Parameters

value int

A value between 0 (no green) and 255 (max green).

Remarks

Often used with SetR(int) and SetB(int).

SetH(double)

Sets the hue channel of the selected color.

public void SetH(double value)

Parameters

value double

A value between 0.0 and 360.0, in degrees.

Remarks

Often used with SetS(double) and SetL(double).

SetInputString(string?)

Sets the selected color to the specified value.

public void SetInputString(string? input)

Parameters

input string

A string value formatted as hexadecimal (#FF0000), RGB (rgb(255,0,0)), or RGBA (rgba(255,0,0,255).

SetL(double)

Sets the lightness channel of the selected color.

public void SetL(double value)

Parameters

value double

A value between 0.0 (darkest/black) and 1.0 (brightest/white).

Remarks

Often used with SetH(double) and SetS(double).

SetR(int)

Sets the red channel of the selected color.

public void SetR(int value)

Parameters

value int

A value between 0 (no red) and 255 (max red).

Remarks

Often used with SetG(int) and SetB(int).

SetS(double)

Sets the saturation channel of the selected color.

public void SetS(double value)

Parameters

value double

A value between 0.0 (no saturation) and 1.0 (max saturation).

Remarks

Often used with SetH(double) and SetL(double).

StringValueChangedAsync(string?)

Occurs when the string value has changed.

protected override Task StringValueChangedAsync(string? value)

Parameters

value string

Returns

Task