Replies: 2 comments 2 replies
-
What you can do right now: <script setup>
import { useAttrs } from 'vue'
import { twMerge } from 'tailwind-merge'
defineOptions({ inheritAttrs: false })
const attrs = useAttrs()
</script>
<template>
<p v-bind="{ ...attrs, class: null }" :class="twMerge(attrs.class, 'text-red')">Hi!</p>
</template> Could surely be a bit better abtracted, too. |
Beta Was this translation helpful? Give feedback.
-
Hi 👋 A bit late to the party but I found something quite interesting that makes it quite easy to integrate Vue with <script setup lang="ts">
import { twMerge } from "tailwind-merge";
const props = defineProps<{
class?: string;
}>();
</script>
<template>
<div> <!-- Here the class is not propagated -->
<div :class="twMerge('h-6', props.class)"> <!-- Here the class is computed and always a string -->
...
</div>
</div>
</template> The only issue with that technique is that even if the Vue compiler does typecheck this correctly, the Vue Typescript Plugin does not. I'm gonna fill an issue on their repository and try to fix this. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
due to for example tailwind css class names, can there be a option to specify a custom merge function for the class fallthrough attributes?
So there can be the option to use the tailwind-merge methods (https://github.com/dcastil/tailwind-merge) to merge the fallthrough class name on a component?
Use case example:
Current status:
MyComponent:
The rendered HTML is:
With the possibility to define a custom merge function:
MyComponent:
The rendered HTML is:
Beta Was this translation helpful? Give feedback.
All reactions