Flowbite components render but look unstyled in a Tailwind project
Flowbite buttons, cards or modals render with no colours, spacing or bordersShort answer
Flowbite React ships its classes inside node_modules, and Tailwind v4 does not scan node_modules by default, so those classes are never generated. Run the Flowbite React init command, or register the package folder with an @source line in your CSS. Also check that your stylesheet imports Tailwind and that class names are not built by string concatenation.
Fix it fast
1Find out which cause you have
Open the browser dev tools, inspect a Flowbite button and look at its class list. If the classes are there but no CSS rule matches them, Tailwind never generated them: a source-scanning problem, not a markup problem.
npm ls flowbite-react tailwindcss grep -rn "@import \"tailwindcss\"" src/2Match what you see, then jump to its fix
- 1
A fresh install: components render, nothing is styled.Flowbite React setup was never runFix - 2
Your own components style fine; only the library's components do not.Tailwind does not scan node_modules, where the component classes liveFix - 3
Components you wrap or extend lose some styles, for example bg-${color}-600.Class names in your own code are built from piecesFix
- 1
What does the error look like?
Flowbite buttons, cards or modals render with no colours, spacing or bordersTailwind classes work in my own components but not in Flowbite components
Cause 1 of 3
Flowbite React setup was never run
1Check
The project README for flowbite-react says that adding it to an existing project is done with its init command, which sets up the dependencies and configuration it needs.
git status --short2Fix
Run the init command in the project root, then restart the dev server.
npx flowbite-react@latest init3Verify
Restart the dev server and reload; the components pick up their styles.
npm run devConfirmed by github.com
Cause 2 of 3
Tailwind does not scan node_modules, where the component classes live
1Check
Tailwind scans every file except .gitignore entries, node_modules, binary files, CSS files and lock files. A package built with Tailwind therefore has to be registered with @source.
grep -rn "@source" src/ *.css 2>/dev/null2Fix
Add an @source line in your main CSS file, with the path relative to that stylesheet, pointing at the package folder. Adjust the path to where your stylesheet is.
/* src/index.css */
@import "tailwindcss";
@source "../node_modules/flowbite-react";3Verify
Rebuild; the previously unstyled component gets its colours.
npm run buildConfirmed by tailwindcss.com
Cause 3 of 3
Class names in your own code are built from pieces
1Check
Tailwind reads source files as plain text and cannot follow string interpolation, so a class such as text-red-600 built from parts is never generated.
grep -rn "bg-\${\|text-\${" src/2Fix
Write complete class names and choose between them.
const tone = error ? 'text-red-600' : 'text-green-600';3Verify
The class appears in the generated CSS.
npm run build && grep -c "text-red-600" dist/assets/*.cssConfirmed by tailwindcss.com
How do I stop it coming back?
- Follow the framework guide for Vite, Next.js or Astro linked from the flowbite-react repository, instead of copying a Tailwind config from an older project.
- After installing any UI kit built on Tailwind, check whether it needs an @source line.
- Use full class names in code so Tailwind can find them.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- TaskvareA task and project-management suite: React on the web, Flutter on mobile, TypeScript underneath.
Related fixes
Web apps
Tailwind is installed but the utility classes do nothing
Tailwind classes work in some components but not in others
When classes have no effect, the stylesheet either lacks the v4 import line, is never loaded by the page, or the class name never appears as plain text in a scanned file.
5 causes, each with a fixWeb apps
Tailwind classes from a shared package are missing in a monorepo app
Styles missing only after next build or only in one app of the monorepo
Tailwind generates CSS only for class names it finds while scanning files.
3 causes, each with a fixWeb apps
There is no tailwind.config.js after installing Tailwind 4 and HeroUI in Next.js
HeroUI components render unstyled
Nothing is broken: Tailwind CSS 4 is configured in CSS and no longer creates tailwind.config.js.
3 causes, each with a fixWeb apps
Hydration failed after adding next-themes dark mode
Console reports a server and client mismatch on the html element
next-themes changes the html element and knows the theme only in the browser, so server HTML and client HTML differ.
3 causes, each with a fixWeb apps
TypeScript marks className as an error on React Native components
Property 'className' does not exist on type
React Native components have no className prop in their own types.
3 causes, each with a fixWeb apps
A shadcn/ui Dialog stays open after the form is submitted
Form submits and the data saves, but the modal remains on screen
A shadcn Dialog is a Radix dialog.
3 causes, each with a fix