Skip to content

How do I get style values ​​from the theme function? #100

Answered by sastan
lamualfa-client asked this question in Q&A
Discussion options

You must be logged in to vote

🤦 Sorry. I did change the theme function to be a helper. There is currently no equivalent API but I'm planing to add it back.

For the moment you can use this code to get a theme function as you know it:

let theme
tw((context) => {
  theme = context.theme
  return ''
})

theme('colors.gray.500')
theme('padding', 'l-3')

The idea behind the change was to only provide helper functions that are used with tw. I understand that at least access to the theme is often needed.

In the next release we will have a "native" theme accessor. The following API is on my mind:

tw.theme('colors.gray.500')
tw.theme('padding', 'l-3')

This would make clear which theme values are accessed. There may be other cont…

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@lamualfa-client
Comment options

@sastan
Comment options

@sastan
Comment options

@lamualfa-client
Comment options

@sastan
Comment options

Answer selected by lamualfa-client
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants