Skip to content

Toggles - AvToggle ​

✨ Introduction ​

The AvToggle is a versatile Vue component, designed to allow the user to choose between two opposite states (active/inactive).

🏗️ Structure ​

None.

🏷️ Props ​

NameTypeDefaultMandatoryDescription
modelValuebooleanundefinedBoolean value linked to the input.
descriptionstringundefinedIndicates the purpose of the toggle.
idstringtoggle-${crypto.randomUUID()}Unique id for the toggle. Used for accessibility.
disabledbooleanundefinedIndicates if the toggle is disabled.
disabledTooltipstringundefinedTooltip text displayed when the toggle is disabled.
activeTextstring'On'Text to display next to the toggle (right) when it is active.
inactiveTextstring'Off'Text to display next to the toggle (right) when it is inactive.
namestringundefinedname attribute of the input.
statusTextWidthstring'1.8rem'Width of the active/inactive texts.

🔊 Events ​

None.

🎨 Slots ​

NameDescription
defaultSlot to customize the content displayed next to the toggle. Receives a prop active indicating the current state of the toggle.

🚀 Storybook demos ​

You can find examples of use and demo of the component on its dedicated Storybook page.

💡 Examples of use ​

vue
<script>
const state = ref(false)
</script>

<template>
  <AvToggle
    v-model="state"
    description="Awesome toggle"
  />
</template>