Function that transforms tw string to CSS rules object? #13768
Answered
by
wongjn
piscopancer
asked this question in
Help
-
I want to use classes inside my config like so plugins: [
plugin(({ addUtilities }) => {
addUtilities({
'.fancy': twToObject('bg-red-100 text-red-500 font-semibold'),
})
}),
], So I need a function like above. I wonder if tailwind has such function internally which i can use in my code too |
Beta Was this translation helpful? Give feedback.
Answered by
wongjn
May 30, 2024
Replies: 2 comments
-
You could use plugins: [
plugin(({ addUtilities }) => {
addUtilities({
'.fancy': {
'@apply bg-red-100 text-red-500 font-semibold': {},
},
})
}),
], Though Adam Wathan, the creator of Tailwind, does not recommend this: #11012 (reply in thread). |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
piscopancer
-
@wongjn father of tailwind may not recommend it, but still i see it as a way to go, thanks! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could use
@apply
as you would in CSS:Though Adam Wathan, the creator of Tailwind, does not recommend this: #11012 (reply in thread).