JedWatson / JedWatson/react-select

Type error on using a css variable for fontWeight on styles

Open
#5,073 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

awaiting-author-response issue/bug-unconfirmed
Dominant language
TypeScript
Stars
28k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

react-select: 5.2.2

I want to assign as a value a css variable for fontWeight in styles. However the following typescript error appears:

Type '"var(--fontWeights-medium)"' is not assignable to type 'FontWeight | (FontWeight | undefined)[] | ("bold" | Globals | "normal" | "bolder" | "lighter")[] | undefined'.

Example of use:

<Select
  styles={{
    multiValueLabel: (base) => ({
      ...base,
      fontWeight: 'var(--fontWeights-medium)',
    }),
  }}
/>

Contributor guide

Open the contributing guide

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.

Research direction

No file or test is named in the report. Start by locating the TypeScript definitions behind the Select styles prop and inspect how fontWeight is typed. Done means the shown CSS variable value is accepted without losing the existing font-weight type checking.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.