Toggle Switch

# Documentation

ToggleSwitch is used to select a boolean value i.e. it allows you to select or deselect an attribute.

#Basic Usage

Use the LvToggleSwitch with some basic and complex use cases by passing either classes or props eg. for setting label you can pass a string into label prop. LightVue toggle-switch is Both compatible with Vue 2.x and Vue 3.x

#With Icons

You can set the icon on the LvToggleSwitch by passing a icon string into icon prop.(The icons can be String)
You can also use Light Icons from LightVue and pass it into the button.

#Dense Switch

You can use the dense version of LvToggleSwitch by setting dense prop true.you can also use set the icon to dense toggle switch by passing the icon in icon prop

#Predefining state

You can Predefine the state of LvToggleSwitch by setting modal-value true.by default the value if false

#Label Position

You can change the label position by through labelPosition prop

#Disable

You can also disable the LvToggleSwitch by setting the disabled prop true

#Setup

You can import a component and register it as a local and global vue component as follows:

// import the component
import LvToggleSwitch from 'lightvue/toggle-switch';
// Register the component locally
export default {
    components: {
        LvToggleSwitch
    }
}
// Register the component globally (Vue 2.x)
Vue.component('LvToggleSwitch', LvToggleSwitch);

// Register the component globally (Vue 3.x)
const app = Vue.createApp({
  // ...
});
app.component('LvToggleSwitch', LvToggleSwitch);
app.mount('#app')
               

#APIs

All of the props, events and slots of the component are mentioned below:

Props
Type
Default
Description
name
String
Specifies the name of the control
icon
String
Determines the icon to be used
checked-icon
String
The icon which should be used when the toggle is on.
unchecked-icon
String
The icon which should be used when the toggle is off.
left-label
Boolean
false
Label to be displayed on the left side of the component
label
String
Label to be displayed with the toggle switch (on the right side)
labelPosition
String
right
Choose whether to place label on the left or right of the switch
disabled
Boolean
false
Disables the toggle switch component
size
String
16px
Defines the size of toggle switch component
color
String
Defines the color of toggle switch component.
Events
Parameters
Description
update:modelValue
value:  String
Can also be achieved by v-model
change
value:  boolean
Changes the value of toggle switch
click
value:  String
Toggle switch changer on click.
focus
value:  String
Decides what happens when toggle switch is in focus.
blur
value:  String
Decide the functionality of toggle switch when it is blur.