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({
});

You can create the widget using one of the following approaches.

  • jQuery

    HTML
    <div id="switch"></div>
    JavaScript
    $(function () {
        $("#switch").dxSwitch({
            value: true
        });
    });
  • AngularJS

    HTML
    <div dx-switch="{
        value: true
    }"></div>
  • Knockout

    HTML
    <div data-bind="dxSwitch: {
        value: true
    }"></div>
  • ASP.NET MVC Wrappers

    @(Html.DevExtreme().Switch()
        .ID("switch")
        .Value(true)
    )

Note that DevExtreme widgets require you to link the jQuery library to your application. If you use the Knockout or AngularJS approach, the Knockout or AngularJS library is also required. For detailed information on linking these libraries to your project, refer to the topics in the Installation section.

View Demo

See Also
Show Example:
AngularJS
Knockout
jQuery

Configuration

An object defining configuration options for the Switch widget.

Methods

This section describes members used to manipulate the widget.

Events

This section describes events fired by this widget.