@@ -5,24 +5,27 @@ Using Google Fonts in your Nuxt project
55## Installation
66
771 . Install ` @nuxtjs/google-fonts ` dependency to your project:
8+
89``` bash
910npx nuxi@latest module add google-fonts
1011```
1112
12132 . Add it to your ` modules ` section in your ` nuxt.config ` :
1314
1415:: code-group
16+
1517``` ts [nuxt.config (Nuxt 3)]
1618export default defineNuxtConfig ({
17- modules: [' @nuxtjs/google-fonts' ]
18- })
19+ modules: [" @nuxtjs/google-fonts" ],
20+ });
1921```
2022
2123``` ts [nuxt.config (Nuxt 2)]
2224export default {
23- buildModules: [' @nuxtjs/google-fonts' ]
24- }
25+ buildModules: [" @nuxtjs/google-fonts" ],
26+ };
2527```
28+
2629::
2730
2831## Options
@@ -33,114 +36,102 @@ You can customize the module's behavior by using the `googleFonts` property in `
3336export default defineNuxtConfig ({
3437 googleFonts: {
3538 // Options
36- }
37- })
39+ },
40+ });
3841```
3942
4043It is also possible to add the options directly in the module declaration:
4144
4245``` ts [nuxt.config]
4346export default defineNuxtConfig ({
4447 modules: [
45- [' @nuxtjs/google-fonts' , {
48+ [
49+ " @nuxtjs/google-fonts" ,
50+ {
4651 families: {
4752 Roboto: true ,
4853 Inter: [400 , 700 ],
49- ' Josefin+Sans' : true ,
54+ " Josefin+Sans" : true ,
5055 Lato: [100 , 300 ],
5156 Raleway: {
5257 wght: [100 , 400 ],
53- ital: [100 ]
58+ ital: [100 ],
5459 },
55- Inter: ' 200..700' ,
56- ' Crimson Pro' : {
57- wght: ' 200..900' ,
58- ital: ' 200..700' ,
59- }
60- }
61- }],
60+ Inter: " 200..700" ,
61+ " Crimson Pro" : {
62+ wght: " 200..900" ,
63+ ital: " 200..700" ,
64+ },
65+ },
66+ },
67+ ],
6268 ],
63- })
69+ });
6470```
6571
6672See the [ module options] ( /getting-started/options ) .
6773
68-
6974## TailwindCss
7075
71- Install the ` @nuxtjs/tailwindcss ` module as shown below :
76+ 1 . Install ` @nuxtjs/tailwindcss ` dependency to your project :
7277
73- :: code-group
74-
75- ``` bash [nuxi]
78+ ``` bash
7679npx nuxi@latest module add tailwindcss
7780```
7881
79- ``` bash [yarn]
80- yarn add -D @nuxtjs/tailwindcss
81- ```
82-
83- ``` bash [npm]
84- npm install -D @nuxtjs/tailwindcss
85- ```
86-
87- ``` sh [pnpm]
88- pnpm i -D @nuxtjs/tailwindcss
89- ```
90- ::
91-
92- If not configured automatically, add the ` @nuxtjs/tailwindcss ` module to the modules array as shown below:
82+ 2 . Add it to your ` modules ` section in your ` nuxt.config ` :
9383
9484:: code-group
95- ``` ts [Nuxt 3]
85+
86+ ``` ts [nuxt.config (Nuxt 3)]
9687export default defineNuxtConfig ({
97- modules: [' @nuxtjs/tailwindcss' , ' ... ' ]
98- })
88+ modules: [" @nuxtjs/tailwindcss" ],
89+ });
9990```
10091
101- ``` ts [Nuxt 2]
92+ ``` ts [nuxt.config ( Nuxt 2) ]
10293export default {
103- buildModules: [' @nuxtjs/tailwindcss' , ' ... ' ]
104- }
94+ buildModules: [" @nuxtjs/tailwindcss" ],
95+ };
10596```
97+
10698::
10799
108- Configure your desired google font as shown below :
100+ 3 . Configure your desired google font:
109101
110102``` ts
111103export default defineNuxtConfig ({
112104 googleFonts: {
113105 families: {
114106 Roboto: true ,
115107 // Other fonts
116- }
108+ },
117109 },
118- })
110+ });
119111```
120112
121- Head over to your ` tailwind.config.js ` file and configure your font(s) as shown below :
113+ 4 . Head over to your ` tailwind.config.js ` file and configure your font(s):
122114
123115``` js
124116/** @type {import('tailwindcss').Config} */
125117module .exports = {
126- content: [' ...' ],
127- theme: {
128- extend: {
129- fontFamily: {
130- Roboto: ' Roboto' ,
131- // Other fonts
132- }
133- },
118+ content: [" ..." ],
119+ theme: {
120+ extend: {
121+ fontFamily: {
122+ Roboto: " Roboto" ,
123+ // Other fonts
124+ },
134125 },
135- plugins: [],
136- }
126+ },
127+ plugins: [],
128+ };
137129```
138130
139- Now you can go ahead and use your font as shown below :
131+ 4 . Now you can go ahead and use your font:
140132
141133``` html
142134<div class =" grid place-items-center w-full min-h-screen" >
143135 <p class =" font-Roboto" >Hello @nuxtjs/google-fonts + @nuxtjs/tailwindcss</p >
144136</div >
145137```
146-
0 commit comments