src/content/docs/linter/rules/no-hex-colors.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="CSS" icon="seti:css"> :::caution This rule is part of the [nursery](/linter/#nursery) group. This means that it is experimental and the behavior can change at any time. ::: ## Summary - Rule available since: `v2.3.14` - Diagnostic Category: [`lint/nursery/noHexColors`](/reference/diagnostics#diagnostic-category) - This rule doesn't have a fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - Sources: - Same as [`color-no-hex`](https://github.com/stylelint/stylelint/blob/main/lib/rules/color-no-hex/README.md){
"linter": {
"rules": {
"nursery": {
"noHexColors": "error"
}
}
}
}
Disallow hex colors.
While hex colors are widely supported and compact, they can be less readable and have limitations in terms of color representation compared to color models like HSL or OKLCH. This rule encourages the use of more expressive color formats.
This rule is inspired by the Stylelint rule
color-no-hex.
a { color: #000; }
a { color: #fff1aa; }
a { color: #123456aa; }
a { color: black; }
a { color: rgb(0, 0, 0); }