Desktop display issue: Fontawesome icon not appearing

Having trouble getting the fontawesome icon to display properly on my website. It appears in inspect mode, but not on the actual site itself.

Any suggestions on how to fix this issue?

import React, { Fragment, useState} from "react";
import { NavLink } from "react-router-dom";
import "../styles/common/Navbar.css";


const Navbar = () => {
    const [showMenu, setShowMenu] = useState(false);

    return (
      <Fragment>
          <nav>
              <a href="/">
              <h1>AnRa<span>Caribbean</span></h1>
              </a>
              <div className={showMenu ? "menu mobile-menu" : "menu"}>
                  <ul>
                      <li><NavLink to="/">Home</NavLink></li>
                      <li><NavLink to="/PropertiesForSale">Buy a Property</NavLink></li>
                      <li><NavLink to="/PropertiesForRent">Rent a Property</NavLink></li>
                      <li><NavLink to="/About">About</NavLink></li>
                      <li><NavLink to="/Contact">Contact</NavLink></li>
                  </ul>
                  <button className="btn">
                      <NavLink to="#">Add Property</NavLink>
                  </button>
              </div>
              <i className="fa fa-solid fa-bars" onClick={() => setShowMenu(!showMenu)}></i>

          </nav>
      </Fragment>
    );
}

export default Navbar;

View Image Here

CSS for max-width screen:

.fa-bars{
    display: flex;
    color: gold;
}

Appreciate any help or advice.

  1. Tried installing dependencies again
npm i --save @fortawesome/fontawesome-svg-core
npm install --save @fortawesome/free-solid-svg-icons

Still unable to resolve the issue.

  1. Attempted deleting nodemodules directory.
  2. Restarted the application.

No luck so far.

Answer №1

According to the documentation provided by Font Awesome, the recommended way to use their icons is as follows:

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faCoffee } from '@fortawesome/free-solid-svg-icons'

const MyApp = () => {
   return (<div><FontAwesomeIcon icon={faCoffee} /></div>)
}

export default MyApp

Answer №2

Were all the steps in the guide followed correctly? Step number three involves adding the FontAwesomeIcon component and using it like this:

<FontAwesomeIcon icon={faBars} />

Refer to the documentation for more information on how to work with icons.

PS: Remember to import both the component and the specific icon:

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faBars } from '@fortawesome/free-solid-svg-icons';

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

jQuery AJAX utilizes div elements

I am having trouble using functions in a select element loaded within a div using AJAX in jQuery. Can anyone offer assistance? Here is the snippet of jQuery code: $("#cbo_sede").change(function () { var sede = document.getElementById("cbo_sede").val ...

Creating a unique texture on a spherical object using THREE.js

Can a sphere be textured in sections rather than all at once? Just like we can use 6 textures on 6 sides of a cube, is it possible to apply different textures to different parts of a sphere? For example, dividing the sphere into quarters and texturing each ...

Issue with navigation bar small box alignment on the left side

Hey there! I'm relatively new to bootstrap and html, and I've encountered an issue with my navbar setup. When I create my navbar, a small box appears on the left side of my screen. Here's an example <head> <meta charset="ut ...

I'm experiencing a strange issue where my component's values remain unchanged even after re-rendering the component with new values. I wonder if this could be a result of Next.js caching

Perhaps the title didn't fully capture what I'm trying to explain, so here's a breakdown. I'm in the process of developing a habit tracker. This tracker enables users to create their own habits which are stored in a habits mongodb tabl ...

Troubleshooting Problems with CSS Span Placement

Challenges with Span Positioning in CSS Currently, I am encountering difficulties while working on the index.html.erb file for an example Rails website. Below is a snippet of the HTML code I am struggling with (please note that this is simply a fabricated ...

How can you ensure seamless synchronization while logging in a user with ReactJS and retrieving data from the API?

Is there a way to synchronize and run these two functions in succession before calling console.log(user) and setLogin()? The goal is to ensure that all the information retrieved from the API is available in the user context before activating the setLogin() ...

The web element cannot be located, but it becomes visible when manually inspected

I'm facing an issue with accessing this menu in selenium as the web element doesn't show up in the inspector until I do it manually. <a id="cke_3275" class="cke_menubutton cke_menubutton__table cke_menubutton_off cke_menubutton_ ...

What are the steps to add code into the Monaco Editor using Playwright?

As I explore the world of Playwright, I am faced with a challenge regarding testing a feature that involves a monaco editor. Unfortunately, my search in Playwright documentation and forums did not yield any relevant information. Here is the test scenario ...

Having difficulty populating a selection box through an ajax request in Django

I am facing an issue with creating cascading select boxes in my project (backend Django), although I believe most of the backend work has been completed. The JavaScript code I'm using is adapted from a solution found on a stackoverflow post. $(docume ...

Invoking numerous functions through the (click)= event

When it comes to removing a user from my site, I find myself having to execute multiple database queries to delete the user's ID across approximately 10 different tables. Currently, I am resorting to what I consider a messy workaround where I have mu ...

Adjusting the sound levels of an HTML audio element using JavaScript

I'm looking to adjust the volume of an <audio> element when a user clicks on an image. HTML: <div id="cloud"> <img name="jsVolumeButton" src="images/cloud.png" width = "140px"/> </div> <audio id="player" src="sounds/rain. ...

What is the best way to fit the text into a DIV row as efficiently as possible?

Looking for a solution to prevent a span from dropping down to the next line when text is too long within a fixed width and height row. The row consists of three elements, two with fixed widths and the third containing a span and text. Constraints include ...

Using the value from the Vuex state to set the initial value for a different parameter

I am facing an issue with utilizing an array of objects in my Vuex state to set a default value for another parameter, specifically for mainAccount: For instance: const store = new Vuex.Store({ state: { AccountNums: [ { label: 'M ...

How can I properly implement a Closure or IIFE to manage an onclick event in ReactJS?

I'm encountering an issue while attempting to utilize the this object in an event handler. An undefined error related to the this object keeps popping up. My development stack includes ReactJS and Redux as well. class Chat extends Component { c ...

What could be causing the overlap between the button and the div element?

My main wrapper div contains a content div and a button. However, I'm facing an issue where the button is overlapping with the content div instead of appearing below it. The content div is styled with the following CSS: #groupMembers { position: ...

Zeroclipboard will fail to copy the text

I seem to be encountering an issue with the Zeroclipboard system. I suspect there might be an error in my code. Even though it indicates that the content has been copied, it actually hasn't been. The code I am currently using is as follows: <scri ...

Getting a file object with v-file-input in Nuxt.js

For my Nuxt.Js apps, I utilized Vuetify.js as the UI framework. In order to obtain the file object when uploading files, I incorporated the v-file-input component from Vuetify.js and wrote the following code snippet: <template> <div> ...

How can I display the post title in the URL instead of the ID using Next.js and ensure it stands out?

I've been trying to figure this out, but all the examples I found were in Laravel and PHP. I need to know how to do this in Next.js. So far, I understand how to create dynamic routes in Next.js using the typical format like this ... /pages/post/[pos ...

Removing an item from an array containing several objects

I have an array that looks like this: var participants = [ {username: "john", time: null}, {username: "samira", time: null}, {username: "mike", time: null}, {username: "son", time:null} ] To remove an item based on the username, I can do the f ...

Having trouble displaying json data in an HTML file with d3.js

I am having trouble loading data from a json file into an HTML file and using D3 to visualize it. Even though the file loads correctly and is verified with a 200 status, the contents are interpreted as null. Below are the contents of the json file: [{"to ...