noTailwindArbitraryValue (JavaScript)
Summary
Section titled “Summary”- Rule available since:
v2.5.7 - Diagnostic Category:
lint/nursery/noTailwindArbitraryValue - This rule doesn’t have a fix.
- The default severity of this rule is information.
- This rule belongs to the following domains:
- Sources:
- Same as
tailwindcss/no-arbitrary-value - Inspired from
shadcn/no-arbitrary-values
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noTailwindArbitraryValue": "error" } } }}Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”<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 bg-black/[0.5]" />;Recognized class strings
Section titled “Recognized class strings”This rule checks the attributes and functions recognized by the top-level
tailwind configuration.
Options
Section titled “Options”allowedCategories
Section titled “allowedCategories”Default: []
Categories of utilities that may use arbitrary values:
layout, such asw-[320px],m-[13px], andtop-[3px]color, such asbg-[#333]typography, such astext-[13px]spacing, such asp-[13px]andgap-[3px]shape, such asrounded-[10px]andborder-[3px]effects, such asshadow-[0_1px_2px_black]andopacity-[0.15]motion, such asduration-[250ms]
An arbitrary property belongs to the category of the CSS property it sets, so [padding:13px] is in spacing.
{ "linter": { "rules": { "nursery": { "noTailwindArbitraryValue": { "level": "on", "options": { "allowedCategories": [ "layout" ] } } } } }}<div className="w-[320px] m-[13px]" />;<div className="p-[13px]" />;code-block.jsx:1:19 lint/nursery/noTailwindArbitraryValue ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Found an arbitrary value in a Tailwind CSS class.
> 1 │ <div className="p-[13px]" />;
│ ^^^^^^
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.
allowedClasses
Section titled “allowedClasses”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]!.
{ "linter": { "rules": { "nursery": { "noTailwindArbitraryValue": { "level": "on", "options": { "allowedClasses": [ "p-[13px]" ] } } } } }}<div className="p-[13px] md:p-[13px]" />;<div className="p-[15px]" />;code-block.jsx:1:19 lint/nursery/noTailwindArbitraryValue ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Found an arbitrary value in a Tailwind CSS class.
> 1 │ <div className="p-[15px]" />;
│ ^^^^^^
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.
Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.