When using extendVariants
to inherit components, if defaultVariants
is set, it cannot be overridden. Is this the expected behavior?
#1540
-
I want to use custom components to extend the default styles of NextUI components. However, when I use import { Button as NextUiButton } from '@nextui-org/button';
import { extendVariants } from '@nextui-org/system-rsc';
export const Button = extendVariants(NextUiButton, {
defaultVariants: {
color: 'primary',
},
variants: {
color: {
primary: 'hover:bg-primary-400 active:bg-primary-600',
},
},
}); <Button>Primary</Button>
// Unable to set color, it still renders the primary button.
<Button color="default">Default</Button> When I changed to use import { Button as NextUiButton } from '@nextui-org/button';
import { extendVariants } from '@nextui-org/system-rsc';
export const Button = extendVariants(NextUiButton, {
compoundVariants: [
{
className: 'hover:bg-primary-400 active:bg-primary-600',
color: undefined,
},
],
variants: {
color: {
default: 'bg-default-200 hover:bg-default-100 active:bg-default-300',
primary: 'hover:bg-primary-400 active:bg-primary-600',
},
},
});
NextUiButton.defaultProps = {
color: 'primary',
}; |
Beta Was this translation helpful? Give feedback.
Answered by
jrgarciadev
Sep 1, 2023
Replies: 2 comments
-
Hey @u3u this is not intended it should support the default properties variants, I'll transform this into an issue, thanks for reporting it. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
u3u
-
Hi @jrgarciadev, does that issue also the same reason ? |
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
Hey @u3u this is not intended it should support the default properties variants, I'll transform this into an issue, thanks for reporting it.