Rate this docs

Vue Bootstrap Switch

Vue Switch - Bootstrap 4 & Material Design

Vue Bootstrap switch is a simple component used for activating one of two predefined options. Commonly used as an on/off button.

It's mostly used in a number of various forms since they are dead simple to use and cut the time one needs to fill all the inputs.

Examples of Bootstrap switch use:

  • Forms
  • On/Off Functionality
  • Preference choice

Default switch

Default styling for Bootstrap Switch component



            <!-- Default switch -->
            <label class="bs-switch">
              <input type="checkbox">
              <span class="slider round"></span>
            </label>

          

Material switch MDB Pro component

Material Design styling for Bootstrap Switch component



            <!-- Material switch -->
            <mdb-switch />

          

Checked state

Add checked attribute to the <input> element to pre-select switch when the page loads.

The checked attribute is a boolean attribute.

Default switch



            <!-- Default checked -->
            <label class="bs-switch">
              <input type="checkbox" checked>
              <span class="slider round"></span>
            </label>

          

Material switch MDB Pro component



            <!-- Material checked -->
            <mdb-switch checked />

          

Disabled state

Add the disabled boolean attribute to the <input> and the custom indicator and label description will be automatically styled and blocked.

A disabled <input> element is unusable and un-clickable.

Default switch



            <!-- Default disabled -->
            <label class="bs-switch">
              <input type="checkbox" disabled>
              <span class="slider round"></span>
            </label>

          

Material switch MDB Pro component



            <!-- Material disabled -->
            <mdb-switch disabled />

          

Switch - API

In this section you will find advanced information about the Switch component. You will learn which modules are required in this component, what are the possibilities of configuring the component, and what events and methods you can use to work with it.


Import statement


          import { mdbSwitch } from 'mdbvue';
      

API Reference: Properties

Name Type Default Description Example
checked Boolean false Turn the switch on <mdb-switch-input checked ... />
disabled Boolean false Disable input <mdb-switch-input disabled ... />
classes String Override or extend the styles applied to the component. <mdb-switch-input classes="..." ... />
offLabel String Off Label for false event <mdb-switch-input offLabel="Off" ... />
onLabel String On Label for false event <mdb-switch-input onLabel="On" ... />

API Reference: Methods

Name Parameters Description Example
v-on:getValue value Returns input value. Use this method instead of v-model to handle input value changes. <mdb-switch-input @getValue="getSwitchValue" />