Edit on
<html>
  <head>
    <script src="//cdnjs.cloudflare.com/ajax/libs/react/0.11.2/JSXTransformer.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/react/0.11.2/react.min.js"></script>
  </head>
  <body>
    <!-- The jsx script type is required for JSX to run, so the javascript must be embedded here to work on codepen. -->
    <script type="text/jsx">
      /** @jsx React.DOM */

      var InputDemo = React.createClass({
        getInitialState: function() {
          return {
            hasContent: false,
            content: ''
          }
        },

        changeHandler: function(e) {
          this.setState({content: e.target.value});
          this.setState({hasContent: this.state.content !== ''});
        },

        render: function() {
          return <div className={this.state.hasContent ? 'active input-wrap' : 'inactive input-wrap'}>
            <input className="input" type="text" onChange={this.changeHandler} />
            <ContentArea content={this.state.content} />
          </div>;
        }
      });

      var ContentArea = React.createClass({
        render: function() {
          return <div className="output">
            <p>{this.props.content}</p>
          </div>;
        }
      });

      React.renderComponent(<InputDemo className="demo" />, document.body);
    </script>
  </body>
</html>
html,
body {
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  background-color: #f7f7f7;
}
.input-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -128px;
  margin-top: -84px;
}
.input {
  color: #555;
  box-sizing: border-box;
  padding: 20px;
  width: 256px;
  font-size: 18px;
  font-family: Consolas, Monaco, 'Andale Mono', monospace;
  border: 1px solid #ebebeb;
  transition: border 400ms ease;
  outline: 0;
}
.input:focus {
  border: 1px solid #666;
}
.output {
  box-sizing: border-box;
  padding: 20px;
  width: 256px;
  font-size: 18px;
  font-family: Consolas, Monaco, 'Andale Mono', monospace;
}
Rerun