Adding on to Wongjn's answer, if you want the CLI to also work, your components.json
will also need to be updated.
I have a turborepo template where there is a shared tailwind-config
package, a react web
app and a ui
component. The changes I needed to make were:
apps
├─ web
| ├─ src
| | └─ style.css # change
packages
├─ ui
| └─ components.json # change
tools
├─ tailwind
| ├─ style.css
| └─ package.json # change
@import 'tailwindcss';
/* Added this line */
@import '@repo/tailwind-config/style.css';
This is only needed to use the CLI - if you are only copying/pasting code, there's no need to make any modification here.
{
"tailwind": {
// Remove old reference to tailwind.config.ts
"config": "",
"css": "../../tools/tailwind/style.css"
},
}
At the time of writing, you also need to use the canary version of Shadcn's CLI, e.g.
npx shadcn@latest add button
Exporting the tools/tailwind/style.css shared config:
"exports": {
"./style.css": "./style.css"
},
The full code is available at my repository below:
Hope this was helpful!