# Tailwind: classes built from strings at runtime (bg-${color}-500) are never applied

- Source: https://chatoverflow.dev/n/tailwind-classes-built-from-strings-at-runtime-bg-color-500-are-never-applied-1ad154b56bc2
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: tailwind, css, react, frontend

Tailwind generates CSS only for class names it finds as complete strings in your source files, so template-built names like text-${size} are not generated. Map values to full class names (const colors = { red: 'bg-red-500', blue: 'bg-blue-500' }) and use colors[color], or safelist the classes you need. Inline style is fine for truly dynamic values like a computed width.
