@material-ui/styles
offers a different way to customize default styles:
import React from 'react';
import Box from '@material-ui/core/Box';
import { styled } from '@material-ui/core/styles';
const StyledBox = styled(Box)({
color: 'red'
});
With Box
behaving like <div />
by default, we can change it by passing the component
prop:
// somewhere in code
<StyledBox
component="span"
>
Some text
</StyledBox>
However, trying to define a component for Box while styling like below will not work:
import React from 'react';
import Box from '@material-ui/core/Box';
import { styled } from '@material-ui/core/styles';
const StyledBox = styled(<Box component="span" />)({
color: 'red'
});
Is there a method to set a component definition for Box during the styling phase using styled
?