I'm working with a named slot:
<div
name="checkAnswer"
class="w-[70%] mx-[15%] flex items-center justify-center"
>
<button
class="p-3 rounded-3xl shadow-md font-bold m-4 px-10 border-2 border-grey-800 hover:border-black hover:transition-all hover:duration-500"
>
<slot name="checkAnswer"></slot>
</button>
</div>
Here's how I use the named slot in my component:
<template #checkAnswer>
<button
@click="checkAnswer"
:disabled="isAnswerChecked"
:class="{
' text-gray-300 border-gray-300 ': isAnswerChecked,
}"
>
Check answer
</button>
</template>
I need to use the button tag for @click functionality, as it can't be applied directly to the template element.
However, I'm facing an issue. When the "Check answer" button is clicked, correct answers are displayed but I want to hide the button afterwards. The problem is that I can't seem to figure out how to hide the entire button - using v-show on the template element only hides the text within the button, leaving me with an empty button.
I've tried placing div elements inside and outside the template, but so far I haven't found a way to hide the button completely, not just its text.