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 (theme) => value function in theme specification #2066

Open
benface opened this issue Jan 7, 2022 · 2 comments
Open

Support (theme) => value function in theme specification #2066

benface opened this issue Jan 7, 2022 · 2 comments

Comments

@benface
Copy link

benface commented Jan 7, 2022

Is your feature request related to a problem? Please describe.
I was expecting the following to work in my theme object:

borders: {
  text: (theme) => '1px solid ${theme.colors.text}',
},

Unfortunately, it doesn’t. border: 'text' doesn’t render anything.

Describe the solution you'd like
It would be nice if that was supported.

Describe alternatives you've considered
I can hardcode the value like this:

borders: {
  text: '1px solid black',
},

But in this case, the text color changes depending on the color mode, so instead of border: 'text' in my sx prop, I have no choice but to do border: (theme) => '1px solid ${theme.colors.text}' every time I want such a border. Not ideal.

Additional context
Thank you so much!

@hasparus
Copy link
Member

hasparus commented Jan 7, 2022

As a workaround, you can do the following if you didn't turn off useCustomProperties:

borders: {
  text: '1px solid var(--theme-ui-colors-primary)'
}

@benface
Copy link
Author

benface commented Jan 8, 2022

Oh @hasparus 🤦‍♂️

That works perfectly, thank you!

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

2 participants