Skip to content

noTailwindRestyledComponents (HTML)

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

Disallow Tailwind utilities that override the appearance of components.

A design system should own its components’ appearance. Use component props for supported visual variants instead of overriding them with utility classes.

The rule reports utilities in these categories:

  • color, such as bg-red-500 and text-white
  • typography, such as text-sm and font-bold
  • spacing, such as p-4 and gap-2
  • shape, such as rounded-none and border-2
  • effects, such as shadow and opacity-50
  • motion, such as transition and animate-spin

Variants, important modifiers, and arbitrary values don’t change the category, so hover:bg-red-500, rounded-none!, and p-[3px] are reported too. Arbitrary properties that set these styles, such as [font-size:14px], are also reported. Other utilities, such as sizing, positioning, and margins, are ignored.

Components are elements with capitalized names such as MyButton and custom elements with hyphenated names such as my-button. Native elements are not checked. The rule checks static class attributes. In Astro, Svelte, and Vue files, it also checks class expressions such as class={...}, Astro’s class:list={...}, and Vue’s :class="...".

<my-button class="rounded-none"></my-button>
code-block.html:1:19 lint/nursery/noTailwindRestyledComponents ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This Tailwind utility restyles a component.

> 1 │ <my-button class="rounded-none"></my-button>
│ ^^^^^^^^^^^^
2 │

ℹ The design system should manage the component's appearance.

ℹ Use a supported component variant or move this style into the component's definition.

ℹ 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.

<my-button variant="danger" class="mt-4 w-full"></my-button>
<button class="rounded-none"></button>

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

Default: [].

Allows categories or classes on selected components. Each entry contains:

  • components: a component name, an array of names, or "*" for all components.
  • categories: any of color, typography, spacing, shape, effects, or motion. Default: [].
  • classes: exact classes, including variants and modifiers. Default: [].

A name matches any segment of a member name, so both Card and Root match Card.Root. Dotted names such as Card.Root match consecutive segments.

biome.json
{
"linter": {
"rules": {
"nursery": {
"noTailwindRestyledComponents": {
"level": "on",
"options": {
"allow": [
{
"components": [
"my-button",
"MyButton"
],
"categories": [
"shape"
],
"classes": [
"hover:shadow-lg"
]
}
]
}
}
}
}
}
}
<my-button class="rounded-none hover:shadow-lg"></my-button>
<MyButton class="rounded-none hover:shadow-lg"></MyButton>