Quick How-to: Use the emotion `css` prop with create-react-app

Harry Hedger
Jun 2 · 1 min read
create-react-app example
cd example
yarn add @emotion/core react-app-rewired customize-cra --save
yarn add @emotion/babel-preset-css-prop --dev
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-app-rewired eject"
}
const { override, addBabelPreset } = require('customize-cra')module.exports = override(
addBabelPreset('@emotion/babel-preset-css-prop')
)
import React from 'react'
import { css } from '@emotion/core'
const Example = () => <div css={css`width: 100%`}>Example</div>

Harry Hedger

Written by

I’m a developer by day, and a wild man by night. https://github.com/hedgerh

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade