Forms
TwColorPicker
TwColorPicker is a Blazor colour picker component. Bind Value, choose an OutputFormat, and toggle ShowAlpha and ShowModeSwitch. Supports input variants.
Last updated
Basic Color Picker
Bind
Value to let users pick a color from a labeled color picker input.With Mode Switch
Set
ShowModeSwitch to let users toggle between color input modes (e.g. hex and RGB).With Alpha Channel
Set
ShowAlpha to add an alpha channel slider for transparency.Input Variants
Use the
Variant property to switch between default, outlined and filled input styles.Dense Color Picker
Set
Dense for a more compact input with a smaller height and text size. Every single-line input shares the same dense height, so they line up when used side by side.Razor
<TwColorPicker Label="Dense Color" @bind-Value="PrimaryColor" Dense />Disabled State
Use the
Disabled property to prevent interaction with the color picker.Razor
<TwColorPicker Label="Disabled Color" Value="#cccccc" Disabled />Output Format
Use
OutputFormat to control whether the bound value is emitted as hex or RGB, regardless of the input format.Value: #3b82f6
Value: rgba(16, 185, 129, 0.8)
Value: hsl(262, 83%, 58%)
Theme Configuration
Styling is controlled by
TwBlazorTheme.Components (a TwColorPickerTheme), configured via the
AddTwBlazor() options callback described on the Get Started page.
Every property is a set of Tailwind classes, so changes are picked up by your own Tailwind build.
| Property | Type | Controls |
|---|---|---|
Swatch |
string | |
SwatchDisabled |
string | |
SwatchHover |
string | |
InputContainer |
string | |
DialogPosition |
string | |
PreviewSwatch |
string | |
SelectorSquare |
string | |
SelectorThumb |
string | |
SliderTrack |
string | |
SliderThumb |
string | |
AlphaLabel |
string | |
ActionBar |
string | |
ControlRow |
string | |
Body |
string | |
SliderRow |
string | |
HueSliderTouch |
string | |
InputColumn |
string | |
ModeSwitchButton |
string | |
AlphaReadoutAlign |
string |
Full reference: TwColorPickerTheme on the API docs.