0

here I have a working codepen using HTML, where the icons (Plus) are shown. In the HTML header there is fontawesome directly imported. https://codepen.io/jartysharky/pen/YzQvzrv

No I want to use these Icons without HMTL. In my App.js I have the following to import my styles and link to the component:

import './assets/scss/style.scss'; const App = () => { return ( <Router> <PageScrollTop> <Switch> <Route path={`${process.env.PUBLIC_URL + "/"}`} exact component={Form}/> 

Then in the Form component I got my main form content that can be seen in the codepen. Because the .scss is imported in the App.js, I also got all my styles in the Form.js. My problem is that the icons are not shown and are only rectangles. Because there is no HTML I can't simply import fontawesome in the head, so I decided to import it directly in my style.sccs.

I have tried using @import "https://use.fontawesome.com/releases/v5.8.2/css/all.css"; in my style.scss but the icons seem not to be found How do I need to import fontawesome in my css files so that they get recognized?

When I import several icons into the component I can use them regularly using their names in React, but I need to be able to use the unicodes of the icons in the css part.

 ul.ks-cboxtags li label::before { display: inline-block; font-style: normal; font-variant: normal; text-rendering: auto; -webkit-font-smoothing: antialiased; font-family: "Font Awesome 5 Free"; font-weight: 900; font-size: 12px; padding: 2px 6px 2px 2px; content: "\f067"; transition: transform .3s ease-in-out; } 
3
  • Does this answer your question? Can't import font-awesome in React JS Commented Sep 21, 2021 at 11:12
  • I know how to use the npm module, but as far as I know I can use these icons only directly in the component. I need to use the unicode icons in my style.scss like they were normally imported for example in the head of a html file. Because there is no html file, I imported the external icon css into my styles.scss, which is then imported to my App.js. Still the icons dont show Commented Sep 21, 2021 at 11:19
  • You can add that link to the HTML in the public folder Commented Sep 21, 2021 at 15:40

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.