Repository navigation
Is there any way to pass custom values into the cva function? #47
|
Just like in the question. Can I for example provide the custom color and based on this the render the classes? const base = (color: string) => cn(`bg-${color}`);But since the variable we create with Essentially what I want to achieve: export const button = (color:string) => cva('font-family:outfit py:12 px:16', {
variants: {
type: {
blank: '',
outlined: 'border:1|solid',
filled: 'border:1|solid',
},
backgroundColor: {
primary: '#fff',
secondary: '#000',
accent: '#222',
custom: color
},
},
defaultVariants: {
type: 'outlined',
},
}); |
Answered by
joe-bell
Oct 20, 2022
Replies: 1 comment 3 replies
|
Sure you can, but you just need to make sure those classes exist — Tailwind’s JIT engine doesn’t support dynamic strings, but there’s no reason you couldn’t pre-define these somewhere else |
3 replies
Answer selected by
joe-bell
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sure you can, but you just need to make sure those classes exist — Tailwind’s JIT engine doesn’t support dynamic strings, but there’s no reason you couldn’t pre-define these somewhere else