# Tutorial - Create a Custom Theme Component

## Environment

| Product Version | Product         | Author                                                                          |
| --------------- | --------------- | ------------------------------------------------------------------------------- |
| 2022.3.913      | UI for WinForms | [Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova) |

## Description

This tutorial demonstrates a step by step tutorial on how to create a theme component and integrate your [custom theme](https://www.telerik.com/products/winforms/documentation/knowledge-base/customize-a-theme) inside the project. Thus, the theme will be available at design time as well.

## Solution

Follow the steps:

1\. Add a new Class Library project to your current solution.

![tutorial-custom-theme-component 001](https://www.telerik.com/products/winforms/documentation/assets/70b138e79bd7734285ab4fe94d9c9660/tutorial-custom-theme-component001.png)

![tutorial-custom-theme-component 002](https://www.telerik.com/products/winforms/documentation/assets/1cf3651385bc95b0aa7621f60cb063f9/tutorial-custom-theme-component002.png)

![tutorial-custom-theme-component 003](https://www.telerik.com/products/winforms/documentation/assets/dc94350b2da8036b824faf7d5b8926a7/tutorial-custom-theme-component003.png)

2\. Then, the custom .tssp file should be added to the Class Library.

> caution The custom .tssp file should be added with **Build Action - Embedded Resource**.

![tutorial-custom-theme-component 004](https://www.telerik.com/products/winforms/documentation/assets/f1ed01fca0d9255c5e78aadda1de8272/tutorial-custom-theme-component004.png)

3\. Add a new class to represent your theme component to the project:

```C#

public class CustomTheme : RadThemeComponentBase
{
    static bool loaded;
    public CustomTheme()
    {
        ThemeRepository.RegisterTheme(this);
    }
    public override void Load()
    {
        if (!loaded || this.IsDesignMode)
        {
            loaded = true;
            Assembly resourceAssembly = typeof(CustomTheme).Assembly;
            this.LoadResource(resourceAssembly, "ProjectDefaultNamespace.ContainingFolderName.CustomTheme.tssp");
        }
    }
    public override string ThemeName
    {
        get { return "CustomTheme"; }
    }
}

```

```VB.NET

Public Class CustomTheme
    Inherits RadThemeComponentBase
    Shared loaded As Boolean
    Public Sub New()
        ThemeRepository.RegisterTheme(Me)
    End Sub
    Public Overrides Sub Load()
        If Not loaded OrElse Me.IsDesignMode Then
            loaded = True
            Dim resourceAssembly As Assembly = GetType(CustomTheme).Assembly
            Me.LoadResource(resourceAssembly, "ProjectDefaultNamespace.ContainingFolderName.CustomTheme.tssp")
        End If
    End Sub
    Public Overrides ReadOnly Property ThemeName() As String
        Get
            Return "CustomTheme"
        End Get
    End Property
End Class

```

> caution Please make sure that the theme name in Visual Style Builder corresponds to the name you are returning in the theme component.

![tutorial-custom-theme-component 005](https://www.telerik.com/products/winforms/documentation/assets/2ae6cf12c3966ec4b483b6c72432e51e/tutorial-custom-theme-component005.png)

4\. Build the entire application. The theme component will be available in the toolbox. You will be able to drag this component to the forms in all the projects in your solution which will load the corresponding theme.

![tutorial-custom-theme-component 006](https://www.telerik.com/products/winforms/documentation/assets/6014d69571843a5f06d5e1fc78fc9fa8/tutorial-custom-theme-component006.png)

![tutorial-custom-theme-component 007](https://www.telerik.com/products/winforms/documentation/assets/c766fa9d65d6c504c4f8c2f6e9982a13/tutorial-custom-theme-component007.png)

## See Also

* [Creating a theme component](https://www.telerik.com/products/winforms/documentation/styling-and-appearance/advanced-topics/adding-custom-redistributable-themes-to-your-application/creating-a-theme-component)

* [How to Customize a Theme](https://www.telerik.com/products/winforms/documentation/knowledge-base/customize-a-theme)
