[react] Design tokens are defined on `:root`, so generic names like `--radius-md` leak into the host app

Open
#4,773 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
react, typescript
Domain
frontend

Research direction

Start by locating the @graphiql/react stylesheet rules that define tokens on :root, including the theme, density, and font-size blocks. Check how dialogs and portals are styled and run the relevant stylesheet tests or checks you find in the repository. Done means GraphiQL tokens no longer affect unrelated host app styles, including Tailwind v4 variables, while remaining available to GraphiQL.

Written by the indexing model from the issue text.

Description

@graphiql/react 1.0.2's stylesheet defines its design tokens on :root (:root, [data-theme="dark"] { ... }, plus the density and font-size blocks). Several have generic names, like --radius-sm/--radius-md/--radius-lg, --font-family, --font-size-body and --px-*.

Once the stylesheet is loaded they apply to the whole page, not just GraphiQL, and in a single-page app they stay after you leave the GraphiQL page. --radius-md is also a Tailwind v4 theme variable, so it changes rounded-md (and anything else using var(--radius-md)) across the app.

Could the tokens be scoped to .graphiql-container (and its dialogs/portals), or prefixed (e.g. --graphiql-radius-md)?

Dominant language
TypeScript
Stars
16.9k
Forks
1.9k
Avg merge
14h 1m
Merged PRs (30d)
81

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from graphql/graphiql

All issues in graphql/graphiql

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.