How to add colors from tailwind to nuxt ui ?
Hello ! I want to know how i can add like purple tailwind default colors to nuxt ui badge ?
2 Replies
Hi @Anto'. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To add Tailwind's default colors (like purple) to Nuxt UI components such as the Badge, you need to map the semantic color alias (e.g., primary, secondary, etc.) to the Tailwind color you want in your configuration. Here’s how you can do it:
1. Assign Tailwind Color to a Semantic Alias
In your
Now, use the
You can assign any Tailwind color to any of the semantic aliases (
You cannot use arbitrary Tailwind color names directly in the
In your
app.config.ts
, set the desired semantic color (e.g., secondary
) to Tailwind's purple
:
2. Use the Semantic Alias in the BadgeNow, use the
color
prop with the alias you configured (e.g., secondary
) in your Badge component:
This will apply Tailwind's purple color to the Badge, as secondary
now points to purple
in your theme configuration.
3. You Can Also Use Other AliasesYou can assign any Tailwind color to any of the semantic aliases (
primary
, secondary
, success
, etc.) in the same way. Just make sure the color exists in your Tailwind theme.
Note:You cannot use arbitrary Tailwind color names directly in the
color
prop (e.g., color="purple"
will not work). You must map the semantic alias to the Tailwind color in your config first Customize design system.
Example for multiple colors:
Now, <UBadge color="secondary">Badge</UBadge>
will use Tailwind's purple color.
For more details, see the Nuxt UI Design System Colors documentation.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@141085430098427904> Kapa.ai is still learning and improving, please let me know how I did by reacting below.