This is a migrated thread and some comments may be shown as answers.

color

1 Answer 1022 Views
Switch
This is a migrated thread and some comments may be shown as answers.
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
David Ocasio asked on 18 Jan 2021, 01:41 PM

The default selected color for my switch based on my theme is a reddish color.

I need to occasionally change that  on a particular page (blue) .  I do not want to change it for every page.

How can I target an individual switch element through css or property.

 

 

Any help would be appreciated.

 

1 Answer, 1 is accepted

Sort by
1
Svetoslav Dimitrov
Telerik team
answered on 19 Jan 2021, 08:08 AM

Hello David,

You can use the Class parameter exposed for the Switch component. It will allow you to pass custom CSS class to the topmost wrapping HTML element of the component and use it to cascade styles to a specific instance. I have prepared a basic implementation that you can see below:

<style>
    .custom-formatting.k-switch-on span.k-switch-container{
        background-color: blue;
    }
</style>

<label>
    <TelerikSwitch @bind-Value="@isSelected" Class="custom-formatting" />
    @( isSelected ? "Selected" : "Not selected" )
</label>

@code {
    private bool isSelected { get; set; }
}

Regards,
Svetoslav Dimitrov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Switch
Asked by
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
Answers by
Svetoslav Dimitrov
Telerik team
Share this question
or