5
2

More than 1 year has passed since last update.

Next.js+tailwindcssにgoogleFont読み込ませる!

Last updated at Posted at 2021-09-17

googleFontをtailwindで使用する為の設定の仕方を紹介します。
こちら課題の一環でLGMTを一定数取らないといけない試験でぜひLGMTを押していただけるとありがたいです。

googlefontでフォントを選択して@importの方でコピーする!

googlefont.png

styles/globals.scssに読み込む

@tailwind base;
@tailwind components;
@tailwind utilities;
//読み込む
@import url('https://fonts.googleapis.com/css2?family=Lato:wght@700&family=Noto+Sans+JP:wght@500&display=swap');

tailwind.config.jsに読み込む

module.exports = {
    theme: {
        extend: {
            fontFamily: {
                roboto: ["Roboto"],
            },
        },
    },
}

スクリーンショット 2021-09-17 21.02.29.png

使用する。

font-roboto
font-(設定したやつ)で使える


<div className="font-roboto">
テキスト
</div>
5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2