Skip to content

Instantly share code, notes, and snippets.

@ashimon83
Created December 4, 2020 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashimon83/5b3d97046fe525d26a33db63267ddd2f to your computer and use it in GitHub Desktop.
Save ashimon83/5b3d97046fe525d26a33db63267ddd2f to your computer and use it in GitHub Desktop.
blog202012 emotioin
/** @jsx jsx */
import { css, jsx } from '@emotion/react'
const danger = css`
color: red;
`
const base = css`
background-color: darkgreen;
color: turquoise;
`
const extended = css`
${base}; // 直接拡張
text-decoration: underline;
`
render(
<div>
<div css={base}>This will be turquoise</div>
<div css={[danger, base]}> // 配列で組み合わせることもできる
some description
</div>
<span css={danger}>other description</div>
{/* 別の種類のタグで有っても共通のクラスをつけたりすることも可能。 */}
{/* あまりやらないと思いますが、できてしまう。 */}
<div css={extended}>extended</div>
</div>
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment