question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

body font from theme not applying

See original GitHub issue

Describe the bug I’m using gatsby-plugin-theme-ui (with gatsby-starter-default) and using the Styled component from theme-ui and I’m not seeing the fonts change for any “body” components (div, p, etc). What’s strange is that the headings change just fine.

To Reproduce Contents of my src/gatsby-plugin-theme-ui/index.js:

import theme from "@theme-ui/preset-tailwind";

export default {
  ...theme,
  fonts: {
    ...theme.fonts,
    body: "Arial, sans-serif",
    heading: "Arial, sans-serif"
  },
};

Expected behavior I would expect the body fonts to change when I change the body key. As I mentioned the headings do change, so I’m not sure if I’m doing something wrong :\

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
jxnblkcommented, Jan 6, 2020

This is the current behavior (the docs might not be super clear), but the next version will apply some typographic styles to the body element by default, with an option to disable that behavior

2reactions
JaKXzcommented, Jan 25, 2020

@jxnblk thanks for the reply, that makes sense.

So I tried removing Styled.root and just putting this in my theme file as documented, using preset-base:

import theme from "@theme-ui/preset-base";

export default {
  ...theme,
  fonts: {
    ...theme.fonts,
    heading: `'Cochin', 'Libre Baskerville', serif`,
    body: `'Open Sans', ${theme.fonts.body}`,
  },
  styles: {
    root: {
      // uses the theme values provided above
      fontFamily: "body",
      fontWeight: "body",
    },
  },
}

but still no dice, the styles don’t even show up:

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Word 2011: Changing theme does not change font for normal ...
I think I fixed it by modifying the "Normal" style in my document - for the font, I changed it to the "Theme...
Read more >
Custom font isn't loading on custom theme for Material UI
But it isn't working. So I tried to customize the font using plain CSS. I found a workaround removing the overrides property in...
Read more >
Body font size not working: Generatepress Theme
Hi, i m using generatepress theme free version and i m not able to change body font size by using theme>customize>typograpghy.
Read more >
Child theme not working (body) - Support - Themeco Forum
Please navigate to Google Fonts, choose a category and choose an actual font. Then navigate to Theme Options > Typography > Body Font...
Read more >
font-family - CSS: Cascading Style Sheets - MDN Web Docs
You should always include at least one generic family name in a font-family list, since there's no guarantee that any given font is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found