11<script setup>
2- import { computed , useSlots } from ' vue' ;
2+ import { computed , useAttrs , useSlots } from ' vue' ;
33import { cva } from ' cva' ;
44import { twMerge } from ' tailwind-merge' ;
55import Icon from ' ./Icon/Icon.vue' ;
66import { Link } from ' @inertiajs/vue3' ;
77
8+ defineOptions ({ inheritAttrs: false });
9+
810const props = defineProps ({
911 /** Appended text */
1012 append: { type: [String , Number , Boolean , null ], default: null },
@@ -30,6 +32,7 @@ const props = defineProps({
3032 text: { type: [String , Number , Boolean , null ], default: null },
3133});
3234
35+ const attrs = useAttrs ();
3336const slots = useSlots ();
3437const hasDefaultSlot = !! slots .default ;
3538const tag = computed (() => {
@@ -78,12 +81,17 @@ const badgeClasses = computed(() => {
7881 asButton: props .href ?? props .as == ' button' ? true : false ,
7982 });
8083
81- return twMerge (classes);
84+ return twMerge (classes, attrs .class );
85+ });
86+
87+ const restAttrs = computed (() => {
88+ const { class: _ , ... rest } = attrs;
89+ return rest;
8290});
8391< / script>
8492
8593< template>
86- < component : is= " tag" : class = " badgeClasses" : href= " props.href" : target= " target" data- ui- badge>
94+ < component : is= " tag" v - bind = " restAttrs " : class = " badgeClasses" : href= " props.href" : target= " target" data- ui- badge>
8795 < span v- if = " props.prepend" class = " font-medium border-e border-inherit ps-0.5 pe-1.5" > {{ prepend }}< / span>
8896 < Icon v- if = " icon" : name= " icon" / >
8997 < slot v- if = " hasDefaultSlot" / >
0 commit comments