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.

Over sized icons on each page refresh

See original GitHub issue

Hi,

I’m suing react-fontawesome with gatsby js for my site. After the static site is generated, on each page refresh, icons are displayed with its maximum size and goes back to the given size when the site is loaded completely.

I’m using the icons as below,

import FontAwesomeIcon from '@fortawesome/react-fontawesome' import faEnvelope from '@fortawesome/fontawesome-free-solid/faEnvelope' import faDownload from '@fortawesome/fontawesome-free-solid/faDownload'

<div className={styles.body}>
        <button className={styles.button}>
          <a target="_blank" href={PDF}>
            <FontAwesomeIcon icon={faDownload} size="1x" /> download
          </a>
        </button>
        <button className={styles.button}>
          <a href="mailto:a@a.com">
            <FontAwesomeIcon icon={faEnvelope} size="1x" /> Mail me!
          </a>
        </button>
</div>

Styles

.button{ width:20%; min-width: 150px; background: none; color: #02B3E4; border:1px solid #02B3E4; margin:10px 20px ; border-radius:100px; }

I’m not entirely sure this behavior is because of gatsby or the way I use font-awesome components. You can view the issue here : https://iamsuneeth.github.io/

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:11
  • Comments:27 (4 by maintainers)

github_iconTop GitHub Comments

74reactions
paustintcommented, Sep 15, 2018

@asifkabani - I am using Gatsby for the landing page of my application and ran into the same problem you describe. I fixed this by doing the following:

(Note: I am using typescript, so adjust as needed for JSX) In layouts/index.tsx import the CSS in your layout(s) to make sure that it loads first, before any attempt to render an icon.

import * as React from 'react';
...
// this ensures that the icon CSS is loaded immediately before attempting to render icons
import '@fortawesome/fontawesome-svg-core/styles.css';
...
43reactions
jeanregissercommented, Mar 12, 2019

Adding to what @paustint said for Gatbsy, you should preferably also prevent fontawesome from dynamically adding its css so you don’t have duplicate classes:

// This ensures that the icon CSS is loaded immediately before attempting to render icons
import "@fortawesome/fontawesome-svg-core/styles.css";
import { config } from "@fortawesome/fontawesome-svg-core";
// Prevent fontawesome from dynamically adding its css since we did it manually above
config.autoAddCss = false;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Why my font-awesome icons are being displayed big at first ...
Seems like the css in being loaded before applying the proper size because right after the refresh it shows big, and then goes...
Read more >
Icons randomly change sizes. - Microsoft Community
Icons randomly change sizes. I have my desktop icons set to Large and all of the programs / shortcuts have 256x256 icons. They...
Read more >
iPadOS 15 malfunctioning Use-Large-Icons - Apple Discussions
This iPad icon size control has been changed in iPadOS 15 at - Settings > Home Screen & Dock > Home Screen to...
Read more >
Stop Windows 10 Desktop Icons from Changing Location After ...
That's it! If you want to confirm it works, move an icon to any location on your desktop, then right-click the desktop and...
Read more >
How to Change Size of Icons on Android - Lifewire
On the Home screen grid page, use the icons along the bottom to adjust how many icons you want to appear ...
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