Pen Settings

HTML

CSS

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

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

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.

HTML

              
                #react-root
              
            
!

CSS

              
                body
  background orange
  background radial-gradient(ellipse at center, orange 0%, darken(orange, 20%) 100%)
  width 100%
  height 100vh
  font-family 'San Francisco', 'Helvetica Neue', Roboto, Helvetica, Arial, sans-serif
  font-weight 100
  
button.main
  margin 10%
  outline none
  font-size 40px
  border none
  background none
  color mix(white, orange, 80%)
  transition color .3s ease-in-out
  &:hover
    color mix(white, orange, 90%)

 lightBlue = mix(blue, white, 20%)
 
.Menu
  position fixed
  top 0
  right 0
  width 250px
  height 100vh
  background mix(blue, black, 20%)
  color lightBlue
  border-left 1px solid alpha(lightBlue, 50%)
  box-shadow 0 2px 20px black
  transform translateX(300px)
  opacity 0
  button
    outline none
    font-size 30px
    border none
    background none
    color mix(red, orange, 50%)
    text-align left
    width 100%
    transition color .3s ease-in-out
    transform translateY(-40px)
    opacity 0
    &:hover
      color mix(red, orange, 70%)
  .MenuItem
    border-bottom 1px solid alpha(lightBlue, 50%)
    padding 5px 10px
    font-size 120%
    opacity 0
    i
      color orange
      margin-right 20px
              
            
!

JS

              
                const MenuItem = ({iconName, text}) => (
  <div className='MenuItem'>
    <i className={classNames('fa', 'fa-' + iconName)}/>
    <span>{text}</span>
  </div>
)

const Menu = ({onClick}) => {
 const items = [
   { iconName: 'home', text: 'Welcome' },
   { iconName: 'cog', text: 'Settings' },
   { iconName: 'unlock', text: 'Log out' }
 ];
 return (
  <div className='Menu'>
     <button onClick={onClick}>
       <i className='fa fa-times' />
     </button>
    {
       items.map(i => <MenuItem key={i.iconName} iconName={i.iconName} text={i.text} />)
     }
  </div>
 ) 
};

class MainApp extends React.Component {
  constructor(props) {
    super(props);
    this.state = { open: false };
    this.onClick = this.onClick.bind(this);
  }
  onClick() {
    this.setState({open: !this.state.open});
    const $Menu = $('.Menu');
    const $button = $Menu.find('button');
    const $MenuItems = $Menu.find('.MenuItem');
    const options = {display: false, duration: 150, easing: 'ease-in-out', stagger: 60 };
    const seqIn = [
      {e: $Menu, p: 'transition.slideRightIn', o: options },
      {e: $MenuItems, p: 'transition.slideRightIn', o: options },
      {e: $button, p: 'transition.slideDownIn', o: options}
    ];
    const seqOut = [
      {e: $MenuItems, p: 'transition.slideRightOut', o: options },
      {e: $button, p: 'transition.slideUpOut', o: options},
      {e: $Menu, p: 'transition.slideRightOut', o: options }
    ];
    $.Velocity.RunSequence(this.state.open ? seqOut : seqIn);
  }
  render() {
    return (
      <div>
        <button className='main' onClick={this.onClick} >
          <i className={classNames('fa', {
            'fa-toggle-on': this.state.open,
            'fa-toggle-off': !this.state.open,
          })} />
        </button>
        <Menu onClick={this.onClick} />
      </div>
    );
  }
}

React.render(
  <MainApp />, 
  document.getElementById('react-root'));
              
            
!
999px

Console