8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

gatsby(react)にNoto Sans JPを入れてMaterial-UIのthemeでfont-familyを上書き指定する

Posted at

メモです。

参考:
https://www.npmjs.com/package/fontsource-noto-sans-jp
https://mrtry.hatenablog.jp/entry/2018/05/07/193920

#インストール
npm install fontsource-noto-sans-jp
もしくは
yarn add fontsource-noto-sans-jp

でNoto Sans JPをインストールする。

#インポート

gatsby-browser.js

import { ThemeProvider } from 'styled-components'
import { MuiThemeProvider } from '@material-ui/core/styles'
import { theme } from './src/utility/theme'
import "fontsource-noto-sans-jp"
import "fontsource-noto-sans-jp/500.css"
import "fontsource-noto-sans-jp/900-normal.css"

などする。

#Material-UIのthemeのfont-familyを上書き指定

import { createMuiTheme } from '@material-ui/core/styles'

// fontFamilyを上書き
export const theme = createMuiTheme({
  typography: {
    fontFamily: ['Noto Sans JP', 'sans-serif'].join(','),
  },
})

8
5
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
8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?