|
| 1 | +--- |
| 2 | +title: Overview |
| 3 | +page_title: Color Palette Overview |
| 4 | +description: Overview of the Color Palette for Blazor. |
| 5 | +slug: colorpalette-overview |
| 6 | +tags: telerik,blazor,masked,Color,Palette,overview |
| 7 | +published: True |
| 8 | +position: 0 |
| 9 | +--- |
| 10 | + |
| 11 | +# Color Palette Overview |
| 12 | + |
| 13 | +The <a href = "https://www.telerik.com/blazor-ui/colorpalette" target="_blank">Blazor Color Palette component</a> provides a list of color tiles for the user to pick a color from by clicking or tapping. You can choose a [predefined list of colors]({%slug colorpalette-presets%}), or [create your own]({%slug colorpalette-custom-colors%}). Two-way binding and [events]({%slug colorpalette-events%}) let you react to the user choice. |
| 14 | + |
| 15 | +## Basics |
| 16 | + |
| 17 | +To use a Telerik Color Palette for Blazor: |
| 18 | + |
| 19 | +1. Add the `<TelerikColorPalette>` tag. |
| 20 | +1. Bind its `Value` to the `string` you want to get out of it. |
| 21 | +1. Optionally, choose a list of `Colors` to show the user (one of the [presets we provide]({%slug colorpalette-presets%}), or a set of [custom colors]({%slug colorpalette-custom-colors%})). |
| 22 | + * If you do not provide a value for the `Colors`, it will default to the `Office` [preset]({%slug colorpalette-presets%}). |
| 23 | + |
| 24 | +>caption Basic color palette with two-way value binding and a default predefined palette |
| 25 | +
|
| 26 | +````CSHTML |
| 27 | +<span style="color: @MyColor">@MyColor</span> |
| 28 | +<br /> |
| 29 | +
|
| 30 | +<TelerikColorPalette @bind-Value="@MyColor"> |
| 31 | +</TelerikColorPalette> |
| 32 | +
|
| 33 | +@code { |
| 34 | + public string MyColor { get; set; } |
| 35 | +} |
| 36 | +```` |
| 37 | + |
| 38 | +>caption The result from the code snippet above after selecting a color |
| 39 | +
|
| 40 | + |
| 41 | + |
| 42 | +## Appearance |
| 43 | + |
| 44 | +You can control the appearane of the component not only through the lists of `Colors` you provide to it, but also its size through the `Columns`, `TileWidth` and `TileHeight` parameters. |
| 45 | + |
| 46 | +>caption Make a large color palette with few columns |
| 47 | +
|
| 48 | +````CSHTML |
| 49 | +@SelectedColor |
| 50 | +<TelerikColorPalette Colors="@ColorPalettePresets.Basic" @bind-Value="@SelectedColor" |
| 51 | + Columns="5" TileHeight="3em" TileWidth="3em"> |
| 52 | +</TelerikColorPalette> |
| 53 | +@code{ |
| 54 | + string SelectedColor { get; set; } |
| 55 | +} |
| 56 | +```` |
| 57 | + |
| 58 | +>caption Theresult from the code snippet above |
| 59 | +
|
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | +## Component Reference |
| 65 | + |
| 66 | +````CSHTML |
| 67 | +<TelerikColorPalette @ref="@TheColorPaletteRef"></TelerikColorPalette> |
| 68 | +
|
| 69 | +@code{ |
| 70 | + Telerik.Blazor.Components.TelerikColorPalette TheColorPaletteRef { get; set; } |
| 71 | +} |
| 72 | +```` |
| 73 | + |
| 74 | +## Features |
| 75 | + |
| 76 | +>caption The Color Palette provides the following features: |
| 77 | +
|
| 78 | +* `Class` - the CSS class that will be rendered on the wrapping element of the component. |
| 79 | + |
| 80 | +* `Colors` - the collection of colors the user can choose from. Can be one of the [presets that come with the component]({%slug colorpalette-presets%}), or [a custom list]({%slug colorpalette-custom-colors%}). |
| 81 | + |
| 82 | +* `Columns` - the number of columns to use when rendering the Colors list. Determines the size of the component together with the `TileHeight` and `TileWidth`. |
| 83 | + |
| 84 | +* `Enabled` - whether the component is enabled. |
| 85 | + |
| 86 | +* `Id` - renders as the `id` attribute on the wrapping element of the component. |
| 87 | + |
| 88 | +* `TabIndex` - maps to the `tabindex` attribute of the main HTML element. You can use it to customize the order in which the elements in your page focus with the `Tab` key. |
| 89 | + |
| 90 | +* `TileHeight` - the height of each individual color item. Determines the size of the component together with the `Columns` and `TileWidth`. Can take CSS [dimensions]({%slug common-features/dimensions%}) strings |
| 91 | + |
| 92 | +* `TileWidth`- the width of each individual color item. Determines the size of the component together with the `Columns` and `TileHeight`. Can take CSS [dimensions]({%slug common-features/dimensions%}) strings |
| 93 | + |
| 94 | +* `Value` - get/set the value of the input, can be used for binding. Can take any string that can be a [CSS background-color string](https://css-tricks.com/almanac/properties/b/background-color/). The presets we provide use hex format (`#123abc`). |
| 95 | + |
| 96 | +* [Events]({%slug colorpalette-events%}) to let you react to the user actions. |
| 97 | + |
| 98 | +* Validation - see the [Input Validation]({%slug common-features/input-validation%}) article. |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | +## See Also |
| 105 | + |
| 106 | + * [Live Demo: Color Palette](https://demos.telerik.com/blazor-ui/colorpalette/overview) |
| 107 | + * [Color Presets]({%slug colorpalette-presets%}) |
| 108 | + * [Custom Color Collections]({%slug colorpalette-custom-colors%}) |
| 109 | + * [API Reference](https://docs.telerik.com/blazor-ui/api/Telerik.Blazor.Components.TelerikColorPalette) |
0 commit comments