DEV Community

Cover image for Don't use @font-face in styled-components with GatsbyJS
Philip Schönholzer
Philip Schönholzer

Posted on

2 3

Don't use @font-face in styled-components with GatsbyJS

I recently found out, that using @font-face in styled-components in a gatsbyjs-project causes the page to flicker and request the font on each render. Just move "@font-face" to a font.css file and import it in the layout component. No more flickering!

Demo: https://font-face-styled-components.netlify.app

Top comments (1)

Collapse
 
benrogerson profile image
Ben Rogerson

Styled components recommends font-display: fallback; to take care of the flicker.
styled-components.com/docs/faqs#ho...

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay