Color roles and contrast
Load when defining colour roles, palettes, contrast or light and dark themes.
skills/design-skill/references/core-color-rules.mdLoad when defining colour roles, palettes, contrast or light and dark themes. Requirement = correctness/accessibility obligation; Pattern = adaptable starting point; Taste hypothesis = design judgment to validate in context.
Choose roles before counts
- Confidence Level: Pattern
- Purpose: Make color communicate coherent meaning.
- Reasoning: A palette count cannot determine whether a screen is useful or expressive.
- Constraint: Define background, surface, text, action, focus and semantic roles. Allow categorical colors and expressive brand palettes when their roles remain legible. Check how nearby colors compete. No universal single-accent or two-text-color lock.
- Example:
- Bad: Remove half the legend categories to obey a three-color rule.
- Good: Use distinct category colors plus labels and shapes; reserve a strong action treatment for the next task.
- Exceptions: Patterns may change when the product, user constraints or observed evidence justify it. Requirements remain.
Measure contrast in context
- Confidence Level: Requirement
- Purpose: Keep text and essential controls readable.
- Reasoning: A hex value alone does not establish contrast over imagery or transparency.
- Constraint: Check rendered combinations: normal text 4.5:1, large text 3:1, applicable essential UI boundaries and graphics 3:1. Use WCAG definitions of large text. Do not communicate meaning by color alone. Check focus, code, error and both themes.
- Example:
- Bad: A red dot alone means an overdue task.
- Good: Show “Overdue” with an icon and measured contrast.
- Exceptions: Inactive controls and other WCAG exceptions have specific conditions; do not extend them to readable active content.
Deliberate themes
- Confidence Level: Pattern
- Purpose: Retain hierarchy across modes.
- Reasoning: Dark mode needs its own surfaces, text and semantic colors.
- Constraint: Design each supported mode; avoid CSS inversion. Pure white or black page bases are valid when requested. Differentiate surfaces through borders, spacing, tint or elevation as appropriate. Respect the project's theme contract and persist explicit choices.
- Example:
- Bad: Invert all colors and assume dark charts remain readable.
- Good: Check every semantic and code color against its actual dark surface.
- Exceptions: Patterns may change when the product, user constraints or observed evidence justify it. Requirements remain.
Build palettes systematically
- Confidence Level: Pattern
- Purpose: Get predictable steps and contrast instead of guessing hex codes.
- Reasoning: Hand-picked shades drift in lightness and saturation; perceptual spaces keep steps even.
- Constraint: Build ramps in OKLCH and expose them through semantic tokens; see design tokens for the token set, dark-mode rules and Tailwind/shadcn mapping, and data visualization for categorical, sequential and diverging chart palettes. Tint neutrals slightly toward the brand hue. Accent usage: primary action, links, focus and one highlight; status colours only for status.
- Example:
- Bad: Seven blues picked by eye, two of them indistinguishable, the link blue failing 4.5:1.
- Good: An OKLCH ramp with even lightness steps, with
accentandlinktaken from measured steps.
- Exceptions: A supplied brand palette; derive the missing steps around it.