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
Remarks
Defaults to Close.
ColorPickerMode
The initial color channels shown.
[Parameter]
[Category("Picker behavior")]
public ColorPickerMode ColorPickerMode { get; set; }
Property Value
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
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
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
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
Remarks
Defaults to ImportExport.
Palette
The list of quick colors to display.
[Parameter]
[Category("Picker behavior")]
public IEnumerable<MudColor> Palette { get; set; }
Property Value
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
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
RightToLeft
[CascadingParameter(Name = "RightToLeft")]
public bool RightToLeft { get; set; }
Property Value
ShowAlpha
Shows alpha transparency options.
[Parameter]
[Category("Picker behavior")]
public bool ShowAlpha { get; set; }
Property Value
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
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
Remarks
Defaults to true
.
ShowModeSwitch
Displays the switch to change the color mode.
[Parameter]
[Category("Picker behavior")]
public bool ShowModeSwitch { get; set; }
Property Value
Remarks
Defaults to true
.
ShowPreview
Displays a preview of the color.
[Parameter]
[Category("Picker behavior")]
public bool ShowPreview { get; set; }
Property Value
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
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
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
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
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
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
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
ColorPickerViewThe 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
doubleA value between
0.0
(fully transparent) and1.0
(solid).
SetAlpha(int)
Sets the transparency channel of the selected color.
public void SetAlpha(int value)
Parameters
value
intA value between
0
(fully transparent) and1
(solid).
SetB(int)
Sets the blue channel of the selected color.
public void SetB(int value)
Parameters
value
intA value between
0
(no blue) and255
(max blue).
Remarks
SetG(int)
Sets the green channel of the selected color.
public void SetG(int value)
Parameters
value
intA value between
0
(no green) and255
(max green).
Remarks
SetH(double)
Sets the hue channel of the selected color.
public void SetH(double value)
Parameters
value
doubleA value between
0.0
and360.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
stringA 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
doubleA value between
0.0
(darkest/black) and1.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
intA value between
0
(no red) and255
(max red).
Remarks
SetS(double)
Sets the saturation channel of the selected color.
public void SetS(double value)
Parameters
value
doubleA value between
0.0
(no saturation) and1.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