Switch

Switch es utilizado para realizar cambios entre dos estados opuestos.

Uso básico

Tamaños

Texto de descripción

Puede añadir active-text y inactive-text para mostrar textos. usar el atributo inline-prompt para controlar si el texto se muestra dentro del punto.

Mostrar iconos personalizados

TIP

Utilice el atributo active-icon y inactive-icon para añadir iconos. Puede pasarle ya sea el nombre del componente (registrado de antemano) o el propio componente que es un componente SVG Vue. Element Plus ha proporcionado un conjunto de iconos que puedes encontrar en icono

Tipos de valores extendidos

Deshabilitado

Cargando

Prevenir interruptores

custom action icon 2.3.9

custom action slot 2.4.4

API

Attributes

NameDescripciónTipoDefault
model-value / v-modelvalor vinculante, debe ser equivalente al active-value o al inactive-value. El tipo por defecto es el tipo boolean.boolean / string / numberfalse
disabledsi Switch esta deshabilitadobooleanfalse
loadingsi el interruptor está en estado de cargabooleanfalse
sizetamaño del interruptorenum''
widthancho del componente Switchnumber / string''
inline-promptsi el icono o el texto se muestran dentro de un punto, sólo el primer carácter será renderizado para el textobooleanfalse
active-iconcomponente del icono que se muestra en on, anula active-textstring / Component
inactive-iconcomponente del icono que se muestra cuando está en off, anula inactive-textstring / Component
active-action-icon 2.3.9component of the icon displayed in action when in on statestring / Component
inactive-action-icon 2.3.9component of the icon displayed in action when in off statestring / Component
active-texttext displayed when in on statestring''
inactive-texttext displayed when in off statestring''
active-valueswitch value when in on stateboolean / string / numbertrue
inactive-valueswitch value when in off stateboolean / string / numberfalse
active-color deprecatedbackground color when in on state ( deprecated, use CSS var --el-switch-on-color instead )string''
inactive-color deprecatedbackground color when in off state ( deprecated, use CSS var --el-switch-off-color instead )string''
border-color deprecatedborder color of the switch ( deprecated, use CSS var --el-switch-border-color instead )string''
nameinput name of Switchstring''
validate-eventwhether to trigger form validationbooleantrue
before-changebefore-change hook before the switch state changes. If false is returned or a Promise is returned and then is rejected, will stop switchingboolean / Function
idid for inputstring
tabindextabindex for inputstring / number
label a11y deprecatedsame as aria-label in native inputstring
aria-label a11y 2.7.2same as aria-label in native inputstring

Events

NameDescripciónType
changese dispara cuando el valor cambiaFunction

Switch Slots

NameDescripción
active-action 2.4.4customize active action
inactive-action 2.4.4customize inactive action

Exposes

MétodoDescriptionType
focusmanual focus to the switch componentFunction

Fuente

ComponentesDocumentación

Contribuidores