I want to style an MUI Button using styled-components. I want to pass variant='outlined' as a prop to the component. Here's what I'm trying:
export const StyledButton = styled(Button).attrs(() => ({
variant: 'outlined',
}))
I want to style an MUI Button using styled-components. I want to pass variant='outlined' as a prop to the component. Here's what I'm trying:
export const StyledButton = styled(Button).attrs(() => ({
variant: 'outlined',
}))
To pass attributes you have to do something like this:
const StyledButton = styled(Button)`
background-color: #6772e5;
color: #fff;
box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08);
padding: 7px 14px;
&:hover {
background-color: #5469d4;
}
`;
export default function StyledComponent() {
return (
<StyledButton variant="outlined">Customized</StyledButton>
);
}
For more, you can refer to offical Doc