API for CSS variable fallback inside defineConsts and defineVars.
Open
enhancement
- Dominant language
- JavaScript
- Stars
- 10.3k
- Forks
- 481
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 13
Description
### Describe the feature request
## Feature request
I would like to be able to use fallback for css variables inside defineConsts and defineVars.
## Suggestion 1
I suggest an API like:
```js
stylex.defineConsts({
myShadow: `0px 1px 1px ${stylex.firstThatWorks(vars.myShadowColor, vars.myShadowDefaultColor)}`,
});
```
Which would be compiled to:
```
0px 1px 1px var(--x-myShadowColor, --x-myShadowDefaultColor)
```
## Workaround
```js
stylex.defineConsts({
myShadow: `0px 1px 1px var(--my-shadow-color, ${vars.myShadowDefaultColor})`,
});
```
Contributor guide
Assessment
This issue has not been assessed yet.