<template>
  <component
    :is="to ? NuxtLink : 'button'"
    :to="to"
    class="btn btn-sm btn-ghost gap-2"
    @click="!to && $emit('click')"
  >
    <Icon v-if="icon" :name="icon" size="16" />
    <slot />
  </component>
</template>

<script setup lang="ts">
import { NuxtLink } from '#components'

defineProps<{
  to?: string
  icon?: string
}>()

defineEmits<{
  (e: 'click'): void
}>()
</script>
