crashappsec / crashappsec/react-registry

theme tokens.css puts bare element rules outside @layer base, defeating every Tailwind colour utility on <a>

Open Beginner friendly
#12 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Installing any `@crashoverride` item pulls in the `theme` style item, whose `tokens.css` writes bare element rules **outside any cascade layer**:

```css
a { color: var(--text-emphasis); text-decoration: none; }
a:hover { text-decoration: underline; }
```

Tailwind puts its utilities in `@layer utilities`, and an unlayered element rule beats any layered rule regardless of specificity or source order. So in a consuming app every colour utility applied to an `` is silently defeated — `text-primary-foreground`, `text-muted-foreground`, all of them. COMPASS hit this as a button-shaped link rendering lime-on-lime: computed colour `rgb(179, 255, 0)` on an `oklch(0.93 0.25 124)` background, invisible.

The same applies to the unlayered `.co-eyebrow`, `.co-accent-underline`, and `.co-tagline .t-*` rules in the same file.

Fix is to wrap them in `@layer base`, which changes nothing about the default appearance (an anchor with no colour utility still resolves to `--text-emphasis`) and only lets a utility win when one is present — which is what the design system assumes everywhere else.

COMPASS carries that fix locally in `ui/src/app/tokens.css` and pins it with a test, so a `shadcn add` that answers "yes" to the `tokens.css` overwrite prompt currently reintroduces the bug. Found while wiring `components.json` for registry adoption (crashappsec/compass#935).

Two notes for anyone reproducing:

- jsdom does not resolve cascade layers, so a unit test cannot catch this class of bug.
- Comparing two computed colour strings can pass vacuously — `rgb(179, 255, 0)` and `oklch(0.93 0.25 124)` are the same colour in two notations. Rasterise both and assert a real WCAG ratio.

Contributor guide

Open the contributing guide

Research direction

Start with the theme style item's tokens.css and compare it with COMPASS's ui/src/app/tokens.css, which carries the local fix. Reproduce the installed theme in a consuming app rather than relying on jsdom. Done means default anchor styling remains intact, Tailwind colour utilities win where applied, and a rasterized contrast check confirms the visible result.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, tailwindcss
Domain
accessibility, design, frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.