Skip to content
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

Missing tailwind classes for dynamic colors #2199

Open
MickL opened this issue Sep 14, 2024 · 4 comments
Open

Missing tailwind classes for dynamic colors #2199

MickL opened this issue Sep 14, 2024 · 4 comments
Labels
bug Something isn't working triage

Comments

@MickL
Copy link

MickL commented Sep 14, 2024

Environment

------------------------------
- Operating System: Darwin
- Node Version:     v21.6.1
- Nuxt Version:     3.13.1
- CLI Version:      3.13.1
- Nitro Version:    2.9.7
- Package Manager:  [email protected]
- Builder:          -
- User Config:      compatibilityDate, devtools, modules
- Runtime Modules:  @nuxt/[email protected]
- Build Modules:    -
------------------------------

Version

2.18.4

Reproduction

https://github.com/MickL/nuxtui-colors-bug

Description

When the color prop is created dynamically, some css styles are not generated, especially for subtle and soft variants:

For example, subtle badges dont have correct border color and the background colors are missing:

Bildschirmfoto 2024-09-14 um 18 47 17

It should look like this:

Bildschirmfoto 2024-09-14 um 18 46 37

In my reproduction repo I used a table:

  <UTable :columns :rows>
    <template #colors-data="{row}">
      <UBadge :color="row.color" variant="subtle">Subtle Badge</UBadge>
      <UButton :color="row.color" variant="soft">Soft Button</UButton>
    </template>
  </UTable>
@MickL MickL added bug Something isn't working triage labels Sep 14, 2024
@Tragio
Copy link
Contributor

Tragio commented Sep 15, 2024

Hi @MickL 🙏

You can take a look at this: https://ui.nuxt.com/getting-started/theming#smart-safelisting

You will need to define it as a safe list since it is a dynamic prop.

@MickL
Copy link
Author

MickL commented Sep 15, 2024

This is what I did. But it ends up in a very large list. Is this really the only option? Why do I have red font and green font if they are also dynamic?

Bildschirmfoto 2024-09-15 um 21 05 02

@Malik-Jouda
Copy link
Contributor

@MickL

export default defineNuxtConfig({ ui: { safelistColors: ['green', 'yellow'] } })

Copy link
Member

@MickL You can also comment in your code // <UBadge color="green" /> for example so the parser knows to safelist the green classes for the Badge component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

4 participants