-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Typography] Make it easy to change the font-weight #12704
Comments
FWIW, I would expect such a feature to work as follows: const enum FontWeight {
Light = 300,
Normal = 400,
...
}
interface TypographyProps {
// possibly just "weight" for simplicity?
fontWeight?: FontWeight;
...
}
const LightText = props => <Typography fontWeight={FontWeight.Light} {...props} />; where any (valid) value passed to the |
There is with You could also change the variants globally with a custom theme. I'm skeptic about a component that should handle all possible typography related css properties. |
@eps1lon and don't you think that's a lot of code just to make something bold? With Italics don't have variations so And |
I think that this component should only implement the material design typography spec. The spec lists different variants with various combinations of weight and size. Everything beyond that should belong into userland and can be done easily thanks to reacts composition model. |
I think this is covered by our @oliviertassinari Do you think we can close this issue or is there something else we could do? |
Box looks great, that definitely solves the problem for bold text. That being said I think a good addition to Box could be If you think that's relevant it could probably be moved to a different issue though. |
New properties can be proposed via PR to https://github.com/mui-org/material-ui/blob/5b25ed3bb0c3639f8ce8204e20ab1e354f63bde2/packages/material-ui-system/src/typography.js#L36 |
Still not easy as of today. Suggested approach https://material-ui.com/system/typography/#main-content does not seem to work. |
The best approach to have both is currently using a Box with fontweight and inside it, use a typography with fontweight: inherit.
|
@BiggA94 |
Please, this would be great and would make a lot of sense, just to pass a prop to the Typography component |
Agree with Louis, though I do find that I often just need to make parts of |
This will work: <p>
Hello
<Box component="span" fontWeight={700}>
world
</Box>
</p> https://codesandbox.io/s/bitter-haze-kwnrv?file=/src/App.tsx |
@alexandermckay In v5, you will get: <Typography sx={{ fontWeight: 'bold' }} /> where bold is taken from |
I believe there is currently no way to change the
font-weight
withTypography
.With Roboto, we have access to 4 font-weight variations:
When using
<b>
or<strong>
, the browser defaults to the bolder variation (which is too bold and inelegant in my opinion). To use the boldfont-weight: 500
or the light variation, we have to create custom styles.It would be neat if
Typography
supported changing thefont-weight
, or if there was aFontWeight
component of some sort.I have implemented it here.
Examples
Bold
Bolder
Comparison
The text was updated successfully, but these errors were encountered: