Skip to content

theme.hardcode border color

github-actions[bot] edited this page Sep 6, 2026 · 2 revisions

theme.hardcode-border-color

Rule ID: theme.hardcode-border-color Severity: WARN Category: theme Target Standards: W3C Design Tokens Community Group (DTCG), Tailwind CSS Border Token Architecture


1. Overview & Core Invariant

Detects hardcoded border and divider colors using primitive palettes, raw hex literals, or static monochrome

Core Invariant:

"Component borders and dividers must use semantic tokens (border-border, border-input), never primitive palette or arbitrary hex colors."


2. Technical Grounding & Engine Realities

Border lines define container elevation, separation, and affordance. When border colors are hardcoded (e.g. border-gray-200, border-[#e5e5e5]):

  1. Invisibility in Dark Mode: A light gray border (#e5e5e5) provides zero contrast or turns into an inverted stark line in dark themes.
  2. Theme Disconnect: When the primary or brand palette changes, borders remain pinned to legacy gray scales.
  3. Inconsistent Boundaries: Disparate components end up using gray-200, slate-200, zinc-300 arbitrarily for identical UI dividers.

Charites enforces using centralized border tokens (border-border, border-input, divide-border).


3. Vulnerability & Risk Taxonomy

Risk Vector Severity Impact
Dark Mode Invisibility HIGH Hardcoded light borders vanish or glow unnaturally on dark theme backgrounds.
Visual Fragmentation MEDIUM Different shades of gray borders destroy cohesive surface elevation hierarchy.

4. Non-Compliant Code Patterns (Bad Examples)

ASTRO (Hardcoded border primitive and arbitrary hex):

<div class="border border-gray-200 divide-y divide-[#e5e5e5]">List</div>

TSX (Primitive directional border in JSX):

export function Card() {
  return <div className="border-t-slate-300 border-x-[#cccccc]">Content</div>;
}

5. Compliant Implementation Patterns (Good Examples)

ASTRO (Using semantic border and divider tokens):

<div class="border border-border divide-y divide-border">List</div>

TSX (Semantic border tokens with dark mode adaptability):

export function Card() {
  return <div className="border-t border-border">Content</div>;
}

6. How to Suppress (Ignore Directives)

If this pattern is required for an intentional exception, suppress the diagnostic using the canonical Charites Rule ID:

<!-- charites:ignore theme.hardcode-border-color intentional exception -->
// charites:ignore theme.hardcode-border-color intentional exception

7. Configuration Reference (charites.yaml)

rules:
  theme.hardcode-border-color:
    severity: warn # error | warn | info | off

8. Architectural Domain & Verification Reference


Rule Categories

A11y (16 rules)
Browser (12 rules)
Cls (16 rules)
Design (1 rules)
Ergonomy (5 rules)
Inp (16 rules)
Lcp (16 rules)
Mobile (5 rules)
Performance (16 rules)
Pwa (10 rules)
Responsive (18 rules)
Semantic (1 rules)
Theme (32 rules)
Ux (20 rules)

Clone this wiki locally