以下の内容はhttps://tech.motoki-watanabe.net/entry/2020/09/20/170212より取得しました。


Reactでstyled-componentなプロジェクトに、reset.cssを導入する

最近はじめてstyled componentでCSSを書いています。

で、reset.cssを入れようと思ったのですが、もうそもそもどう入れるのかわからず。

qiita.com

を参考にやりました。


入れたresetは

github.com

こちら。このパッケージをnpmやyarnでインストールして、

_app.tsx

import { createGlobalStyle } from 'styled-components'
import reset from 'styled-reset'

const GlobalStyle = createGlobalStyle`
  ${reset}
`

export default function App({ Component, pageProps }: AppProps) {
  return (
    <>
      <GlobalStyle />
    </>
  )
}

でいけます。参考にしたQiitaではinjectGlobalで入れてますが、

qiita.com

styled-component v4 からcreateGlobalStyleが出来たので、こちらのほうが良さそうなのでこれで入れました。




以上の内容はhttps://tech.motoki-watanabe.net/entry/2020/09/20/170212より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14