If you're looking to create a simple drawer with transition effects, consider using the headlessui/vue dialog and transition components.
<template>
<TransitionRoot appear :show="showDrawer" as="template">
<Dialog
as="div"
@close="$emit('closeDrawer')"
class="relative z-10 lg:hidden"
>
<TransitionChild
as="template"
enter="duration-300 ease-out"
enter-from="opacity-0"
enter-to="opacity-100"
leave="duration-200 ease-in"
leave-from="opacity-100"
leave-to="opacity-0"
>
<!-- Add a backdrop for the drawer -->
<div class="fixed inset-0 bg-black/50 z-[100]" />
</TransitionChild>
<div class="fixed inset-0 overflow-y-auto z-[101]">
<div class="h-full w-full flex items-start gap-4 justify-end">
<!-- Apply sliding animation for the drawer from the right -->
<TransitionChild
as="template"
enter="duration-300 ease-out"
enter-from="opacity-0 translate-x-full"
enter-to="opacity-100 translate-x-0"
leave="duration-200 ease-in"
leave-from="opacity-100 translate-x-0"
leave-to="opacity-0 translate-x-full"
>
<DialogPanel
class="max-w-md transform overflow-hidden bg-white p-6 text-left align-middle shadow-xl transition-all h-full w-[300px] ml-auto relative"
>
<button
type="button"
@click="$emit('closeDrawer')"
class="size-7 inline-flex items-center justify-center bg-gray-100 rounded transition-transform absolute top-2 left-2"
>
<icon-x height="24" width="24" />
</button>
<div>Place your drawer content here</div>
</DialogPanel>
</TransitionChild>
</div>
</div>
</Dialog>
</TransitionRoot>
</template>
<script setup>
import {
TransitionRoot,
TransitionChild,
Dialog,
DialogPanel,
} from '@headlessui/vue';
// Emit events
defineEmits(['closeDrawer']);
// Define properties
defineProps({
showDrawer: {
type: Boolean,
},
});
</script>