Skip to content

noTailwindRawColors (JavaScript)

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

Disallow Tailwind CSS utility classes that use raw palette colors.

Palette colors such as pink-500 and slate-950 tie styles to specific colors instead of the role those colors play. Design system color names such as primary or muted let a design system change its palette without editing each component. This rule checks color utilities, including variants and opacity modifiers. It allows custom color names, black, white, transparent, current, and inherit. This rule does not check arbitrary values such as bg-[#ff00aa]. It does not read your Tailwind CSS theme, so redefining a default palette name does not exempt it.

<div className="bg-pink-500" />;
code-block.jsx:1:17 lint/nursery/noTailwindRawColors ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This Tailwind CSS class uses a raw palette color.

> 1 │ <div className="bg-pink-500" />;
│ ^^^^^^^^^^^
2 │

ℹ Raw palette colors couple components to specific colors, making design-system changes harder.

ℹ Use a color from your design system. Check your Tailwind config for the available colors.

ℹ This rule is still being actively worked on, so it may be missing features or have rough edges. Visit https://github.com/biomejs/biome/issues/11342 for more information or to report possible bugs.

ℹ 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="hover:text-red-500/80" />;
code-block.jsx:1:23 lint/nursery/noTailwindRawColors ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This Tailwind CSS class uses a raw palette color.

> 1 │ <div className="hover:text-red-500/80" />;
│ ^^^^^^^^^^^^^^^
2 │

ℹ Raw palette colors couple components to specific colors, making design-system changes harder.

ℹ Use a color from your design system. Check your Tailwind config for the available colors.

ℹ This rule is still being actively worked on, so it may be missing features or have rough edges. Visit https://github.com/biomejs/biome/issues/11342 for more information or to report possible bugs.

ℹ 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="bg-primary hover:text-muted-foreground" />;
<div className="bg-white text-black border-transparent fill-current stroke-inherit" />;

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

Default: []

Exact palette colors to allow. Entries are case-sensitive color names, such as slate-950 or pink-500, without utility prefixes, variants, or opacity modifiers. Allowing pink-500 permits it in every color utility, including variants and opacity modifiers; it does not allow other pink shades.

biome.json
{
"linter": {
"rules": {
"nursery": {
"noTailwindRawColors": {
"level": "on",
"options": {
"allowedColors": [
"pink-500"
]
}
}
}
}
}
}
<div className="bg-pink-500 hover:text-pink-500/80 border-black" />;