joe-bell / cva

Class Variance Authority
https://cva.style
Apache License 2.0
5.46k stars 107 forks source link

Flag variant #237

Closed dy closed 8 months ago

dy commented 8 months ago

We can see sometimes components use flag property, like

<Navigation transparent />
<Button size="md" icon />

So that some classes get added conditionally by presence of that flag. Would be nice cva to be able to do something like

const buttonVariants = cva('', {
  variants: {
    ...
    // flag variant that reduces paddings
    icon: 'px-2'
  }
})
dy commented 8 months ago

I guess it can be used now as

variants: {
    ...
    icon: { true: 'px-2'}
  }