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

[bug]: Tailwind 4 classes missing when using shadcn from monorepo #6878

Open
2 tasks done
viveleroi opened this issue Mar 6, 2025 · 2 comments
Open
2 tasks done

[bug]: Tailwind 4 classes missing when using shadcn from monorepo #6878

viveleroi opened this issue Mar 6, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@viveleroi
Copy link

Describe the bug

I've been updating our relatively new monorepo to use Tailwind 4 and I followed their upgrade docs as well as the shadcn docs. I've updated the versions, reinstalled shadcn components, adjusted our globals.css file per the docs, etc. I don't believe I've missed anything. Our monorepo setup very closely mirrors the shadcn monorepo example that's generated via the shadcn CLI.

However, when I run our apps, it seems like tailwind is not detecting the classnames shad/twMerge/etc are generating. For example, a destructive button is completely invisible because the text is white but the bg-destructive is nowhere to be found in the generated css.

Once I added a hard-coded example to our app, not via shad components, the tailwind file detected it and updated.

I'm not sure where to look to figure out why tailwind isn't detecting all of the classes from shadcn components.

Affected component/components

Button, Card, etc

How to reproduce

  1. Update the shadcn monorepo generated via CLI to tailwind v4

Codesandbox/StackBlitz link

No response

Logs

System Info

Windows 11, Node 21

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
@viveleroi viveleroi added the bug Something isn't working label Mar 6, 2025
@viveleroi
Copy link
Author

I was at least able to solve it by re-adding a tailwind config file and specifying the ui package content.

globals.css:

@import 'tailwindcss';
@config "../../tailwind.config.ts";

tailwind.config.ts:

import type { Config } from 'tailwindcss'

const config = {
  content: ['./src/**/*.{ts,tsx}', '../../apps/**/*.{ts,tsx}']
} satisfies Config

export default config

@JoshuaS98
Copy link

In packages/ui/globals.css, you can add the @source directive to add sources that tailwind should consider while generating utility classes.

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

No branches or pull requests

2 participants