What is the difference between these?
I'm looking at the Typography Component API and there's gutterBottom
and paragraph
props that documented the exact same thing, if true, margin bottom will be 0. Here's the link to the Component API: https://material-ui.com/api/typography/
The em unit for gutterBottom is relative. 1em equals to the font-size of the father component. gutterBottom: { marginBottom: '0.35em', }, paragraph: { marginBottom: 16, }, Second,paragraph is used to choose the basic component of Typography.
You can import <Typography /> component from @material-ui/core using the following code. Important Props and its values: align: It is used to align the text on the component. Example: inherit, left, center, right, or justify.
To line break with Typography, set the display prop to block, which will break the line before the text inside.
There are two parts of difference.
First,the css unit is different.The em unit for gutterBottom is relative.1em equals to the font-size of the father component.
gutterBottom: {
marginBottom: '0.35em',
},
paragraph: {
marginBottom: 16,
},
Second,paragraph is used to choose the basic component of Typography.If paragraph is true ,the Typography is "p".If paragraph is false,check the two default setting, or the Typography will be "span".
const Component =
componentProp ||
(paragraph ? 'p' : headlineMapping[variant] || defaultHeadlineMapping[variant]) ||
'span';
Well they may cause a similar look (0.35em margin vs 16px margin) but they are more concerned with semantics. paragraph
will also result in a p
element rather than a div
element.
The documentation could be improved. Feel free to raise an issue or even open a PR.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With