css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              * {
  box-sizing: border-box;
}

body {
  padding: 30px;
  font-family: 'Helvetica';
  background: #cad1d6;
}

// Tabs
.tab-set {
  padding: 20px;
  border: 1px solid #a5acb1;
  border-radius: 5px;
  background: #fff;
}

.tab-list {
  display: flex;
  position: relative;
}

.tab-list-item {
  flex: 1;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 180ms ease-out;
  outline: 0; // add focus state for better accessibility
  
  &:hover,
  &.is-active {
    opacity: 1;
  }
}
            
          
!
            
              const { Component, Children, PropTypes } = React
const { Motion, spring } = ReactMotion
const { AriaManager, AriaToggle, AriaPopover, AriaTabList, AriaTab, AriaPanel, AriaItem } = ReactARIA

const fastSpring = { stiffness: 400, damping: 40 }

class Tabs extends Component {
  constructor(props) {
    super(props)
    this.state = {
      tabs: [{
        id: 't1',
        title: <strong>πŸ— Bacon Ipsum</strong>,
        panel: <div><p>Bacon ipsum dolor amet pork prosciutto tail ground round cow pancetta ham beef.  Brisket cupim shoulder drumstick turkey sausage cow pork beef pig venison boudin.  Ham hock bacon hamburger alcatra boudin shank shankle porchetta short ribs.  Jowl shank shoulder, pork belly tail ham hock ribeye fatback sirloin doner beef swine ground round meatball hamburger.</p><p>Venison pork turkey jerky pig.  Kevin andouille pastrami, ham hock sausage landjaeger sirloin tri-tip spare ribs boudin kielbasa tenderloin bresaola.  Short loin ribeye biltong capicola salami tenderloin, fatback ground round rump sirloin meatloaf porchetta.  Pork loin alcatra short loin ham hock kevin salami beef ribs filet mignon leberkas.  Bresaola pork landjaeger, tail jowl t-bone corned beef.  Cupim ground round tail brisket, pork belly short loin t-bone.  Beef ribs pork chop kevin short ribs frankfurter alcatra ball tip ground round jerky.</p></div>
      }, {
        id: 't2',
        title: <strong>πŸ‘¨πŸΏ Samuel Ipsum</strong>,
        panel: <div><p>Now that we know who you are, I know who I am. I'm not a mistake! It all makes sense! In a comic, you know how you can tell who the arch-villain's going to be? He's the exact opposite of the hero. And most times they're friends, like you and me! I should've known way back when... You know why, David? Because of the kids. They called me Mr Glass.</p><p>Your bones don't break, mine do. That's clear. Your cells react to bacteria and viruses differently than mine. You don't get sick, I do. That's also clear. But for some reason, you and I react the exact same way to water. We swallow it too fast, we choke. We get some in our lungs, we drown. However unreal it may seem, we are connected, you and I. We're on the same curve, just on opposite ends.</p></div>
      }, {
        id: 't3',
        title: <strong>πŸ’€ Zombie Ipsum</strong>,
        panel: <div><p>Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro. De carne lumbering animata corpora quaeritis. Summus brains sit​​, morbo vel maleficia? De apocalypsi gorger omero undead survivor dictum mauris. Hi mindless mortuis soulless creaturas, imo evil stalking monstra adventus resi dentevil vultus comedat cerebella viventium. Qui animated corpse, cricket bat max brucks terribilem incessu zomby. The voodoo sacerdos flesh eater, suscitat mortuos comedere carnem virus. Zonbi tattered for solum oculi eorum defunctis go lum cerebro.</p></div>
      }],
      activeId: 't1',
      height: 'auto'
    }
    this._handleChange = this._handleChange.bind(this)
  }

  _handleChange(activeId) {
    this.setState({ activeId })
  }

  render() {
    const { tabs, activeId, height } = this.state
    const activeIndex = tabs.indexOf(tabs.filter(tab => tab.id === activeId)[0])
    
    return (
      <AriaManager
        type="tabs"
        activeTabId={activeId}
        onChange={this._handleChange}
      >
        <div className="tab-set">
          <Measure>
            { dimensions =>
              <Motion
                style={{ x: spring(dimensions.width/3 * activeIndex, fastSpring) }}
              >
              { value =>
                <AriaTabList className="tab-list">
                  { tabs.map(({ id, title }) =>
                    <AriaTab
                      key={id}
                      id={id}
                      isActive={id === activeId}
                    >
                      {(props, isActive) => (
                        <div {...props} className={`tab-list-item ${isActive ? 'is-active' : ''}`}>
                          {title}
                        </div>
                      )}
                    </AriaTab>
                  )}
                  <div
                    style={{
                      width: dimensions.width/3,
                      height: 2,
                      background: '#a5acb1',
                      position: 'absolute',
                      bottom: 0,
                      left: 0,
                      transform: `translate3d(${value.x}px, 0, 0)`
                    }}
                  />
                </AriaTabList>
              }
              </Motion>
            }
          </Measure>
          <div className="tab-panels">
            <ReactFluidContainer
              height="auto"
              style={{ overflow: 'hidden' }}
            >
              <div>
                { tabs.map(({ id, panel }) =>
                  <AriaPanel
                    key={id}
                    isActive={id === activeId}
                    controlledBy={id}
                    className="tab-panel"
                  >
                    {panel}
                  </AriaPanel>
                )}
              </div>
            </ReactFluidContainer>
          </div>
        </div>
      </AriaManager>
    )
  }
}

ReactDOM.render(<Tabs/>, document.getElementById('app'))
            
          
!
999px
πŸ•‘ One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console