Color Picker
Color selection with swatches, opacity, format options, and model binding.
<rhx-color-picker>
Examples
Basic
<rhx-color-picker name="color" rhx-label="Color" value="#3b82f6" />
With Swatches
<rhx-color-picker name="color-swatches" rhx-label="Brand Color"
value="#ef4444"
rhx-swatches="#ef4444,#f97316,#eab308,#22c55e,#3b82f6,#8b5cf6,#ec4899,#000000" />
With Opacity
<rhx-color-picker name="color-alpha" rhx-label="Overlay Color"
value="#3b82f6" rhx-opacity="true" />
Formats
<rhx-color-picker name="color-rgb" rhx-label="RGB Color"
value="#22c55e" rhx-format="rgb" />
<rhx-color-picker name="color-hsl" rhx-label="HSL Color"
value="#8b5cf6" rhx-format="hsl" />
Inline
<rhx-color-picker name="color-inline" rhx-label="Theme Color"
value="#f97316" rhx-inline="true"
rhx-swatches="#ef4444,#f97316,#eab308,#22c55e,#3b82f6,#8b5cf6" />
States
<rhx-color-picker name="color-dis" rhx-label="Disabled"
value="#6b7280" rhx-disabled="true" />
Model Binding
<rhx-color-picker rhx-for="BrandColor" rhx-label="Brand Color" />
htmx Integration
Pick a color to save...
<rhx-color-picker name="themeColor" rhx-label="Theme Color"
value="#3b82f6"
rhx-swatches="#ef4444,#f97316,#eab308,#22c55e,#3b82f6,#8b5cf6"
hx-post="/Docs/Components/ColorPicker?handler=SaveColor"
hx-trigger="change"
hx-target="#color-result"
hx-include="this" />
<div id="color-result">Pick a color to save...</div>
Properties
| Property | Type | Default | Description |
|---|---|---|---|
rhx-for |
ModelExpression |
- |
ASP.NET Core model expression for two-way binding |
name |
string |
- |
The form field name |
value |
string |
- |
The current color value (hex) |
rhx-label |
string |
- |
Label text |
rhx-format |
string |
hex |
Color format: hex, rgb, hsl |
rhx-swatches |
string |
- |
Comma-separated preset color values |
rhx-opacity |
bool |
false |
Show opacity/alpha slider |
rhx-inline |
bool |
false |
Always show the picker (no trigger button) |
rhx-disabled |
bool |
false |
Whether the color picker is disabled |
Accessibility
- Trigger button has an
aria-labeldescribing the current color value. - Keyboard navigation is supported within the swatch grid using arrow keys.
- The selected color value is announced to screen readers on change.
- Disabled state sets
aria-disabled="true"on the trigger.