|
| 1 | +--- |
| 2 | +title: Create a Custom Skin |
| 3 | +page_title: Create a Custom Skin | RadCheckBoxList for ASP.NET AJAX Documentation |
| 4 | +description: Create a Custom Skin |
| 5 | +slug: checkboxlist/appearance-and-styling/create-a-custom-skin |
| 6 | +tags: create,a,custom,skin |
| 7 | +published: True |
| 8 | +position: 1 |
| 9 | +--- |
| 10 | + |
| 11 | +# Create a Custom Skin |
| 12 | + |
| 13 | +Each of the controls included in the **Telerik UI for ASP.NET AJAX** suite is styled with two CSS files that are loaded in a certain order. The first file – **[ControlName].css** , also called base stylesheet, contains CSS properties and values that are common for all skins, i.e., it is layout-specific, not skin-specific. These are CSS float, padding, margin, font-size, font-family, etc. In general, when creating a custom skin for a control, this file should not be edited unless the custom skin needs different sizes, padding and / or margins. |
| 14 | + |
| 15 | +The second file represents the actual skin of the control, and its name consists of the control name plus the skin name, e.g., **Button.Default.css**. Upon creating a custom skin for the control, one should edit that particular file, as it contains skin-specific CSS properties and references to images, colors, borders and backgrounds. |
| 16 | + |
| 17 | +## Create a RadCheckBoxList Skin from an Existing One |
| 18 | + |
| 19 | +1. In your project, create a new directory named **Skins**; |
| 20 | + |
| 21 | +1. In the **Skins** folder if you already have some custom skin, most probably you already have a folder named: **MyCustomSkin** – if you don’t – create one; |
| 22 | + |
| 23 | +1. In the **Skins** folder, create a new folder named: **MyCustomSkinLite** - this is the place where your Lightweight custom skins CSS will be placed; |
| 24 | + |
| 25 | +1. Go to **[ControlsInstallationFolder]\Skins\DefaultLite** and copy **Button.Default.css** into your **MyCustomSkinLite** folder; |
| 26 | + |
| 27 | +1. Go to **[TelerikControlsInstallationFolder]\Skins\Default** and copy the **Common** folder into your **MyCustomSkin** folder; |
| 28 | + |
| 29 | +1. In your your **MyCustomSkinLite** folder, rename **Button.Default.css** to **Button.MyCustomSkin.css**; |
| 30 | + |
| 31 | +1. When you are finished you should have the following folder structure in your project: |
| 32 | + |
| 33 | + 1. **Skins/MyCustomSkin/Common/** - containing several sprites; |
| 34 | + |
| 35 | + 1. **Skins/MyCustomSkinLite/Button.MyCustomSkin.css**. |
| 36 | + |
| 37 | +1. In order to support multiple skins of **RadCheckBoxList** on a single page, the wrapping skin-specific class is created using the name of the control, plus underscore ("_") plus SkinName, i.e., **.RadButton_Default**, so in order to create a custom skin out of the Default skin, we should rename all occurrences of **"RadButton_Default"** in **Button.MyCustomSkin.css** to **"RadButton_MyCustomSkin"** as shown below: |
| 38 | + |
| 39 | +  |
| 40 | + |
| 41 | +1. Add a new server declaration of **RadCheckBoxList** on your page and set **Skin="MyCustomSkin"** and **EnableEmbeddedSkins="false"**: |
| 42 | + |
| 43 | + **ASP.NET** |
| 44 | + |
| 45 | + <telerik:RadCheckBoxList runat="server" ID="RadCheckBoxList1" Skin="MyCustomSkin" EnableEmbeddedSkins="false"> |
| 46 | + </telerik:RadCheckBoxList> |
| 47 | + |
| 48 | +1. Register **Button.MyCustomSkin.css** in the head section of your web page. In order to have the CSS applied correctly, the base stylesheet should come first in the DOM: |
| 49 | + |
| 50 | + **ASP.NET** |
| 51 | + |
| 52 | + <link href="Skins/MyCustomSkinLite/Button.MyCustomSkin.css" rel="stylesheet" type="text/css" /> |
| 53 | + |
| 54 | +1. Make sure the path to the files is correct; otherwise the skin will not apply; |
| 55 | + |
| 56 | +1. Reload the page, and if the steps 1-11 have been followed correctly, you will see **RadCheckBoxList** running a custom Default skin set as an external resource. |
| 57 | + |
| 58 | +## Custom Skin Example |
| 59 | + |
| 60 | +The example below shows how to modify the CSS in order not only to change some colors and background colors, but also some base layout settings such as font size, element height, border-radius, etc. |
| 61 | + |
| 62 | +````ASP.NET |
| 63 | +<!DOCTYPE html> |
| 64 | +
|
| 65 | +<html xmlns="http://www.w3.org/1999/xhtml"> |
| 66 | +<head id="Head1" runat="server"> |
| 67 | + <title></title> |
| 68 | + <style> |
| 69 | + /* Checkbox normal state */ |
| 70 | + html .RadButton_Default.rbCheckBox .rbIcon, |
| 71 | + html .RadButton_Default.rbCheckBox .rbText { |
| 72 | + color: #80078e; |
| 73 | + } |
| 74 | +
|
| 75 | + /* Checkbox hovered state */ |
| 76 | + html .RadButton_Default.rbCheckBox.rbHovered .rbIcon, |
| 77 | + html .RadButton_Default.rbCheckBox.rbHovered .rbText { |
| 78 | + color: #3a0470; |
| 79 | + } |
| 80 | + </style> |
| 81 | +</head> |
| 82 | +<body> |
| 83 | + <form id="form1" runat="server"> |
| 84 | + <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> |
| 85 | + <telerik:RadCheckBoxList runat="server" ID="RadCheckBoxList1" Text="Check here"> |
| 86 | + </telerik:RadCheckBoxList> |
| 87 | + </form> |
| 88 | +</body> |
| 89 | +</html> |
| 90 | +```` |
| 91 | + |
| 92 | +## See Also |
| 93 | + |
| 94 | + * [Render Modes]({%slug checkboxlist/mobile-support/render-modes%}) |
0 commit comments