ui icon indicating copy to clipboard operation
ui copied to clipboard

Allow custom color for Chip

Open luminous8 opened this issue 3 months ago • 7 comments

Package

v4.x

Description

It would be awesome if "color" props on the Chip component would accept more than the default variables color ("error" | "primary" | "secondary" | "success" | "info" | "warning" | "neutral")

sometimes, user can set their own colors and it would be useful to simply pass an hex color to the color props

Keep up the great work ❤️

Love the library

Additional context

No response

luminous8 avatar Sep 24 '25 10:09 luminous8

We use our own color often not only in Badges.

The theming section in the docs explains how you can add your own colors globally.

https://ui.nuxt.com/docs/getting-started/installation/nuxt#themecolors

You can add any color you define in your main.css (or any default tailwind color) to be accessible. In the main.css just use the HEX values or RGB you want.

ui: { theme: { colors: ['primary', 'error', 'gold', 'my-own-defined-color', 'wathever-i-define'] } }

Or in the app.config too:

ui: { colors: { primary: 'blue', secondary: 'purple', tertiary: 'indigo' } }

Shooteger avatar Sep 24 '25 10:09 Shooteger

The colors u want to use are stored in my database, so they are not available at build time Each user can set up their own colors, so having them in app.config is not possible for me in this case

luminous8 avatar Sep 24 '25 10:09 luminous8

The colors u want to use are stored in my database, so they are not available at build time Each user can set up their own colors, so having them in app.config is not possible for me in this case

This isn't really possible, since in your case, for example, you'd like to send a hex to the color props, except that the component has variants and needs several shades of color to work

Image

However, you can overide the colors by making a tailwind class or a ui object in a computed with the colors you get from your db.

HugoRCD avatar Sep 24 '25 10:09 HugoRCD

I see, you could solve it via defining a default variable color in CSS/Tailwind config, then inject it via a nuxt plugin.

So you basically just override the app.config on runtime.

But of course your enhancement would be cool and save time, just providing you with an alternative.

Shooteger avatar Sep 24 '25 10:09 Shooteger

I see, you could solve it via defining a default variable color in CSS/Tailwind config, then inject it via a nuxt plugin.

So you basically just override the app.config on runtime.

But of course your enhancement would be cool and save time, just providing you with an alternative.

I was talking more about overriding the component itself with props or classes 😅

HugoRCD avatar Sep 25 '25 10:09 HugoRCD

I ran into the same problem... It would be great to be able to change the color using props or classes.

luishgp avatar Oct 28 '25 22:10 luishgp

I'm 100% positive this was possible on v3 (You could just reference, for example, Tailwind's red color and pass it in the color prop of, say the UBadge component)

Onelvis avatar Nov 10 '25 03:11 Onelvis