Skip to content

noTailwindArbitraryValue (HTML)

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.

Arbitrary variants, such as [&_svg]:size-4, and arbitrary modifiers, such as /[0.5] in bg-black/[0.5], are not reported.

<div class="w-[400px]"></div>
code-block.html:1:15 lint/nursery/noTailwindArbitraryValue ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ Found an arbitrary value in a Tailwind CSS class.

> 1 │ <div class="w-[400px]"></div>
│ ^^^^^^^
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 class="text-[#555] bg-white"></div>
code-block.html:1:18 lint/nursery/noTailwindArbitraryValue ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ Found an arbitrary value in a Tailwind CSS class.

> 1 │ <div class="text-[#555] bg-white"></div>
│ ^^^^^^
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 class="[color:red]"></div>
code-block.html:1:13 lint/nursery/noTailwindArbitraryValue ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ Found an arbitrary value in a Tailwind CSS class.

> 1 │ <div class="[color:red]"></div>
│ ^^^^^^^^^^^
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 class="w-4 text-red-500 bg-white"></div>
<div class="[&:nth-child(3)]:px-2 bg-black/[0.5]"></div>

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

Default: []

Categories of utilities that may use arbitrary values:

  • layout, such as w-[320px], m-[13px], and top-[3px]
  • color, such as bg-[#333]
  • typography, such as text-[13px]
  • spacing, such as p-[13px] and gap-[3px]
  • shape, such as rounded-[10px] and border-[3px]
  • effects, such as shadow-[0_1px_2px_black] and opacity-[0.15]
  • motion, such as duration-[250ms]

An arbitrary property belongs to the category of the CSS property it sets, so [padding:13px] is in spacing.

biome.json
{
"linter": {
"rules": {
"nursery": {
"noTailwindArbitraryValue": {
"level": "on",
"options": {
"allowedCategories": [
"layout"
]
}
}
}
}
}
}
<div class="w-[320px] m-[13px]"></div>
<div class="p-[13px]"></div>
code-block.html:1:15 lint/nursery/noTailwindArbitraryValue ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ Found an arbitrary value in a Tailwind CSS class.

> 1 │ <div class="p-[13px]"></div>
│ ^^^^^^
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.

Default: []

Classes that may use arbitrary values. Write each class without variants or !. An allowed class is also allowed with variants and !, so allowing p-[13px] also allows md:p-[13px] and p-[13px]!.

biome.json
{
"linter": {
"rules": {
"nursery": {
"noTailwindArbitraryValue": {
"level": "on",
"options": {
"allowedClasses": [
"p-[13px]"
]
}
}
}
}
}
}
<div class="p-[13px] md:p-[13px]"></div>
<div class="p-[15px]"></div>
code-block.html:1:15 lint/nursery/noTailwindArbitraryValue ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ Found an arbitrary value in a Tailwind CSS class.

> 1 │ <div class="p-[15px]"></div>
│ ^^^^^^
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.