Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Material UI - gutterBottom vs paragraph, difference?

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/

like image 960
hellomello Avatar asked Nov 07 '18 04:11

hellomello


People also ask

What is gutterBottom in material UI?

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.

How do you use Typography in material UI?

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.

How do you add a new line in Typography material UI?

To line break with Typography, set the display prop to block, which will break the line before the text inside.


2 Answers

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';
like image 141
Root Avatar answered Oct 18 '22 21:10

Root


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.

like image 44
epsilon Avatar answered Oct 18 '22 21:10

epsilon