noTailwindRestyledComponents (JavaScript)
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 Button, member names
such as UI.Button, and custom elements with hyphenated names such as my-button.
Native elements are not checked. The rule checks class and className,
including literal branches of conditionals and common class helper calls.
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”<Button className="rounded-none" />;code-block.jsx:1:20 lint/nursery/noTailwindRestyledComponents ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This Tailwind utility restyles a component.
> 1 │ <Button className="rounded-none" />;
│ ^^^^^^^^^^^^
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.
<Button variant="danger" className="mt-4 w-full" />;<button className="rounded-none" />;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 UI and Button match
UI.Button. Dotted names such as UI.Button match consecutive segments.
{ "linter": { "rules": { "nursery": { "noTailwindRestyledComponents": { "level": "on", "options": { "allow": [ { "components": "Button", "categories": [ "shape" ], "classes": [ "hover:shadow-lg" ] } ] } } } } }}<Button className="rounded-none hover:shadow-lg" />;Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.