Skip to content

Commit 95ac3a2

Browse files
committed
feat: link component
1 parent 448a69e commit 95ac3a2

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/components/Link.vue

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<script setup lang="ts">
2+
import { computed, useAttrs } from 'vue'
3+
import { twMerge } from 'tailwind-merge'
4+
5+
defineOptions({ inheritAttrs: false })
6+
7+
defineProps({
8+
/**
9+
* The URL the link points to.
10+
*/
11+
href: {
12+
type: String,
13+
required: true,
14+
validator: (v: string) => v.trim().length > 0,
15+
},
16+
})
17+
18+
const attrs = useAttrs()
19+
const mergedClass = computed(() => twMerge('no-underline', attrs.class as string))
20+
</script>
21+
22+
<template>
23+
<a :href="href" v-bind="$attrs" :class="mergedClass">
24+
<slot />
25+
</a>
26+
</template>

0 commit comments

Comments
 (0)