Diagnostic step 1
Replace runtime concatenation with a mapping: create an object map like const bg = { primary: 'bg-blue-500', ... } and reference map[variant] so build-time analysis sees literal strings.
Generated Oct 21, 2026, 9:46:27 AM
Replace runtime concatenation with a mapping: create an object map like const bg = { primary: 'bg-blue-500', ... } and reference map[variant] so build-time analysis sees literal strings.
If mapping is impractical, add a safelist array in tailwind.config.js with regex patterns that cover the dynamic variants (e.g., safelist: [{ pattern: /bg-(red|blue|green)-500/ }]).
Avoid relying on ephemeral DOM-only injections; where possible use @apply in a component CSS file to define reusable classes that Tailwind compiles.
Rebuild production and inspect the generated CSS bundle to confirm the expected class selectors are present; test by deploying to a staging environment before rolling to production.