DeepWorks Studios Blazor Component Library

Demo user Administrator ยท Blazor Server Library 20261206222504-6e8ff32.dirty

DwsColorPicker

API Reference

Disabled

Disabled blocks typing and the dialog. In permission-selection mode the picker is selected by a click on its frame.

Show Code
ColorPicker.razor

<DwsColorPicker Name="ColorPickerDemo_Disabled" Label="Disabled" RawValue="#4C26A5" Disabled="true" Tooltip="The field is disabled" />

Read-only

Readonly blocks typing and the dialog too, but still shows the value.

Show Code
ColorPicker.razor

<DwsColorPicker Name="ColorPickerDemo_Readonly" Label="Read-only" RawValue="#30D5C8" Readonly="true" Tooltip="The value is visible but not editable" />

The native dialog

PickerType Native opens the browser's own colour dialog instead of the panel (opaque colours only; the opacity a value has is kept).

Show Code
ColorPicker.razor

<DwsColorPicker Name="ColorPickerDemo_Native" Label="Native dialog" PickerType="DwsColorPickerType.Native"
                Behavior="DwsPickerBehavior.EditableDialog" @bind-RawValue="@_nativeColor" />

@code {
    private string _nativeColor = "#E91E63";
}

Without the colour name

Every picker names its colour in words next to the label ('dark blue', localized; it is the field's description for screen readers, and the panel announces the colour being edited) - ShowColorName=false switches that off.

Show Code
ColorPicker.razor

<DwsColorPicker Name="ColorPickerDemo_NoColorName" Label="Without the colour name" RawValue="#1E3A8A" ShowColorName="false" />

Interface-Description

Name Typ Default Description
IsOpen bool false Whether the palette panel is open.
DefaultPalette IReadOnlyList<string> 20 colours Static: the predefined colours used when Palette is not set.
DefaultGradientPalette IReadOnlyList<string> 6 gradients Static: the predefined gradients used when GradientPalette is not set.
Name Typ Parameters Description
OpenAsync Task Opens the panel (or the native dialog). Focus stays where it is; the keyboard shortcuts on the field also move focus into the panel. Does nothing while disabled, read-only, in permission-selection mode or with OnlyEditable.
CloseAsync Task Closes the panel, discarding changes OK has not applied.
ClearAsync Task Clears the value and raises the change callbacks as a user change would.
Name Typ Default Description
Value Color? null The colour as System.Drawing.Color, alpha channel included. Supports @bind-Value. Ignored in gradient mode.
RawValue string? string.Empty The value as text in Format (or the CSS gradient in gradient mode). Supports @bind-RawValue. Every format is accepted as input; invalid text keeps the last valid value.
Gradient DwsColorGradient? null The gradient edited in Mode Gradient. Supports @bind-Gradient.
Mode DwsColorPickerMode Color Color edits a single colour, Gradient a CSS gradient of two or more stops (always with the palette panel).
Format DwsColorFormat Hex Text format of the field and RawValue: Hex, Rgb, Hsl, Hsv or Cmyk. Hsv and Cmyk are not CSS colours; gradient stops use hex for them.
EnableAlpha bool false Shows the opacity slider and input and keeps the alpha of typed values. When off, user input is made opaque.
PickerType DwsColorPickerType Palette Palette opens the library's panel, Native the browser's colour dialog (opaque colours only).
Behavior DwsPickerBehavior OnlyDialog OnlyDialog: a click on the field (or Enter, Space, Arrow Down) opens the dialog; Alt+Arrow Down opens it with every dialog behaviour. EditableDialog: typing, plus double-click or the swatch button for the dialog. OnlyEditable: typing only.
ShowColorArea bool true Panel: the HSV picker (saturation/brightness area and hue slider).
ShowChannelInputs bool true Panel: the RGBA picker (hex and channel inputs).
ShowPalette bool true Panel: the predefined colours, and the predefined gradients in gradient mode.
ShowOkButton bool true Panel: OK and Cancel. With them changes apply on OK; without them every change applies at once.
Palette IReadOnlyList<string>? null (DefaultPalette) The predefined colours in any supported format. Invalid entries are skipped and logged.
GradientPalette IReadOnlyList<string>? null (DefaultGradientPalette) The predefined CSS gradients shown in gradient mode.
PanelWidth int? 280 Width of the panel in px.
Placement DwsPopoverPlacement BottomStart Where the panel opens; it flips when there is no room.
Label string string.Empty Floating label of the field.
Icon string Icons.BS.Palette Icon before the label; empty shows none.
Tooltip string string.Empty Tooltip of the picker.
TooltipPosition DwsTooltipPosition Top Kept so existing markup still compiles: the tooltip is the browser's native title, which has no position.
Readonly bool false Shows the value but blocks typing and the dialog.
ShowValidationMessage bool true Shows a message under the field when the text is not a valid colour.
AllowClear bool false Shows a button in the field that clears the value (also with OnlyDialog, where typing is blocked).
ShowEyeDropper bool true Panel: an eyedropper button that picks a colour from the screen, in browsers with the EyeDropper API (Chromium-based); hidden elsewhere.
ShowColorName bool true Shows the name of the nearest basic colour ("dark blue", localized; with the opacity for a partly transparent colour) next to the field's label, where it is also the field's description for screen readers, and in the palette panel, where it is announced as the colour changes. Not shown for gradients.
Haptic DwsHapticFeedback DwsHapticFeedback.Selection Tactile feedback for a tap on a palette colour or gradient, while the app has haptics switched on (IDwsHapticService). OK and the clear button play a light tap unless this is None. Played inside the tap, so it works on iOS too.
ContrastAgainst Color? null The colour the picked colour is used with (the background its text stands on, or the text on a picked background). With it set the panel shows the WCAG contrast ratio and whether it meets AA / AAA for normal and large text; the verdict is announced politely. A translucent picked colour is measured as it lies on this one.
ShowContrast bool true Shows the contrast check in the panel when ContrastAgainst is set. Not shown for a gradient.
RawValueExpression Expression<Func<string?>>? null The bound text, set by @bind-RawValue. Under static SSR the picker is the browser's colour input named after it (Model.Accent), which a static form posts as #rrggbb.
Name Typ Description
ValueChanged EventCallback<Color?> Raised when the user changes the colour.
RawValueChanged EventCallback<string> Raised with the new value as text in Format (colour or gradient), and again in the new format when Format changes while RawValue is bound.
GradientChanged EventCallback<DwsColorGradient?> Raised when the user changes the gradient.
OnInvalidValue EventCallback<string> Raised with text (typed or passed) that is not a valid colour or gradient.
OnFocus EventCallback<FocusEventArgs> Raised when the text field gets focus.
OnBlur EventCallback<FocusEventArgs> Raised when the text field loses focus.
OnOpen EventCallback Raised when the panel has opened.
OnClose EventCallback<bool> Raised when the panel has closed; true when OK applied the changes.
Name Typ Default Description
Element ElementReference The associated web component. May be null if accessed before the component is rendered.
ComponentGuid Guid Unique identifier for the component.
TypeString string The name of the component type, obtained from reflection.
Authorized_RegisterEnabled bool false Indicates whether this component is enabled through a permission registry.
Authorized_RegisterSelected bool false Indicates whether this component is selected in permission selection mode.
GetInitializedState bool false Returns whether the component is initialized.
GetRenderModeState DwsRenderMode Returns the current render mode.
GetComponentState DwsComponentStateType Returns the current component state.
GetIsInteractiveState bool false Returns whether the component is interactive.
GetIsPrerenderingState bool false Returns whether the component is prerendering.
GetComponentLoadingState bool false Returns whether the component is loading.
IsFormBusy bool false Whether the DwsForm (or DwsFormBusyRegion) around the component is locked because its submit handler is running. The state itself is the cascaded FormBusyState (IDwsFormBusyState).
Name Typ Parameters Description
DebugInfo void Logs debug information about the component.
UpdateState void Updates the component's state and triggers StateHasChanged.
UpdateStateAsync Task Asynchronously updates the component's state and triggers StateHasChanged.
Dispose void Disposes the component and releases resources.
FocusAsync ValueTask bool containedInScrollableList Sets focus to the component's element.
Name Typ Default Description
Name string Required unique identifier for the component within its container.
Visible bool true Determines if the component is visible in the UI.
Disabled bool false Disables the form control, ensuring it doesn't participate in form submission.
ComponentNameSpace string The namespace for permission-based access control.
PermissionKey string? null A stable key that takes the place of Name in the generated permission namespace (Page.PermissionKey): the stored permission survives a rename, and components that share a key share one permission entry. Null: keyed by Name. Read once, when the component registers; an explicit ComponentNameSpace wins.
Class string Optional CSS class names.
Style string Optional in-line styles.
Tag object An optional user-defined object to store any additional data with the component.
BackReference DwsReference A reference to the enclosing component.
ID string The HTML ID attribute for the component.
AdditionalAttributes Dictionary<string, object> Additional HTML attributes for the component's root element.
IgnorePermissionChecks bool false Bypasses all permission checks for this component.
IgnorePermissionSelection bool false Ignore permission selection mode for this component.
IgnoreFormBusy bool false Takes the component out of the submit lock of the DwsForm (or DwsFormBusyRegion) around it: IsFormBusy stays false for it.
Name Typ Description
OnInitializedCallbackStarted EventCallback Callback when OnInitialized starts.
OnInitializedCallback EventCallback Callback during OnInitialized.
OnInitializedCallbackCompleted EventCallback Callback when OnInitialized completes.
OnInitializedAsyncCallbackStarted EventCallback Callback when OnInitializedAsync starts.
OnInitializedAsyncCallback EventCallback Callback during OnInitializedAsync.
OnInitializedAsyncCallbackCompleted EventCallback Callback when OnInitializedAsync completes.
OnIsComponentLoadingChanged EventCallback<bool> Callback when IsComponentLoading changes.
OnCurrentRenderModeChanged EventCallback<DwsRenderMode> Callback when CurrentRenderMode changes.
OnComponentStateChanged EventCallback<DwsComponentStateType> Callback when ComponentState changes.
An error has occurred. This app may no longer respond until reloaded.