最近はじめてstyled componentでCSSを書いています。
で、reset.cssを入れようと思ったのですが、もうそもそもどう入れるのかわからず。
を参考にやりました。
入れたresetは
こちら。このパッケージを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
で入れてますが、
styled-component v4 からcreateGlobalStyle
が出来たので、こちらのほうが良さそうなのでこれで入れました。