Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div id="app"></div>


  height: 900px;
  width: 100%;



padding: 20px;
font-family: "lato";
color: white;
font-size: 20px;
 cursor: pointer;
margin-left: 20px;
border: none; 


  font-family: "lato";
  color: white;
  font-weight: 800px;
  text-align: center;
  text-transform: uppercase;


  width: 300px;
  height: 300px;
  display: block;
  margin: auto;
  padding-top: 40px;



var blue = '#70CFE1';
var green = '#85C85D';
var red = '#F4614C';
var yellow = "#E5CF41";
var orange = "#F79D2A";
var random ="#81479b";

//creatures sources
var blueSrc = '';
var greenSrc = '';
var redSrc = '';
var yellowSrc = "";
var orangeSrc = "";

var Color = React.createClass({
  //set initial background to red and creature to red
  getInitialState: function () {
  return { color: red, creature: redSrc};
  //random color and creature color
  changeColorRandom: function () {
    var values = [blue,green,red,yellow, orange],

valueToUse = values[Math.floor(Math.random() * values.length)];   
 var creatures = [blueSrc,greenSrc,redSrc,yellowSrc, orangeSrc],
creatureToUse = creatures[Math.floor(Math.random() * creatures.length)];   
  var color = valueToUse;
  var creature = creatureToUse;

  this.setState({ color: color, creature: creature });
//color and creature blue
   changeColorBlue: function () {
   var color = blue;
    var creature = blueSrc;
  this.setState({ color: color, creature: creature });
  //color and creature green
    changeColorGreen: function () {
   var color = green;
 var creature = greenSrc;
  this.setState({ color: color, creature: creature });
  //color and creature red
    changeColorRed: function () {
   var color = red;
  var creature = redSrc;
  this.setState({ color: color, creature: creature });
  //color and creature yellow
   changeColorYellow: function () {
   var color = yellow;
  var creature = yellowSrc;
  this.setState({ color: color, creature: creature });
  //color and creature orange
   changeColorOrange: function () {
   var color = orange;
  var creature = orangeSrc;
  this.setState({ color: color, creature: creature });
   render: function () {
  return (
  <div  style={{background: this.state.color}}>
  Color Changer
  <br />

  <button style={{background: blue}} onClick={this.changeColorBlue}>

  <button style={{background: green}} onClick={this.changeColorGreen}>

  <button style={{background: red}} onClick={this.changeColorRed}>

  <button style={{background: yellow}} onClick={this.changeColorYellow}>
  <button style={{background: orange}} onClick={this.changeColorOrange}>
  <button style={{background: random}} onClick={this.changeColorRandom}>
  <img src={this.state.creature} />


React.render(<Color />, document.getElementById('app'));