google-fonts icon indicating copy to clipboard operation
google-fonts copied to clipboard

How to use it for some pege ?

Open golubvladimir opened this issue 3 years ago • 1 comments

I want to use Open Sans font only on some pages. How to set it in settings ?

golubvladimir avatar May 19 '21 08:05 golubvladimir

'Open Sans' : true

GnApollo avatar Sep 10 '21 22:09 GnApollo

After adding 'Open+Sans': true to your googleFonts options in nuxt.config.ts, you can then add the font as a class in your pages.

.some-class { font-family: 'Open Sans', sans-serif; }

aleavikraman avatar Jan 05 '23 19:01 aleavikraman

After adding 'Open+Sans': true to your googleFonts options in nuxt.config.ts, you can then add the font as a class in your pages.

.some-class { font-family: 'Open Sans', sans-serif; }

confirm, it's working (missed that in the docs, too), this issue should've been closed.

danieldanielecki avatar Jan 29 '23 13:01 danieldanielecki

With nuxt 3 we can request stylesheets in different routes

ricardogobbosouza avatar Mar 03 '23 12:03 ricardogobbosouza

It's still an improvement that needs to be implemented

ricardogobbosouza avatar Mar 03 '23 12:03 ricardogobbosouza

'Open Sans' : true

Sorry, maybe this is not clear.

for future reference on Nuxt 2. Here's how I do it.

nuxt.config.js

buildModules : {
....
  ['@nuxtjs/google-fonts', {
      families: {
        Roboto: true,
        'Open Sans' : true
      }
    }],
...
}

if you're using tailwindcss

tailwind.config.js

module.exports = {
  important: true,
  content: [
    './components/**/*.{vue,js}',
    './layouts/**/*.vue',
    './pages/**/*.vue',
    './plugins/**/*.{js,ts}',
    './nuxt.config.{js,ts}',
  ],
  theme: {
    extend: {
      fontFamily: {
        'rob': ['Roboto'],
        'sans': ['Open Sans']
      },

    },
  }
}

then you can use it on your HTML as CSS.

<template>
    <p class="font-rob">Roboto Font</p>
    <p class="font-sans">Open Sans Font</p>
</template>

<script>
export default {}
</script>

GnApollo avatar Mar 03 '23 12:03 GnApollo