Skip to content

noTailwindArbitraryValue (JavaScript)

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

Disallow arbitrary values in Tailwind CSS utility classes.

Arbitrary values (e.g. w-[400px], text-[#555]) and arbitrary properties (e.g. [color:red]) bypass Tailwind’s configured theme scales. This rule reports them so teams can keep styling constrained to named utilities from their Tailwind configuration.

<div className="w-[400px]" />;
code-block.jsx:1:19 lint/nursery/noTailwindArbitraryValue ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Found an arbitrary value in a Tailwind CSS class.

> 1 │ <div className="w-[400px]" />;
^^^^^^^
2 │

Arbitrary values bypass Tailwind's theme configuration, defeating design-system consistency and making styles harder to refactor.

Use a named utility from your Tailwind configuration 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.

<div className="text-[#555] bg-white" />;
code-block.jsx:1:22 lint/nursery/noTailwindArbitraryValue ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Found an arbitrary value in a Tailwind CSS class.

> 1 │ <div className="text-[#555] bg-white" />;
^^^^^^
2 │

Arbitrary values bypass Tailwind's theme configuration, defeating design-system consistency and making styles harder to refactor.

Use a named utility from your Tailwind configuration 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.

<div className="[color:red]" />;
code-block.jsx:1:17 lint/nursery/noTailwindArbitraryValue ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Found an arbitrary value in a Tailwind CSS class.

> 1 │ <div className="[color:red]" />;
^^^^^^^^^^^
2 │

Arbitrary values bypass Tailwind's theme configuration, defeating design-system consistency and making styles harder to refactor.

Use a named utility from your Tailwind configuration 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.

<div className="w-4 text-red-500 bg-white" />;
<div className="[&:nth-child(3)]:px-2" />;

By default, this rule checks the class and className JSX attributes. The attributes option adds more JSX attributes to check, and functions enables checking string arguments and tagged templates in matching utilities.

biome.json
{
"linter": {
"rules": {
"nursery": {
"noTailwindArbitraryValue": {
"level": "on",
"options": {
"attributes": [
"classList"
],
"functions": [
"clsx"
]
}
}
}
}
}
}

Additional JSX attribute names to check.

Default: [] (the class and className attributes are always checked).

Function or tagged template names whose classes will be checked for arbitrary values.

Default: [].

<div className={clsx("w-[400px]")} />;
code-block.jsx:1:25 lint/nursery/noTailwindArbitraryValue ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Found an arbitrary value in a Tailwind CSS class.

> 1 │ <div className={clsx("w-[400px]")} />;
^^^^^^^
2 │

Arbitrary values bypass Tailwind's theme configuration, defeating design-system consistency and making styles harder to refactor.

Use a named utility from your Tailwind configuration 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.