Skip to content

useTailwindStaticClassStrings (JavaScript)

biome.json
{
"linter": {
"rules": {
"nursery": {
"useTailwindStaticClassStrings": "error"
}
}
}
}

Require complete, statically written class names.

Tailwind detects class names in source text. Dynamic string construction can hide complete class names from its source scanner. Choose between complete class names instead. Template interpolation and concatenation are reported even when separated by whitespace or composed entirely of literals. Variables and conditional choices are allowed. This rule does not follow variable assignments or inspect tagged templates.

<div className={`bg-${color}`} />;
code-block.jsx:1:17 lint/nursery/useTailwindStaticClassStrings ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This class string is constructed dynamically.

> 1 │ <div className={`bg-${color}`} />;
│ ^^^^^^^^^^^^^
2 │

ℹ Tailwind scans source text for complete class names.

ℹ Use complete class names, choosing between them with a conditional expression or a lookup.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

<div className={"text-" + color} />;
code-block.jsx:1:17 lint/nursery/useTailwindStaticClassStrings ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This class string is constructed dynamically.

> 1 │ <div className={"text-" + color} />;
│ ^^^^^^^^^^^^^^^
2 │

ℹ Tailwind scans source text for complete class names.

ℹ Use complete class names, choosing between them with a conditional expression or a lookup.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

clsx(`bg-${color}`);
code-block.js:1:6 lint/nursery/useTailwindStaticClassStrings ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This class string is constructed dynamically.

> 1 │ clsx(`bg-${color}`);
│ ^^^^^^^^^^^^^
2 │

ℹ Tailwind scans source text for complete class names.

ℹ Use complete class names, choosing between them with a conditional expression or a lookup.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

<div className={`p-4 ${classes}`} />;
code-block.jsx:1:17 lint/nursery/useTailwindStaticClassStrings ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This class string is constructed dynamically.

> 1 │ <div className={`p-4 ${classes}`} />;
│ ^^^^^^^^^^^^^^^^
2 │

ℹ Tailwind scans source text for complete class names.

ℹ Use complete class names, choosing between them with a conditional expression or a lookup.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

<div className={active ? "bg-red-500" : "bg-blue-500"} />;
<div className="p-4 text-white" />;

This rule checks the attributes and functions recognized by the top-level tailwind configuration.