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

Allow referencing other CSS variables #39

Open
maxsalven opened this issue Mar 5, 2024 · 2 comments · May be fixed by #40
Open

Allow referencing other CSS variables #39

maxsalven opened this issue Mar 5, 2024 · 2 comments · May be fixed by #40
Assignees
Labels
enhancement New feature or request

Comments

@maxsalven
Copy link

My app uses javascript to dynamically set some CSS variables, like a --brand color (in HSL).

It would be great if we could reference these in tw-colors:

createThemes({
   'light': light({ 
      'button-primary-bg': 'var(--brand)',
   }),
   'dark': dark({ 
      'button-primary-bg': 'steelblue',
   }),
})
@L-Blondy L-Blondy added the enhancement New feature or request label Mar 5, 2024
@L-Blondy L-Blondy self-assigned this Mar 5, 2024
@maxsalven
Copy link
Author

As a follow up, being able to set opacity alongside a variable reference would be great too. Am not sure what the syntax would look like.

createThemes({
   'light': light({ 
      'button-primary-bg': 'var(--brand)',
      'button-primary-bg-opacity': '0.5',
      // or perhaps
      'button-primary-bg': 'var(--brand) / 0.5',
   }),
})

Thanks!

@maxsalven maxsalven linked a pull request Mar 6, 2024 that will close this issue
@L-Blondy
Copy link
Owner

L-Blondy commented Mar 6, 2024

Since var(--brand) is a color and not just hsl values, the default opacity should be set on the --brand variable directly.

While it is technically doable, I've got to think carefully whether or not I want to add support for css variables: it might be a blocker for future features.

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

Successfully merging a pull request may close this issue.

2 participants