Switch

The Switch is a widget that can be in two states: "On" and "Off".

Included in: dx.mobile.js, dx.web.js, dx.viz-web.js, dx.all.js
Module: ui/switch
Export: default
Switch interactive configuration
Copy Code
Copy to Codepen
$("#switch").dxSwitch({
});

                    

DevExtreme widgets are integrated with many popular libraries and frameworks. See the Installation section (for JavaScript libraries) or the Prerequisites and Installation section (for ASP.NET MVC framework) to find details on setting up DevExtreme with a particular library or framework.

The following code shows how to create the Switch widget using every supported library and framework. For more details on working with widgets in these libraries and frameworks, see the Widget Basics topic for jQuery, Angular, AngularJS, Knockout or ASP.NET MVC.

jQuery
JavaScript
HTML
$(function () {
    $("#switch").dxSwitch({
        value: true
    });
});
<div id="switch"></div>
Angular
HTML
TypeScript
<dx-switch [value]="true"></dx-switch>
import { DxSwitchModule } from 'devextreme-angular'
// ...
export class AppComponent {
    // ...
}
@NgModule({
    imports: [
        // ...
        DxSwitchModule
    ],
    // ...
})
AngularJS
HTML
<div dx-switch="{
    value: true
}"></div>
Knockout
HTML
<div data-bind="dxSwitch: {
    value: true
}"></div>
ASP.NET MVC Controls
Razor C#
Razor VB
@(Html.DevExtreme().Switch()
    .ID("switch")
    .Value(true)
)
@(Html.DevExtreme().Switch() _
    .ID("switch") _
    .Value(True)
)

View Demo

See Also
Show Example:
AngularJS
Knockout
jQuery

Configuration

An object defining configuration options for the Switch widget.

Methods

This section describes the members used to manipulate the widget.

Events

This section describes events fired by this widget.

See Also