Back to Devexpress

DxThemeBase<TProps>.Clone(Action<TProps>) Method

blazor-devexpress-dot-blazor-dot-dxthemebase-1-dot-clone-x28-system-dot-action-0-x29.md

latest3.2 KB
Original Source

DxThemeBase<TProps>.Clone(Action<TProps>) Method

Clones a built-in DevExpress Blazor theme or applies a Bootstrap external theme.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.Resources.v25.2.dll

NuGet Package : DevExpress.Blazor.Resources

Declaration

csharp
public ITheme Clone(
    Action<TProps> modifier
)

Parameters

NameTypeDescription
modifierAction<TProps>

A delegate method that configures theme properties.

|

Returns

TypeDescription
ITheme

The theme.

|

Remarks

Call the RegisterTheme(ITheme) method in the App.razor file to register a theme in your Blazor application. You can choose a theme from the built-in theme collection or create a new theme using the Clone() method.

The Clone method accepts theme properties as a parameter:

Note

Bootstrap themes require theme-specific stylesheets. Once you pass the BootstrapExternal option to the RegisterTheme method, call the Clone method and add an appropriate stylesheet using theme properties.

razor
<head>
    @*...*@
    @DxResourceManager.RegisterTheme(Themes.OfficeWhite.Clone(properties => {
        properties.Name = "Office White Custom";
        properties.AddFilePaths("css/OWCustomStyles.css")
    }))
</head>
razor
<head>
    @*...*@
    @DxResourceManager.RegisterTheme(Themes.BootstrapExternal.Clone(properties => {
        properties.Name = "Pulse Bootswatch";
        properties.AddFilePaths("css/pulse/bootstrap.min.css");
    }))
</head>
razor
<head>
    @*...*@
    @DxResourceManager.RegisterTheme(Themes.Fluent.Clone(properties => {
        properties.Name = "Fluent Dark Purple";
        properties.Mode = ThemeMode.Dark;
        properties.AccentColor = ThemeFluentAccentColor.Purple;
    }))
</head>
razor
<head>
    @*...*@
    @DxResourceManager.RegisterTheme(Themes.Fluent.Clone(properties => {
        properties.Name = "Fluent Light Custom";
        properties.SetCustomAccentColor("#107c41");
        properties.AddFilePaths("css/fluent/FluentCustomStyles.css");
    }))
</head>

See Also

DxThemeBase<TProps> Class

DxThemeBase<TProps> Members

DevExpress.Blazor Namespace