-
Notifications
You must be signed in to change notification settings - Fork 688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with using {color} in app.config.ts variants #2007
Comments
Update 4. aug. 2024: Managed to reproduce the issue, updated the reproduction link. Please help. Update 3. aug. 2024: the issue still appears. After clearing my .nuxt folder, it came back. It looks like tailwind is not safelisting those classes. The problem is that I'm not able to reproduce it easily in stackblitz, because our project is quite complex (lots of nuxt layers). I'll try to reproduce it and if I manage, I will reopen the issue. Update: 2. aug. 2024: Found out that the issue in the reproduction was the preferred color mode: system. Also I removed @nuxtjs/tailwindcss from my project (because it's included with @nuxt/ui) and it seems to have fixed the problem. |
Since ui/src/runtime/utils/colors.ts Line 63 in 8d9b89d
You can read more about this here: https://tailwindcss.com/docs/content-configuration#safelisting-classes You can achieve this in your import type { Config } from 'tailwindcss'
export default <Partial<Config>>{
safelist: [{
pattern: RegExp(`^text-(red|blue)-100$`),
variants: ['hover']
}]
} It will be much easier in |
Right, but the documentation explicitly says
And I've used I've looked through your source code and if I remember correctly nuxt/ui safelists only a few classes (bg- and some others), which means I have to safelist a load of classes. It's not just text-{color}- that I've used and the repro is just an example. EDIT: Just an edit to my comment. The above might have come out in a negative way, but it wasn't meant so. I should have added above that a caveat in the documentation (that not all primary classes are actually generated) might be the right thing to do as there might be others who try to do the same. |
This issue is stale because it has been open for 30 days with no activity. |
This issue is stale because it has been open for 30 days with no activity. |
Hi! @benjamincanac Thanks in advance config file
|
@cesswhite You don't need safelists with Nuxt UI v3, would you mind opening a new issue with a reproduction of what you're trying to achieve? |
@benjamincanac The goal is to rebuild this tool: https://www.onamu.dev/ using UI v3. It's a tool for dynamic gradients, and the main objective is to ensure that all gradients are available, as we previously achieved with the safelist. However, some colors are not displaying correctly Before submitting an issue, I’d like to confirm whether it’s truly an issue or just a mistake on my part. |
@cesswhite The |
This issue is stale because it has been open for 30 days with no activity. |
I can confirm that I also get this bug in Nuxt UI v2.19.2 @benjamincanac Is there a plan to fix this in v2? |
@albertpratomo What bug? The solution to safelist classes has already been given above. |
@benjamincanac So do you mean the "Smart safelisting" feature by Nuxt UI is not working? ![]() And that we have to manually safelist classes via Tailwind config regex? |
I didn't mean that no, the smart safelisting is working fine. The smart safelisting applies when using Vue components, it's unrelated to the classes you write in your |
Ah okay, from the docs I assumed that the smart safelisting will check the classes I wrote in // in app.config.ts
ui: {
button: {
variant: {
solid: 'bg-{color}-700',
},
},
}
// in nuxt.config.ts
ui: {
safelistColors: ['primary'],
},
// in App.vue
<template>
<UButton />
</template> to clarify: Nuxt UI won't automatically safelist |
@benjamincanac sorry to ping, could you confirm? |
Environment
Version
2.18.1
Reproduction
https://stackblitz.com/edit/nuxt-ui-snm3l2?file=app.config.ts
Description
If using {color} in app.config.ts variants (https://ui.nuxt.com/getting-started/theming#smart-safelisting), even with "primary", the generated classes are ignored by tailwind. See reproduction (hover classes)
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: