我这样使用cva:
export const checkboxVariants = cva('border ...', {
variants: {
size: {
sm: 'h-4 w-4',
md: 'h-5 w-5',
lg: 'h-6 w-6',
},
},
defaultVariants: {
size: 'md',
},
});
和
type CheckboxProps = VariantProps<typeof checkboxVariants>
但是在检查组件 props 时,我可以看到也允许 null 值,并且如果传递 null 则不会应用任何大小类。
如何从可用值中删除 null?
一个问题是在使用中,另一个问题是在故事书中,因为它表明允许 null 并且看起来不太好:
我在cva github上留下了询问并收到了下面的回复。 https://github.com/joe-bell/cva/issues/253
朋友们,我想很快就会有补丁。
或者,这里也是替代方案。 从类型的属性中删除 null 或未定义