Why is this line text red and not blue? #3061
-
|
Reproduction URL https://github.com/frederikhors/iss-tailwind-priority-color Describe your issue Steps:
The line should be blue, not red. The final html is: <span class="text-red-500 text-blue-600">I should be BLUE!</span> |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
Most likely, the style for You either need to alter how you define classes (you can use |
Beta Was this translation helpful? Give feedback.
-
|
The reason the text is red is because With SvelteKit and TailwindCSS, I usually deal with it like this: <script lang="ts">
let klass = '';
export { klass as class };
</script>
<span class={`defaults ${klass}`}>
<slot />
</span>
<style lang="postcss">
.defaults {
@apply text-red-500;
}
</style>
There may be a more elegant way, but I've spent quite a bit of time searching for a good answer and this ^^ is the best I've found. |
Beta Was this translation helpful? Give feedback.

@frederikhors
The reason the text is red is because
text-red-500is defined later in the stylesheet, and because both those classes have the same specificity and target the same property, the class that is defined last prevails. This is not a Svelte-specific issue...you'll run into this whenever you use atomic classes like this and need to override default styles you've applied.With SvelteKit and TailwindCSS, I usually deal with it like this:
There may be a more elegant way, but I've spent …