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

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

CSS

              
                * {
  box-sizing: border-box;
}

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

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

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

.tab-list-item {
  flex: 1;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 180ms ease-out;
  height: 100%;
  outline: 0; // add focus state for better accessibility
  border: 1px solid #a5acb1;
  
  &:hover,
  &.is-active {
    opacity: 1;
    background: #999;
    
  }
}
              
            
!

JS

              
                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>What is a 529?</strong>,
        panel: <div><p>A 529 is a tax-advantaged investment 
            vehicle in the US designed for encouraging saving for 
            the future higher education expenses of a designated 
            beneficiary. You can use a 529 to pay for K-12 public, private and religios school tuition, post-secondary education costs, such as tuition, fees, books, supplies & equipment, room and board.</p></div>
      }, {
        id: 't2',
        title: <strong>Why use a 529?</strong>,
        panel: <div><p>>With the Economic Growth & Tax Relief Reconciliation Act of 2001, qualified distributions from 529 plans are exempt from federal income tax. </p></div>
      }, {
        id: 't3',
        title: <strong>Concerns about a 529?</strong>,
        panel: <div><ul>
              <li>If the money is not spent on education, expenses are subject to income tax, 
              plus a 10% penalty.</li>
              <li>Paying qualified expenses directly from a 529 may reduce a student's 
              eligibility for need based financial aid.</li>
              <li>Paying qualified expenses from a 529 may reduce eligibility for the 
              American Opportunities Tax Credit, due to IRS coordination restrictions.</li>
            </ul></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

Console