Last active
February 5, 2025 11:24
-
-
Save addeeandra/73e42bf8d9a978815a2fcd88d841928d to your computer and use it in GitHub Desktop.
Vue Component with PrimeVue + VueUse + Motion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script setup lang="ts"> | |
import {Button} from 'primevue' | |
import {useDark, useToggle} from '@vueuse/core' | |
const isDark = useDark() | |
const toggleDark = useToggle(isDark) | |
</script> | |
<template> | |
<Button @click="toggleDark()" size="small" text> | |
<template #icon> | |
<i v-if="isDark" class="pi pi-moon" v-motion | |
:initial="{ rotate: 180, opacity: 0 }" | |
:enter="{ rotate: 0, opacity: 1 }" | |
:leave="{ rotate: 180, opacity: 0 }"></i> | |
<i v-else class="pi pi-sun" v-motion | |
:initial="{ rotate: 180, opacity: 0 }" | |
:enter="{ rotate: 0, opacity: 1 }" | |
:leave="{ rotate: 180, opacity: 0 }"></i> | |
</template> | |
</Button> | |
</template> | |
<style scoped></style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment