Skip to content

Instantly share code, notes, and snippets.

@addeeandra
Last active February 5, 2025 11:24
Show Gist options
  • Save addeeandra/73e42bf8d9a978815a2fcd88d841928d to your computer and use it in GitHub Desktop.
Save addeeandra/73e42bf8d9a978815a2fcd88d841928d to your computer and use it in GitHub Desktop.
Vue Component with PrimeVue + VueUse + Motion
<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