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

              
                <!-- the component is loaded via JavaScript -->
              
            
!

CSS

              
                $yellow: #F9E4AD;
$peach: #E6B098;
$red: #CC4452;
$maroon: #723147;
$purple: #31152B;

*{
  box-sizing: border-box;
}

body{
  background: $peach;
  font-family: 'Open Sans', sans-serif;
}

.tabs{
  background: lighten($yellow, 13%);
  max-width: 400px;
  margin: 2em auto;
  width: 100%;
  position: relative;
  border: 1px solid $maroon;
  box-shadow: 0 10px 40px
    darken(transparentize($maroon, .5), 10%);
  overflow: hidden;
  
  &__tracker{
    position: absolute;
    top: 0;
    left: 0;
    width: 100px;
    height: 5px;
    background: $purple;
  }
  
  &__titles{
    
      &__title{
        color: $red;
        display: inline-block;
        cursor: pointer;
        padding: 1em 20px;
        margin: 0;
        transition: all 300ms ease-in-out;
        
        &:hover{
          transform: scale(1.1);
          color: darken($red, 5%);
        }
      }
  }

  
  &__contents{
    
    position: relative;
    height: 260px;
    
    &__content{
      padding: 20px;
      width: 100%;
      position: absolute;
      top: 0;
      left: 0;
    }
  }
  

}



.scale-enter {
  transform: translateX(-100%);
  opacity: .01;
}

.scale-enter.scale-enter-active {
  transform: translateX(0);
  opacity: 1;
    transition: all 500ms ease-in-out;

}

.scale-leave {
  transform: translateX(0);
  opacity: 1;

}

.scale-leave.scale-leave-active {
  transform: translateX(100%);
  opacity: .01;
  transition: all 500ms ease-in-out;
}

.tag{
  display: inline-block;
  background: $maroon;
  border-radius: 12px;
  color: white; 
  padding: 4px 8px;
  text-transform: uppercase;
  font-weight: 700;
  
  & + &{
    margin-left: 10px;
  }
  
  &--not{
    @extend .tag;
    background: darken($red, 10%);
  }
}
              
            
!

JS

              
                var ReactCSSTransitionGroup = React.addons.CSSTransitionGroup;
var demoMode = true;

var tabs = [
  {
    title: 'Alligator',
    text: <div><p>A large semiaquatic reptile similar to a crocodile but with a broader and shorter head, native to the Americas and China.</p><span className="tag">Real</span><span className="tag">Scaly</span></div>
  },
    {
    title: 'Cat',
    text: <div><p>A small domesticated carnivorous mammal with soft fur, a short snout, and retractile claws. It is widely kept as a pet or for catching mice, and many breeds have been developed.</p><span className="tag">Real</span><span className="tag">Fuzzy</span></div>
  },
    {
    title: 'Manticore',
    text: <div><p>A mythical beast typically depicted as having the body of a lion, the face of a man, and the sting of a scorpion.</p><span className="tag--not">Not Real</span><span className="tag--not">Kinda Mean</span></div>
  }
];


class Tabs extends React.Component{

  constructor(props){
    super(props);
    this.state = {
      current: 0
    }
    this.changeTab = this.changeTab.bind(this);
    this.moveTracker = this.moveTracker.bind(this);
  }
  
  componentDidMount(){
    this.moveTracker();
  }
  
  moveTracker(){
    var title = ReactDOM.findDOMNode(this).querySelector('.tabs__titles__title[data-active="true"]');
    var tracker = ReactDOM.findDOMNode(this).querySelector('.tabs__tracker');
    Velocity(tracker, {width: title.clientWidth, left: title.offsetLeft}, {duration: 1000, easing:  [ 250, 15 ]})
  }
  
  changeTab(e){
    e.stopPropagation();
    this.setState({
      current: e.target.getAttribute('data-index')
    }, function(){
      this.moveTracker();
    })
  }
  
  render(){
    let tabs = this.props.tabs;
    return(
      <div className="tabs">
      <div className="tabs__tracker" />
      <div className="tabs__titles">
        {tabs.map((tab, index, array) =><h2 className="tabs__titles__title" data-active={this.state.current == index} data-index={index} key={'tab-title-' + index} onClick={this.changeTab}>{tab.title}</h2>)}      
      </div>
        <div className="tabs__contents">
         <ReactCSSTransitionGroup transitionName='scale' transitionEnterTimeout={500} transitionLeaveTimeout={500}><div className="tabs__contents__content" key={'tab-text-' + this.state.current}>{tabs[this.state.current].text}</div></ReactCSSTransitionGroup>
      </div>
    </div>
    )
  }
}

ReactDOM.render(<Tabs tabs={tabs}/>, document.getElementsByTagName('body')[0]);
                
if(demoMode){
  var titles = document.querySelectorAll('.tabs__titles__title');
  setTimeout(function(){titles[1].click()}, 1500);
  setTimeout(function(){titles[2].click()}, 3000);
  setTimeout(function(){titles[0].click()}, 4500);
}
              
            
!
999px

Console