1.0.1 • Published 7 years ago

react-css-editor v1.0.1

Weekly downloads
6
License
MIT
Repository
-
Last release
7 years ago

React CSS Editor

React textarea component for editing style objects as CSS strings

Demo: http://jxnblk.com/react-css-editor

npm i react-css-editor
import React from 'react'
import CSSEditor from 'react-css-editor'

class App extends React.Component {
  state = {
    style: {
      color: 'tomato'
      padding: 16
    }
  }

  update = fn => {
    this.setState(fn)
  }

  render () {
    const { style } = this.state

    return (
      <div>
        <CSSEditor
          value={style}
          onChange={val => {
            this.update(state => ({ style: val }))
          })
        />
        <button style={style} children='Hello' />
      </div>
    )
  }
}

MIT License