Skip to content

Switch

ESwitch A Switch displays two exclusive options and allows the user to toggle the status of a single item between checked and unchecked. Demo Here

Usage

vue

<template>
  <ESwitch v-model="value"> On</ESwitch>
</template>

<script setup>
  const value = ref(false);
</script>

Props

For ESwitch component, the following props are available:

PropTypeDefaultNote
labelString-Component's label
idString-HTML id attribute.
disabledBooleanfalseDisables the ESwitch.
widthString-Sets the component's width.
heightString-Sets the component's height.
messageString-Adds a message below the select.
modelValueBoolean-If true, the element is checked.
validateOnString"input"Triggers validation on @values: submit, input.
rulesArray-Validation rules. For more info refer to Form Validation.
stateString-Validates the user-provided data against established criteria and performs display validation. States can be none if no validation is necessary, danger if the selected is valid, or success if it is acceptable.
nameString-HTML name attribute.
iconObject{}Adds a fixed icon to the switch. More Info about icons here.
trueIconObject{}Displays a true icon when the switch is checked. More Info here.
falseIconObject{}Displays a false icon when the switch is unchecked. More Info here.
squareBooleanfalseRemoves rounded corners of the element.
colorString"primary"The given color is applied to the element - utility colors are supported (e.g primary or danger). you'll find a list of built-in classes on the src/styles/_vars.scsspage.

Emits

The ESwitch component contains following emits.

EmitDescription
update:modelValueEmitted when the local ref's value is mutated.

Slots

The ESwitch component provide following slots that enable you to customize the content.

SlotDescription
trueValueValue of the switch if it's checked.
falseValueValue of the switch if it's un-checked.

COPYRIGHT