{
  "id": 12618020,
  "title": "Why React components from npm render unstyled with Tailwind v3",
  "url": "https://urgent.news/2026/10/07/why-react-components-from-npm-render-unstyled-with-tailwind-v3",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-07T11:43:14.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/oguzhanayyldz/why-react-components-from-npm-render-unstyled-with-tailwind-v3-4ci1"
  },
  "original_language": "en",
  "account": "React components from npm libraries often render unstyled when used with Tailwind v3. This occurs because Tailwind v3 generates CSS only for the class names it can see. When a component library ships its Tailwind classes inside compiled JavaScript, those classes are not found by Tailwind's configuration unless explicitly included.\n\nTo resolve this issue, you need to add the library's distribution folder to the `content` array in your `tailwind.config.js`. For example, if the library is named `@moontra/moonui` and its compiled files are in the `dist` folder, you should add `./node_modules/@moontra/moonui/dist/**/*.{js,mjs}` to the `content` array. This ensures Tailwind scans the necessary files and applies the appropriate classes.\n\nAdditionally, some libraries may use CSS variables to define colors and other design tokens. In such cases, you need to import the token file provided by the library. For instance, for the `@moontra/moonui` library, you would import `@moontra/moonui/tokens.css` using either an import statement in your main file or a global import in your layout file. This step is crucial for applying the correct colors and styles to the components.\n\nOnce you have configured Tailwind to include the library's files and token file, the components should render with the expected styles. It is important to note that the order in which these steps are taken can affect the outcome. For example, adding the library's files to `content` without importing the token file may lead to components with missing colors. Conversely, importing the token file without including the library's files in `content` may not resolve the issue if the components rely on class names defined in the library's files.\n\nIn summary, to fix unstyled components from npm libraries when using Tailwind v3, you need to add the library's distribution folder to the `content` array in your `tailwind.config.js`, and import the token file provided by the library. Ensuring these steps are taken in the correct order will help you achieve the desired styling for the components.",
  "summary": "Install a React component library, import a Button , render it. The label shows up and the click handler fires, but the thing looks like a gray browser default. The console is quiet and the build is green. I reproduced this in clean projects while working on MoonUI, a component library built on Radix and Tailwind. The components were not broken. My Tailwind setup just had no idea they existed,…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}