Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
EmotionでReactをstylingすればモテるかもしれない
Search
Matsuo Obu
May 29, 2019
Technology
0
620
EmotionでReactをstylingすればモテるかもしれない
Emotion使うとモテるかもしれないという話。React LT会 @Informetis (2019-05-29) で発表。
Matsuo Obu
May 29, 2019
Tweet
Share
More Decks by Matsuo Obu
See All by Matsuo Obu
Reactの歴史
mqtsuo02
0
1k
文学作品「檸檬」をReactで読む
mqtsuo02
1
500
僕が求めていたのはNext.jsだったんだ
mqtsuo02
0
680
Repro Tech Hands-on : Nuxt.js
mqtsuo02
1
900
ピピピのPWA
mqtsuo02
0
720
GraphQLについての5分間
mqtsuo02
0
810
Create React App 読解特急
mqtsuo02
0
100
JekyllとBootstrapを使って静的なブログを作ってみたよ
mqtsuo02
0
85
Other Decks in Technology
See All in Technology
ハッカソンから社内プロダクトへ AIエージェント ko☆shi 開発で学んだ4つの重要要素
leveragestech
0
610
2025年の医用画像AI/AI×medical_imaging_in_2025_generated_by_AI
tdys13
0
320
re:Invent2025 セッションレポ ~Spec-driven development with Kiro~
nrinetcom
PRO
2
170
AWSと生成AIで学ぶ!実行計画の読み解き方とSQLチューニングの実践
yakumo
2
320
AIと融ける人間の冒険
pujisi
0
110
ECS_EKS以外の選択肢_ROSA入門_.pdf
masakiokuda
1
120
わが10年の叡智をぶつけたカオスなクラウドインフラが、なくなるということ。
sogaoh
PRO
1
380
AWS re:Invent2025最新動向まとめ(NRIグループre:Cap 2025)
gamogamo
0
160
チームで安全にClaude Codeを利用するためのプラクティス / team-claude-code-practices
tomoki10
6
3.1k
会社紹介資料 / Sansan Company Profile
sansan33
PRO
11
390k
2025-12-27 Claude CodeでPRレビュー対応を効率化する@機械学習社会実装勉強会第54回
nakamasato
4
1.4k
Models vs Bounded Contexts for Domain Modularizati...
ewolff
0
110
Featured
See All Featured
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
97
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
79
WCS-LA-2024
lcolladotor
0
410
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
200
GraphQLとの向き合い方2022年版
quramy
50
14k
First, design no harm
axbom
PRO
1
1.1k
Designing for Timeless Needs
cassininazir
0
110
The agentic SEO stack - context over prompts
schlessera
0
580
jQuery: Nuts, Bolts and Bling
dougneiner
65
8.3k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
2
78
Automating Front-end Workflow
addyosmani
1371
200k
Transcript
@mqtsuo02 2019-05-29 React LT会 EmotionでReactをstylingすれば モテるかもしれない
自己紹介 - フリーランスのWebエンジニア - 直近2年間はずっとReactメイン - ReactのSPA3本、ReactNative1本やった - 最近はNext.jsとGAEが好き
Reactでstylingといえば....
いろいろあるけど...
None
ですが...
こんなやつもいます...
自己紹介 - CSS in JS のライブラリ - 高性能:パフォーマンスがいい - 多機能:色々な方法でstylingできる
- 大人気:★ 8,000 over - とてもエモーショナルなロゴですね emotion-js / emotion
多機能な点において styled-componentsに完全勝利
Emotionのstyling いろいろ - css prop (Object styles) - css prop
(String styles) - Styled Components (String styles) - Styled Components (Object styles)
css prop (Object styles) const textStyle = { color: "red"
}; const Page = () => ( <div css={textStyle}>Emotion でモテモテ</div> ); Inline stylesと同じ要領のstyling cssプロパティに指定する
@emotion/coreのcss関数を使うと CSSと同じように書ける css prop (String styles) import { css }
from "@emotion/core" ; const textStyle = css` color: blue; `; const Page = () => ( <div css={textStyle}>Emotion でモテモテ</div> );
styleの共通化はこんな感じに書ける const baseStyleSt = css` color: black; `; const textStyleSt
= css` ${baseStyleSt}; font-size: .8rem; color: blue; `; const baseStyleOb = { color: "black", }; const textStyleOb = { ...baseStyleOb, fontSize: ".8rem", color: "blue", }; String Styles Object Styles
Styled Components (String styles) styled-componentsと同じ要領で書ける import styled from "@emotion/styled" ;
const MoteText = styled.div` color: yellow; `; const Page = () => ( <MoteText>Emotionでモテモテ</MoteText> );
Styled Components (Object styles) import styled from "@emotion/styled" ; const
MoteText = styled.div({ color: "green", }); const Page = () => ( <MoteText>Emotionでモテモテ</MoteText> ); styled-componentsと同じ要領で書ける
$ npm install --save @emotion/core 導入方法 (css props) /** @jsx
jsx */ import { jsx, css } from "@emotion/core" ; @emotion/core パッケージをインストール 各ページファイルでプラグマを書いて Reactの代わりに jsx モジュールをimportする
$ npm install --save @emotion/styled 導入方法 (Styled Components) import React
from "react"; import styled from "@emotion/styled" ; @emotion/styled パッケージをインストール styledだけを使う場合は、プラグマは必要なし styled-components と同じ使用感
Emotionは他にもいろいろな機能がある - Globalコンポーネントでglobalのstylingができる - ネストされてるelementに対してもstylingできる - propsの値から動的なstylingもできる - 姉妹パッケージのfacepaintでメディアクエリをいい感じに書ける -
TypeScriptの型定義がパッケージに入っているのでtsxへの導入も楽
Emotionはこんな人にオススメかもしれない - stylingをとことんカスタムしたい人 - Inline Stylesっぽい感じでclassによるstylingがしたい人 - 環境整備だけして、styling方法は後で考えたい人 - とりあえずナウいパッケージ使いたい人
そうゆうことだ
ReactやってるならEmotionもさわった方がいい プラグマはうざいけど、多機能なのはいい 個人的にはこのロゴ(絵文字)好き Reactのお仕事おまちしてます! このLTで伝えたかったこと
E N D