Skip to content

API for CSS variable fallback inside defineConsts and defineVars. #1483

@c5n8

Description

@c5n8

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:

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

stylex.defineConsts({
  myShadow: `0px 1px 1px var(--my-shadow-color, ${vars.myShadowDefaultColor})`,
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions