How to import a stylesheet from external source in react?

15,881

Solution 1

You can just import it in your style sheet like so

    @import url('https://fonts.googleapis.com/css?family=Roboto');

And your body style will become

body {
  font-family: 'Roboto';
}

Solution 2

inset the link in your index.html

<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
Share:
15,881
Gergő Horváth
Author by

Gergő Horváth

Updated on September 15, 2022

Comments

  • Gergő Horváth
    Gergő Horváth over 1 year

    I mean icons from fontawesome or fonts from google fonts. In HTML i place something like this in the head:

    <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
    

    What about react?

  • NIKHIL CHANDRA ROY
    NIKHIL CHANDRA ROY about 4 years
    Is there any way to import it inside js extension reactjs because I am not using any css file instance use material-ui css
  • Friday Ameh
    Friday Ameh about 4 years
    You can add it as link to your index.html should work correctly