@emotion/provider

0.11.2 • Public • Published

@emotion/provider

A React component to provide a theme to child components

Install

yarn add @emotion/provider

Usage

/** @jsx jsx */
import { jsx } from '@emotion/jsx'
import styled from '@emotion/styled'
import * as React from 'react'
import ThemeProvider from '@emotion/provider'

let SomeParagraph = styled.p`
  color: ${props => props.theme.primaryColor};
`

class SomeComponent extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      theme: {
        primaryColor: 'hotpink'
      }
    }
  }
  render() {
    return (
      <ThemeProvider theme={this.state.theme}>
        <h1 css={theme => ({ color: theme.primaryColor })}>some heading</h1>
        <SomeParagraph>some text</SomeParagraph>
      </ThemeProvider>
    )
  }
}

Dependencies (2)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @emotion/provider

    Weekly Downloads

    12,121

    Version

    0.11.2

    License

    MIT

    Unpacked Size

    11.1 kB

    Total Files

    10

    Last publish

    Collaborators

    • emmatown
    • tkh44
    • emotion-release-bot
    • andarist