ColorPalette
Description
A grid of named colour swatches
ColorPalette displays a set of named swatches for picking from a predefined brand or theme palette. It's distinct from the raw ColorPicker which allows any colour — use ColorPalette when the set of valid choices is known in advance.
API reference
public sealed class ColorPalette : ComponentBase<ColorPalette, HTMLElement>A grid of named colour swatches for letting users pick from a predefined palette.
- Namespace
- Tesserae
- Inheritance
- ComponentBase<ColorPalette, HTMLElement> → ColorPalette
Constructors
| Name | Description |
|---|---|
| ColorPalette | Initializes a new instance of this class. |
Properties
| Name | Description |
|---|---|
| Value | Gets the currently selected hex color string. |
Methods
| Name | Description |
|---|---|
| Define | Configures the component to define. |
| AddSwatch | Adds a swatch with a label and hex color. |
| Swatches | Adds multiple swatches from an array of (label, hexColor) tuples. |
| SetValue | Selects a color by hex value programmatically. |
| WithCustomColor | Adds a "custom…" swatch that opens the browser color picker. |
| OnChange | Registers a callback for when the selected color changes. |
| Render | Renders the component's root HTML element. |
public static ColorAndLabel Define(string label, string color)Configures the component to define.
public ColorPalette AddSwatch(string label, string hexColor)Adds a swatch with a label and hex color.
public ColorPalette Swatches(params ColorAndLabel[] entries)Adds multiple swatches from an array of (label, hexColor) tuples.
public ColorPalette SetValue(string hexColor)Selects a color by hex value programmatically.
public ColorPalette WithCustomColor(bool value = true)Adds a "custom…" swatch that opens the browser color picker.
public ColorPalette OnChange(Action<string> onChange)Registers a callback for when the selected color changes.