|
| 1 | +--- |
| 2 | +title: Create a Custom Skin |
| 3 | +page_title: Create a Custom Skin | RadPushButton for ASP.NET AJAX Documentation |
| 4 | +description: Create a Custom Skin |
| 5 | +slug: pushbutton/appearance-and-styling/create-a-custom-skin |
| 6 | +tags: create,a,custom,skin |
| 7 | +published: True |
| 8 | +position: 3 |
| 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 one – **[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 the general case, 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 RadPushButton 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 have already 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 Light-Weight custom skins CSS will be placed; |
| 24 | + |
| 25 | +1. Go to **[ControlsInstallationFolder]\Skins\DefaultLite** and copy **Button.Default.css** in your **MyCustomSkinLite** folder; |
| 26 | + |
| 27 | +1. Go to **[TelerikControlsInstallationFolder]\Skins\Default** and copy **Common** folder in your **MyCustomSkin** folder; |
| 28 | + |
| 29 | +1. 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 **RadPushButton** on a single page, the wrapping skin-specific class is coined by 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 **RadPushButton** on your page, and set **Skin="MyCustomSkin"** and **EnableEmbeddedSkins="false"**: |
| 42 | + |
| 43 | +**ASP.NET** |
| 44 | + |
| 45 | +<telerik:RadPushButton ID="RadPushButton1" runat="server" EnableEmbeddedSkins="false" Skin="MyCustomSkin" /> |
| 46 | + |
| 47 | +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: |
| 48 | + |
| 49 | +**ASP.NET** |
| 50 | + |
| 51 | +<link href="Skins/MyCustomSkin/Button.MyCustomSkin.css" rel="stylesheet" type="text/css" /> |
| 52 | + |
| 53 | +1. Make sure the path to the files is correct; otherwise the skin will not apply; |
| 54 | + |
| 55 | +1. Reload the page, and if the steps 1-11 have been followed correctly, you will see **RadPushButton** running a custom Default skin set as an external resource. |
| 56 | + |
| 57 | +## Custom Skin Example |
| 58 | + |
| 59 | +Below is shown 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. |
| 60 | + |
| 61 | +````ASP.NET |
| 62 | +<!DOCTYPE html> |
| 63 | +
|
| 64 | +<html xmlns="http://www.w3.org/1999/xhtml"> |
| 65 | +<head runat="server"> |
| 66 | +<title></title> |
| 67 | +<style> |
| 68 | +/* Button normal state */ |
| 69 | +.RadButton.RadButton_Default.rbButton { |
| 70 | +background-color: #80078e; |
| 71 | +background-image: linear-gradient(#4f0258, #80078e 100%); |
| 72 | +border-color: #6b536e; |
| 73 | +color: #fff; |
| 74 | +} |
| 75 | +
|
| 76 | +/* Button hovered state */ |
| 77 | +.RadButton.RadButton_Default.rbButton.rbHovered { |
| 78 | +background-color: #660283; |
| 79 | +background-image: linear-gradient(#660283, #f2ddf8 100%); |
| 80 | +border-color: #47035a; |
| 81 | +color: #3a0470; |
| 82 | +} |
| 83 | +
|
| 84 | +</style> |
| 85 | +</head> |
| 86 | +<body> |
| 87 | +<form id="form1" runat="server"> |
| 88 | +<asp:ScriptManager runat="server"></asp:ScriptManager> |
| 89 | +<telerik:RadPushButton runat="server" Text="Button"></telerik:RadPushButton> |
| 90 | +<telerik:RadPushButton runat="server" Text="Icon Left"> |
| 91 | +<Icon CssClass="rbPrint" /> |
| 92 | +</telerik:RadPushButton> |
| 93 | +</form> |
| 94 | +</body> |
| 95 | +</html> |
| 96 | +```` |
| 97 | + |
| 98 | +## See Also |
| 99 | + |
| 100 | + * [Render Modes]({%slug pushbutton/mobile-support/render-modes%}) |
0 commit comments