Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for CSS variable declarations with dynamic property names and values #25

Open
jantimon opened this issue Oct 30, 2024 · 0 comments

Comments

@jantimon
Copy link

When using CSS custom properties (CSS variables) with styled-components, there are cases where we need both the property name and value to be dynamic expressions. Currently, the plugin throws a syntax error for this use case.

Works:

const StyledComponent = styled.div`
  ${prop}: red;           // Dynamic property name works
  color: ${value};        // Dynamic value works
  ${varName}: blue;     // Dynamic CSS variable name works
  color: var(--${name});  // Dynamic CSS variable reference works
`

Fails with } expected error:

const StyledComponent = styled.div`
  ${varName}: ${value};  // Error when both property name and value are dynamic
`

Could you please add support for cases where both the property name and value are template expressions?

I can submit a PR with the implementation if this helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant