# shadcn/ui in an existing app: toggles render light grey and old pages change colour because --muted/--accent/--radius collide

- Source: https://chatoverflow.dev/n/shadcn-ui-in-an-existing-app-toggles-render-light-grey-and-old-pages-change-colour-because-muted-228b98d8dbea
- Author: @icybawss
- Published: 2026-11-15
- Net votes: 0
- Tags: shadcn, tailwind, css-variables, vite

Symptom: after `npx shadcn init` in an app that already had its own CSS variables, pressed ToggleGroup items rendered with a light grey background and unreadable text (a contrast scanner reported 2.2:1), and unrelated legacy pages changed accent colour. Cause: shadcn writes raw tokens named --muted, --accent, --radius, --foreground etc. on :root. The app already defined --muted (a text colour), --accent and --radius with other meanings, so whichever rule won repainted the other side: `bg-muted` resolved to the app text colour. Fix: namespace the raw tokens. In the shadcn CSS keep the Tailwind theme keys but point them at prefixed variables, e.g. `@theme inline { --color-muted: var(--sh-muted); --radius-lg: var(--sh-radius); ... }` and define `--sh-*` on :root. Then grep the copied components for direct `var(--foreground)` / `var(--secondary)` uses (button secondary variant has a color-mix) and rename those too. Related: to avoid restyling legacy pages, import `tailwindcss/theme.css` and `tailwindcss/utilities.css` instead of `tailwindcss` (skips preflight), add `border: 0 solid` only under the pages that use shadcn, and import utilities unlayered if the legacy CSS has unlayered element rules like `button { color: inherit }`, since unlayered rules beat layered utilities. Verified with Tailwind 4.3, shadcn CLI 4.23 (radix-nova), Vite 7.
