New to Telerik UI for ASP.NET Core? Download free 30-day trial

Appearance

In this article, you will find information about the styling options and rendering of the Telerik UI for ASP.NET Core Switch.

For a complete example, visit the Appearance Demo of the Switch.

Options

The Switch HtmlHelper provides the following styling options:

  • Size()—configures the overall size of the component.
  • TrackRounded()—defines the radius of the track's border.
  • ThumbRounded()—sets the radius of the thumb's border.

Size

The Size() method allows you to adjust the size of the Switch. The default size is Medium.

@(Html.Kendo().Switch()
    .Name("switch")
    .Size(ComponentSize.Medium)
    .Messages(c => c.Checked("YES").Unchecked("NO"))
)
<kendo-switch name="switch" size="ComponentSize.Medium">
    <messages checked="YES" unchecked="NO"/>
</kendo-switch>

The option adds a class k-switch-md to the span.k-switch element:

<span class="k-switch k-switch-on k-switch-md">
</span>

The following values are available for the Size option:

  • Small
  • Medium
  • Large
  • None

TrackRounded

You can control how much border radius is applied to the component's track by using the TrackRounded() method. The default value is Full.

The example below demonstrates how to set the TrackRounded option:

@(Html.Kendo().Switch()
    .Name("switch")
    .TrackRounded(Rounded.Full)
)
<kendo-switch name="switch" track-rounded="Rounded.Full"></kendo-switch>

The option adds a class k-rounded-full to the span.k-switch-track element that wraps the On/Off labels:

<span class="k-switch-track k-rounded-full">
</span>

The TrackRounded option supports the following values:

  • Small
  • Medium
  • Large
  • Full
  • None

ThumbRounded

The ThumbRounded() method controls how much border radius is applied to thumb of the Switch.

@(Html.Kendo().Switch()
    .Name("switch")
    .ThumbRounded(Rounded.Full)
)
<kendo-switch name="switch" thumb-rounded="Rounded.Full"></kendo-switch>

The option adds a class k-rounded-full to the span.k-switch-thumb element for the Switch handle:

<span class="k-switch-thumb k-rounded-full">
</span>

The ThumbRounded option supports the following values:

  • Small
  • Medium
  • Large
  • Full—the default value
  • None

Rendering

Starting with version R1 2022, the component has a new rendering. For additional information on the decision behind these changes, visit the Components Rendering Overview article.

To review the latest rendering of the component, refer to the HTML specifications in the Kendo UI Themes Monorepo. The tests folder of the repository contains the rendering for all flavors of the components, providing a clear reference for how their elements are structured. The rendering information can help you customize a component's appearance and behavior by applying custom CSS or JavaScript to suit specific design or functional requirements.

See Also

In this article