|
| 1 | +--- |
| 2 | +title: Overview |
| 3 | +page_title: Overview | FlatColorPicker for Blazor |
| 4 | +description: Overview of the FlatColorPicker for Blazor. |
| 5 | +slug: flatcolorpicker-overview |
| 6 | +tags: telerik,blazor,flatcolorpicker,overview |
| 7 | +published: True |
| 8 | +position: 0 |
| 9 | +--- |
| 10 | + |
| 11 | +# FlatColorPicker Overview |
| 12 | + |
| 13 | +The <a href = "https://www.telerik.com/blazor-ui/flatcolorpicker" target="_blank">FlatColorPicker for Blazor</a> is an interactive component that allows color selection from a color palette or a [HSVA](https://en.wikipedia.org/wiki/HSL_and_HSV) canvas. Users can also type a specific RGB/HEX color value manually. The FlatColorPicker is practically identical to the [ColorPicker component]({%slug colorpicker-overview%}) with the only difference that the ColorPicker takes up less space and displays the color selection UI in a popup. |
| 14 | + |
| 15 | +#### In this article: |
| 16 | + * [Basics](#basics) |
| 17 | + * [Example](#example) |
| 18 | + * [Interface](#interface) |
| 19 | + * [Features](#features) |
| 20 | + * [Supported Value Formats](#supported-value-formats) |
| 21 | + |
| 22 | +## Basics |
| 23 | + |
| 24 | +To use a Telerik FlatColorPicker for Blazor: |
| 25 | + |
| 26 | +1. Add the `TelerikFlatColorPicker` tag. |
| 27 | +1. Set its `Value` attribute to any of the [supported HEX/RGB formats](#supported-value-formats). Use a `string` property with [one-way]({%slug flatcolorpicker-events%}#valuechanged) or [two-way](#example) binding. |
| 28 | +1. (optional) Set the `ValueFormat` to `ColorFormat.Hex` or `ColorFormat.Rgb` if the app expects a specific color format. |
| 29 | + |
| 30 | +## Example |
| 31 | + |
| 32 | +Here is a simple FlatColorPicker declaration and the resulting UI. |
| 33 | + |
| 34 | +````CSHTML |
| 35 | +@* Blazor FlatColorPicker *@ |
| 36 | +
|
| 37 | +<TelerikFlatColorPicker @bind-Value="@Color" /> |
| 38 | +
|
| 39 | +@code { |
| 40 | + string Color { get; set; } = "rgb(40, 47, 137)"; |
| 41 | +} |
| 42 | +```` |
| 43 | + |
| 44 | +## Interface |
| 45 | + |
| 46 | +The image below reveals all FlatColorPicker interface elements: |
| 47 | + |
| 48 | +* View selectors (top left) |
| 49 | +* Color preview box (top right) |
| 50 | +* Current color box (below the color preview) |
| 51 | +* Clear button (top) |
| 52 | +* Palette tiles or HSV canvas with hue and opacity sliders (middle) |
| 53 | +* RGBA or HEX value textboxes with a toggle button (bottom) |
| 54 | +* Apply and Cancel buttons (bottom) |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | +## Features |
| 59 | + |
| 60 | +The FlatColorPicker tag exposes the following features via its attributes: |
| 61 | + |
| 62 | +* `Value` - `string` - sets the FlatColorPicker value in a few [different color formats](#supported-value-formats). Supports two-way binding. |
| 63 | +* `ValueFormat` - `ColorFormat` - sets the color format, which the component will return in the application code. By default, the property is not set and the value format will change depending on the used view: `Rgb` when selecting a color from the GradientView, and `Hex` when selecting a color from the PaletteView. |
| 64 | +* `FlatColorPickerViews` - `RenderFragment` - a nested container to list the [FlatColorPicker views]({%slug flatcolorpicker-views%}). All views are enabled by default and the user can switch between them with buttons. Each view tag has its own configuration attributes. |
| 65 | +* `View` - `ColorPickerView` - sets the default selected [view]({%slug flatcolorpicker-views%}) (`ColorPickerView.Gradient` by default). Supports two-way binding. |
| 66 | +* `ShowPreview` - `bool` - toggles the [current color box and the color preview box](#interface) in the popup (`true` by default). |
| 67 | + |
| 68 | +* `Class` - `string` - renders a custom CSS class to the `div.k-flatcolorpicker` element. |
| 69 | +* `Enabled` - `bool` - determines if the user can open the popup and change the value (`true` by default). |
| 70 | + |
| 71 | +### Buttons |
| 72 | + |
| 73 | +* `ShowButtons` - `bool` - sets the visibility of the Apply and Cancel buttons (`true` by default). |
| 74 | +* `ShowClearButton` - `bool` - sets the visibility of the Clear button. |
| 75 | + |
| 76 | +## Supported Value Formats |
| 77 | + |
| 78 | +The FlatColorPicker accepts values by the application code in the following formats: |
| 79 | + |
| 80 | +@[template](/_contentTemplates/common/coloreditors.md#value-formats) |
| 81 | + |
| 82 | +Color keywords are not supported. |
| 83 | + |
| 84 | +## See Also |
| 85 | + |
| 86 | +* [FlatColorPicker Views]({%slug flatcolorpicker-views%}) |
| 87 | +* [FlatColorPicker Events]({%slug flatcolorpicker-events%}) |
| 88 | +* [FlatColorPicker Live Demo](https://demos.telerik.com/blazor-ui/flatcolorpicker/overview) |
0 commit comments