14

I'm trying to import a Google Font inside the main.scss file, but following code didn't work:

@import url("//fonts.googleapis.com/css?family=Open+Sans:300,400,600,700");

Is there a way to do that? I looking for this question in stackoverflow, but I don't find a concrete answer...

Can somebody help me?

Albert Font
  • 546
  • 1
  • 3
  • 11

4 Answers4

24

Instead of using url(), try the below:

@import 'https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700';

heyitsjhu
  • 951
  • 7
  • 9
3

The correct syntax for importing Google Fonts into Sass:

@import url('https://fonts.googleapis.com/css2?family=Alegreya + Sans + SC:wght@400;500;800');
Hany Afifi
  • 67
  • 5
0

Right know, using Gulp and Dart Sass, both work. I prefer the Sass-way, just saying. So, with the new Google Fonts’ syntax:

@import url("https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600;700&display=swap");

or

@import "https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600;700&display=swap";

give the same, exact result compiled from Sass to CSS. Then, if you add one of these in a .scss file, you don’t have to worry at all.

Federico Moretti
  • 527
  • 1
  • 11
  • 22