noTailwindRestyledComponents (HTML)
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/noTailwindRestyledComponents - This rule doesn’t have a fix.
- The default severity of this rule is information.
- This rule belongs to the following domains:
- Sources:
- Inspired from
shadcn/no-restyle
- Inspired from
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noTailwindRestyledComponents": "error" } } }}Description
Section titled “Description”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 asbg-red-500andtext-whitetypography, such astext-smandfont-boldspacing, such asp-4andgap-2shape, such asrounded-noneandborder-2effects, such asshadowandopacity-50motion, such astransitionandanimate-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="...".
Examples
Section titled “Examples”Invalid
Section titled “Invalid”<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>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”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 ofcolor,typography,spacing,shape,effects, ormotion. 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.
{ "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>Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.