Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <!-- @ionic/core@5.1.0 -->


      <ion-title>Toggle: Customized</ion-title>

  <ion-content class="ion-padding-horizontal">
    <ion-toggle checked></ion-toggle>
    <ion-toggle color="danger"></ion-toggle>
    <ion-toggle color="danger" checked></ion-toggle>

    <h1>Custom Widths</h1>
    <ion-toggle color="secondary" class="width-small"></ion-toggle>
    <ion-toggle color="secondary" checked class="width-small"></ion-toggle>
    <ion-toggle color="secondary" class="width-large"></ion-toggle>
    <ion-toggle color="secondary" checked class="width-large"></ion-toggle>

    <h1>Custom Heights</h1>
    <div style="display: flex; flex-flow: column; float: left;">
      <ion-toggle class="height-small"></ion-toggle>
      <ion-toggle checked class="height-small"></ion-toggle>
    <ion-toggle class="height-large"></ion-toggle>
    <ion-toggle checked class="height-large"></ion-toggle>
    <ion-toggle class="handle-height-large"></ion-toggle>
    <ion-toggle checked class="handle-height-large"></ion-toggle>

    <h1>Dynamic Sizes</h1>
    <ion-toggle color="tertiary" class="dynamic-small width-small height-small"></ion-toggle>
    <ion-toggle color="tertiary" checked class="dynamic-small width-small height-small"></ion-toggle>
    <ion-toggle color="tertiary" class="dynamic-large width-large height-large"></ion-toggle>
    <ion-toggle color="tertiary" checked class="dynamic-large width-large height-large"></ion-toggle>

    <h1>Complex Custom Toggles</h1>
    <ion-toggle mode="ios" class="all-custom"></ion-toggle>
    <ion-toggle mode="ios" checked class="all-custom"></ion-toggle>

    <ion-toggle class="custom-overflow"></ion-toggle>
    <ion-toggle checked class="custom-overflow"></ion-toggle>

    <ion-toggle mode="ios" color="dark" class="custom-spacing"></ion-toggle>
    <ion-toggle mode="ios" color="dark" checked class="custom-spacing"></ion-toggle>

    <ion-toggle mode="md" color="dark" class="custom-spacing"></ion-toggle>
    <ion-toggle mode="md" color="dark" checked class="custom-spacing"></ion-toggle>

    <ion-toggle mode="ios" class="icon-custom"></ion-toggle>
    <ion-toggle mode="ios" checked class="icon-custom"></ion-toggle>




                ion-toggle {
  padding: 5px;

.width-small {
  width: 40px;

.width-large {
  width: 100px;

.ios.height-small {
  height: 20px;

  /* The height of the handle is 100% of the track height - 4px */
  --handle-width: 16px;

.md.height-small {
  height: 10px;

  /* The height of the handle is 100% of the track height + 6px */
  --handle-width: 16px;

.height-large {
  height: 60px;

  --border-radius: 4px;
  --handle-border-radius: 4px;

  --handle-width: 50%;

.handle-height-large {
  height: 60px;

   * The max height of the handle is 100% of the track height - handle spacing
   * so this will never show as being 150%
  --handle-height: 150%;
  --handle-width: 23px;
  --handle-border-radius: 14px 4px 4px 14px;
  --handle-transition: border-radius 120ms ease-in-out 80ms;

.handle-height-large.toggle-checked {
  --handle-border-radius: 4px 14px 14px 4px;

.icon-custom {
  --handle-background-checked: #fff
    url( no-repeat center /

.icon-custom::before {
  position: absolute;
  content: "ON";
  color: white;
  top: 16px;
  left: 10px;
  z-index: 1;
  font-size: 8px;

.all-custom {
  height: 20px;
  width: 40px;

  --background: #fff;
  --background-checked: #0366a6;
  --handle-background: #bbbbbb;
  --handle-width: 20px;
  --handle-height: 20px;
  --handle-spacing: 0;
  --handle-box-shadow: none;

  border: 2px solid #bbb;
  border-radius: 16px;

.all-custom.toggle-checked {
  border-color: #0366a6;

  --handle-box-shadow: 0 3px 12px rgba(0, 0, 0, 0.16),
    0 3px 1px rgba(0, 0, 0, 0.1);

.custom-overflow {
  overflow: visible;

  contain: none;

  --background-checked: #d6ffd6;

  --handle-box-shadow: 0 3px 12px rgba(255, 0, 0, 0.6),
    0 3px 1px rgba(50, 70, 255, 0.6);

.ios.custom-spacing {
  --handle-height: 100%;
  --handle-width: 32px;

  --handle-spacing: 0;

.md.custom-spacing {
  --handle-height: 100%;
  --handle-width: 14px;

  --handle-spacing: 0;



                window.Ionic = {
  config: {
    mode: 'ios'

const smallToggles = document.querySelectorAll(".dynamic-small");
const largeToggles = document.querySelectorAll(".dynamic-large");

function toggleDynamic() {
  for (var i = 0; i < smallToggles.length; i++) {
    const toggle = smallToggles[i];

    const hasClass = toggle.classList.contains("height-small");

    if (hasClass) {
    } else {

  for (var i = 0; i < largeToggles.length; i++) {
    const toggle = largeToggles[i];

    const hasClass = toggle.classList.contains("height-large");

    if (hasClass) {
    } else {