noTailwindLegacyImportant (HTML)
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/noTailwindLegacyImportant - This rule has a safe fix.
- The default severity of this rule is warning.
- This rule belongs to the following domains:
- Sources:
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noTailwindLegacyImportant": "error" } } }}Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”<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>Recognized class strings
Section titled “Recognized class strings”This rule checks the attributes and functions recognized by the top-level
tailwind configuration.
Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.