79452914

Date: 2025-02-19 22:28:07
Score: 0.5
Natty:
Report link

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

web/app/src/style.css

@import 'tailwindcss';

/* Added this line */
@import '@repo/tailwind-config/style.css';

packages/ui/components.json

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

tools/tailwind/package.json

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!

Reasons:
  • Blacklisted phrase (0.5): I need
  • Contains signature (1):
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: nktnet