Responsive typography
See original GitHub issueI have created a functionality in my theme file to make the typography styles responsive:
Feature description
const mediaSizes = {
smallPhone: 320,
bigPhone: 480,
tablet: 600,
bigTablet: 801,
tabletLaptop: 1025,
desktop: 1281
}
const makeFontSizeResponsive = fontSize => {
const fontNumber = fontSize.slice(0, -2)
const result = {
[mediaQueries['smallPhone']]: { fontSize: `${fontNumber * 0.7}px` },
[mediaQueries['bigPhone']]: { fontSize: `${fontNumber * 0.75}px` },
[mediaQueries['tablet']]: { fontSize: `${fontNumber * 0.8}px` },
[mediaQueries['bigTablet']]: { fontSize: `${fontNumber * 0.85}px` },
[mediaQueries['tabletLaptop']]: { fontSize: `${fontNumber * 0.9}px` },
[mediaQueries['desktop']]: { fontSize: `${fontNumber}px` }
}
return result
}
const newTheme = createTheme({
...,
'typography': {
'font100': {
'fontFamily': 'Helvetica, Arial, sans-serif',
'fontSize': '11px',
'fontWeight': 'normal',
'lineHeight': '1.45em',
...makeFontSizeResponsive('11px')
},
...
}
However these do not work with the baseui typography classes because the fonts prop is filtered by individual keys, and I believe that the styles are also not deep merged. I could create my own custom typography components and probably will due to time, but I think it would be good to allow this. If there is a better way please advise?
See: https://github.com/uber-web/baseui/blob/master/src/block/styled-components.js#L86
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
A guide to responsive typography - UX Collective
Responsive web design is a methodology to create websites that scales and adapts depending up the size of the screen and capabilities of...
Read more >Modern Fluid Typography Using CSS Clamp
Usually, when we implement responsive typography, values change on specific breakpoints. They are explicitly defined.
Read more >Simple solutions to responsive typography - YouTube
In this one, I look at two simple ways to make maintaining your site's typography much simpler!
Read more >Typography - web.dev
Good typography on the web isn't just about the type choices that you make as a designer. Responsive typography is also about respecting...
Read more >How To Create a Responsive Text - W3Schools
Responsive Font Size. The text size can be set with a vw unit, which means the "viewport width". That way the text size...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@asherccohen Ah okay, they are exported in Flow, but not Typescript. Opened #3779.
This section of the theming guide focuses on extending the default theme with new properties: https://baseweb.design/guides/theming/#customizing-the-theme-type