Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

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

Packages

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.

Behavior

Save Automatically?

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.

HTML

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

CSS

              
                
              
            
!

JS

              
                class App extends React.Component {
  render() {
    return (
      <div style={this.style()}>
        
        {/* Basic. Just Text. */}
        <PrimaryButton>
          Upload File
        </PrimaryButton>
        
        {/* Throw in an icon! */}
        <PrimaryButton>
          <FileIcon/>
          &nbsp;&nbsp;
          Upload File
        </PrimaryButton>

        {/* Getting creative! */}
        <PrimaryButton>
          Upload File
          &nbsp;&nbsp;
          <FileIcon/>
        </PrimaryButton>
        
        {/* Bold the text */}
        <PrimaryButton>
          <span style={{fontWeight: 'bold'}}>
            Upload File
          </span>&nbsp;&nbsp;
          <FileIcon/>
        </PrimaryButton>
        
        {/* Hover effect #1 */}
        <GreenAura>
          <PrimaryButton>
            <span style={{fontWeight: 'bold'}}>
              Upload File
            </span>&nbsp;&nbsp;
            <FileIcon/>
          </PrimaryButton>
        </GreenAura>
        
        {/* Hover effect #1 and #2 */}
        <Levitate>
          <GreenAura>
            <PrimaryButton>
              <span style={{fontWeight: 'bold'}}>
                Upload File
              </span>&nbsp;&nbsp;
              <FileIcon/>
            </PrimaryButton>
          </GreenAura>
        </Levitate>
        
      </div>
    )
  }
  style() {
    return {
      display: 'flex',
      justifyContent: 'space-around',
      alignItems: 'center',
      flexDirection: 'column',
      flexWrap: 'wrap',
      margin: '0 auto',
      width: '33vw',
      height: '100vh'
    }
  }
}

class PrimaryButton extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      isActive: false
    }
  }
  render() {
    return (
      <button style={this.style()} onMouseDown={() => this.setState({isActive: true})} onMouseUp={() => this.setState({isActive: false})}>
        {this.props.children}
      </button>
    )
  }
  style() {
    return {
      display: 'inline-flex',
      margin: '0 auto',
      padding: '1.5vw 2.5vw',
      border: 'none',
      color: 'white',
      fontSize: '2vw',
      backgroundColor: this.state.isActive ? '#006600' : 'green',
      cursor: 'pointer',
      borderRadius: '0.5vw',
      outline: 0,
    }
  }
}

class GreenAura extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      isHovering: false
    }
  }
  render() {
    return <span style={this.style()} onMouseOver={() => this.setState({isHovering: true})} onMouseOut={() => this.setState({isHovering: false})}>{this.props.children}</span>
  }
  style() {
    return {
      display: 'inline-flex',
      borderRadius: '0.5vw',
      boxShadow: this.state.isHovering ? '0 0.5vw 2vw rgba(0, 128, 0, 0.5)' : 'none',
      transition: 'box-shadow 250ms ease-out'
    }
  }
}

class Levitate extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      isHovering: false
    }
  }
  render() {
    return <span style={this.style()} onMouseOver={() => this.setState({isHovering: true})} onMouseOut={() => this.setState({isHovering: false})}>{this.props.children}</span>
  }
  style() {
    return {
      display: 'inline-flex',
      transform: `translateY(${this.state.isHovering ? '-0.5vw' : '0'})`,
      transition: 'transform 250ms ease-out'
    }
  }
}

class FileIcon extends React.Component {
  render() {
    return (<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="2.25vw" viewBox="0 0 9 9"><title>files-empty</title><path d="M0 0v8h7v-4h-4v-4h-3zm4 0v3h3l-3-3z" id="file" fill="#ffffff"></path></svg>)
  }
}

React.render(<App />, document.getElementById('app'));
              
            
!
999px

Console