🔥 Meet Our New Project: t0ggles - Your Ultimate Project Management Tool! 🔥

Toggle Vue Component

Toggle Components

There are following components included:

  • Toggle

Toggle Props

NameTypeDefaultDescription
checkedbooleanfalse

Defines whether the toggle input is checked or not

colorsobject

Object with Tailwind CSS colors classes

colors.bgIosstring'bg-black bg-opacity-10 dark:bg-white dark:bg-opacity-20'
colors.bgMaterialstring'bg-md-light-surface-variant dark:bg-md-dark-surface-variant'
colors.borderMaterialstring'border-md-light-outline dark:border-md-dark-outline'
colors.checkedBgIosstring'bg-primary'
colors.checkedBgMaterialstring'bg-md-light-primary dark:bg-md-dark-primary'
colors.checkedBorderMaterialstring'border-md-light-primary dark:border-md-dark-primary'
colors.checkedThumbBgIosstring'bg-white'
colors.checkedThumbBgMaterialstring'bg-md-light-on-primary dark:bg-md-dark-on-primary'
colors.thumbBgIosstring'bg-white'
colors.thumbBgMaterialstring'bg-md-light-outline dark:bg-md-dark-outline'
componentstring'label'

Component's HTML Element

defaultCheckedbooleanfalse

Defines whether the toggle input is checked or not, for the case if it is uncontrolled component

disabledbooleanfalse

Defines whether the toggle input is disabled or not

namestring

Toggle input name

readonlybooleanfalse

Defines whether the toggle input is readonly or not

touchRipplebooleantrue

Enables touch ripple effect in Material theme

valueany

Toggle input value

Toggle Events

NameTypeDescription
changefunction(e)

Toggle input change event handler

Examples

Toggle.vue
<template>
<k-page>
<k-navbar title="Toggle" />
<k-list strong inset>
<k-list-item label title="Item 1">
<template #after>
<k-toggle
component="div"
class="-my-1"
:checked="checked1"
@change="() => (checked1 = !checked1)"
/>
</template>
</k-list-item>
<k-list-item label title="Item 2">
<template #after>
<k-toggle
component="div"
class="-my-1 k-color-brand-red"
:checked="checked2"
@change="() => (checked2 = !checked2)"
/>
</template>
</k-list-item>
<k-list-item label title="Item 3">
<template #after>
<k-toggle
component="div"
class="-my-1 k-color-brand-green"
:checked="checked3"
@change="() => (checked3 = !checked3)"
/>
</template>
</k-list-item>
<k-list-item label title="Item 4">
<template #after>
<k-toggle
component="div"
class="-my-1 k-color-brand-yellow"
:checked="checked4"
@change="() => (checked4 = !checked4)"
/>
</template>
</k-list-item>
</k-list>
</k-page>
</template>
<script>
import { ref } from 'vue';
import {
kPage,
kNavbar,
kNavbarBackLink,
kList,
kListItem,
kToggle,
} from 'konsta/vue';
export default {
components: {
kPage,
kNavbar,
kNavbarBackLink,
kList,
kListItem,
kToggle,
},
setup() {
const checked1 = ref(true);
const checked2 = ref(true);
const checked3 = ref(true);
const checked4 = ref(true);
return {
checked1,
checked2,
checked3,
checked4,
};
},
};
</script>
Code licensed under MIT.
2022 © Konsta UI by nolimits4web.