Skip to content

noTailwindLegacyImportant (HTML)

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

Disallow the leading ! important modifier in Tailwind CSS classes.

The ! modifier makes all the styles of a class !important. In Tailwind CSS v4, the ! goes at the end of the class name, as in flex! or hover:bg-red-500!. Tailwind CSS v3 wrote it at the start of the utility name instead, as in !flex or hover:!bg-red-500. Tailwind CSS v4 still accepts the old form for backward compatibility, but it’s deprecated.

This rule reports classes that put the ! at the start, and moves it to the end.

<div class="!flex"></div>
code-block.html:1:13 lint/nursery/noTailwindLegacyImportant  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ The Tailwind CSS class !flex puts the important modifier ! before the utility name.

> 1 │ <div class="!flex"></div>
│ ^^^^^
2 │

ℹ Tailwind CSS v4 expects the ! at the end of the class name, and only accepts it before the utility name for backward compatibility.

ℹ Use flex! instead.

ℹ 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.

ℹ Safe fix: Move the ! to the end of the class name.

1 │ - <div·class="!flex"></div>
1 │ + <div·class="flex!"></div>
2 2 │

<div class="hover:!bg-red-500"></div>
code-block.html:1:13 lint/nursery/noTailwindLegacyImportant  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ The Tailwind CSS class hover:!bg-red-500 puts the important modifier ! before the utility name.

> 1 │ <div class="hover:!bg-red-500"></div>
│ ^^^^^^^^^^^^^^^^^
2 │

ℹ Tailwind CSS v4 expects the ! at the end of the class name, and only accepts it before the utility name for backward compatibility.

ℹ Use hover:bg-red-500! instead.

ℹ 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.

ℹ Safe fix: Move the ! to the end of the class name.

1 │ - <div·class="hover:!bg-red-500"></div>
1 │ + <div·class="hover:bg-red-500!"></div>
2 2 │

<div class="flex! hover:bg-red-500! -m-4!"></div>

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