color-no-hex
Disallow hex colors.
a { color: #333 }/** ↑ * This hex color */Use this rule to enforce a convention. For example, disallow hex colors in favor of oklch(), whose channels you can read and compare.
This rule supports 1 message argument: the disallowed hex color.
Options
Section titled “Options”{ "color-no-hex": true}The following patterns are considered problems:
a { color: #000; }a { color: #fff1aa; }a { color: #123456aa; }Hex values that are not valid also cause problems:
a { color: #foobar; }a { color: #0000000000000000; }The following patterns are not considered problems:
a { color: black; }a { color: rgb(0, 0, 0); }a { color: rgba(0, 0, 0, 1); }Optional secondary options
Section titled “Optional secondary options”ignoreFunctions
Section titled “ignoreFunctions”{ "ignoreFunctions": ["array", "of", "functions", "/regex/"] }Ignore hex colors within the specified functions.
Given:
{ "color-no-hex": [true, { "ignoreFunctions": ["var", "/^--/"] }]}The following patterns are not considered problems:
a { color: var(--foo, #fff); }a { color: --foo(#fff); }