Checkbox based Toggle Switch component with swipe/drag support for Ember.
Based on this codepen. Here's the official demo using this component.
- Ember.js v5.8 or above — LTS 5.8, LTS 5.12, and current release/beta/canary are all actively tested in CI, under both classic and Embroider builds
- Ember CLI v5.8 or above
- Node.js v20.19 or above
Older Ember versions are likely fine (nothing in this addon is version-gated), but are no longer verified in CI.
ember install ember-toggle
There are many themes which change the visual appearance of the toggle.
Check the demo for interactive examples.
'default''ios''light''flat''flip''skewed''material'
Use it along with the @variant='auto' or @variant='dark' option to get a dark themed version, works only with 'ios', 'flat' and 'material' theme.
Example of changing the theme
Note: you choose which themes ship with your app by importing their CSS files, see the Styling section below.
You can also adjust the size of the widget by use of the size property. Valid sizes are:
'small''medium''large'
This option is available on all themes but is a less sensible choice for those themes which actually
include the label within the control (e.g., skew and flip).
You can customize labels (The text the user sees for the two states) and their associated values:
If you want your labels to be displayed, then you must set showLabels to true.
value- The state of the switch, can betrueorfalse. Defaults tofalse.onToggle- The action that should change the state ofvalue.theme- One of 'light', 'ios', 'flat', 'material', 'flip', 'skewed', 'default'.variant- One ofdarkorauto. Useautofor system dependent light/dark theme. Works only withios,flatandmaterialtheme. Defaults to 'default' if not specified.size- One of 'small', 'medium', 'large'. Defaults to 'medium' if not specified.onLabel- The label for the on state. Defaults to 'On'.offLabel- The label for the off state. Defaults to 'Off'.showLabels- Defaults to 'false', if 'true' will display labels on left and ride side of toggle switchdisabled- Defaults tofalse, which means you can click the toggle. Whentrue, an.x-toggle-disabledclass is set on the toggle and an.x-toggle-container-disabledclass is set on the component.name- A name to differentiate multiple toggles, gets passed to thetoggleaction. Defaults to 'default'.
Since ember-toggle is a v2 addon, it can no longer inject its CSS into your
app's build automatically. Import the base styles plus whichever themes you
use, e.g. in your app's app.js:
import 'ember-toggle/styles/base.css';
import 'ember-toggle/styles/themes/default.css';
import 'ember-toggle/styles/themes/light.css';Available theme files, under ember-toggle/styles/themes/:
default.css, light.css, ios.css, flat.css, skewed.css, flip.css,
material.css.
note: the IOS theme is referred to as just
iosnotios7as was indicated in the originating CSS source
Only import the themes you actually use, to keep your app's CSS bundle small.
If you want to write your own theme entirely, skip importing any theme file
and use ember-toggle/styles/themes/default.css as a reference for the class
names each component renders.
You can set app-wide defaults for non-theme options. These defaults can be overriden on a per toggle basis.
This configuration is located in config/environment.js.
The following is an example of how you can configure this addon:
ENV['ember-toggle'] = {
defaultShowLabels: true, // defaults to false
defaultTheme: 'light', // defaults to 'default'
defaultSize: 'small', // defaults to 'medium'
defaultOffLabel: 'False', // defaults to 'Off'
defaultOnLabel: 'True', // defaults to 'On'
};If you need custom labels, additional markup, or non-standard behavior, you are in the right section.
The x-toggle component also provides a composable component API.
The above is a simple example that returns a basic toggle, but you can see how this could be used to wrap the switch or the labels in custom markup or logic.
This format allows greater flexibility with labels, like the single label use-case.
Note: The
nothelper is a custom Ember helper in the above example.
See the Contributing guide for details.
MIT

