deg84's blog
  • Home
  • サバゲー
  • 個人開発
Sign in Subscribe

Material-UI

A collection of 1 post
GatsbyJS + Material-UIのブログにCSS in JSのEmotionを導入する
Gatsby

GatsbyJS + Material-UIのブログにCSS in JSのEmotionを導入する

このブログの見た目はMaterial UIをベースにstyle属性を使って調整していましたが、RichLinkコンポーネントを作った際にどうしても画面の小さいスマホ用のスタイルと画面の大きいPC用のスタイルを分ける必要が出てきました。 style属性のままだとMediaQueryが使えないので今回はEmotionを導入することにしました。 手順 ①必要なNPMパッケージをインストールする yarn add @emotion/core emotion-theming gatsby-plugin-emotion # or npm install @emotion/core emotion-theming gatsby-plugin-emotion ②gatsby-plugin-emotionを読み込む module.exports = { <!-- 中略 --> plugins: [ 'gatsby-plugin-emotion', ], } ③emotion-themingを使えるようにする // 中略 import { MuiT
30 7月 2020 1 min read
Page 1 of 1
deg84's blog © 2025
  • Sign up
Powered by Ghost