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.

              <h1>Accessible tab component in React</h1>
<div id="mount"></div>
  font-family Menlo, Monaco, Arial, sans-serif
  font-size 1.5em
  font-size 1.1em
  list-style-type none
  padding 0
  border-bottom 1px solid #ccc
    display inline
  display inline-block
  padding 0.25em 0.75em
  margin 0 0.25em -1px 0.25em
  text-decoration none
  border 1px solid #ccc
  border-radius 3px 3px 0 0
  color #000
    border-bottom-color #fff
  padding 0 0.5em
    display none
              const Tab = ({children, index, isSelected}) => (
  <div id={`tabpanel_${index}`}

class Tabs extends React.Component {
  constructor(props) {
    this.tabs = props.children
    this.state = {selected: this.tabs.find(tab => tab.props.selected) || this.tabs[0]}
    this.selectTab = this.selectTab.bind(this)
    this.previousTab = this.previousTab.bind(this)
    this.nextTab = this.nextTab.bind(this)
    this.handleClick = this.handleClick.bind(this)
    this.handleKeyup = this.handleKeyup.bind(this)
  componentDidUpdate() {
  selectTab (tab) {
    this.setState({selected: tab})
  previousTab (tab) {
    const index = this.tabs.indexOf(tab)
    if (index > 0) this.selectTab(this.tabs[index - 1])
  nextTab (tab) {
    const index = this.tabs.indexOf(tab)
    if (index < this.tabs.length - 1) this.selectTab(this.tabs[index + 1])
  handleClick (e, tab) {
  handleKeyup (e, tab) {
    if (e.which === 13) this.selectTab(tab)
    else if (e.which === 37) this.previousTab(tab)
    else if (e.which === 39) this.nextTab(tab)
  render () {
    return (<div>
      <ul role="tablist">
        {, i) => (
          <li role="presentation">
            <a id={`tab_${i}`}
               aria-selected={tab === this.state.selected}
               tabIndex={tab === this.state.selected ? 0 : -1}
               onClick={e => this.handleClick(e, tab)}
               onKeyUp={e => this.handleKeyup(e, tab)}
               ref={link => { if (tab === this.state.selected) this.activeLink = link}}
        {, i) => (
          React.cloneElement(tab, {
            index: i,
            isSelected: () => tab === this.state.selected

const App = () => (
    <Tab title="React">
      <p>Declarative views make your code more predictable and easier to debug.</p>
      <p>Build encapsulated components that manage their own state, then compose them to make complex UIs.</p>
      <h2>Learn Once, Write Anywhere</h2>
      <p>We don't make assumptions about the rest of your technology stack, so you can develop new features in React without rewriting existing code.</p>
    <Tab title="Vue">
      <p>Already know HTML, CSS and JavaScript? Read the guide and start building things in no time!</p>

      <p>Simple, minimal core with an incrementally adoptable stack that can handle apps of any scale.</p>

      <p>16kb min+gzip Runtime<br/>
         Blazing Fast Virtual DOM<br/>
         Minimal Optimization Efforts</p>
    <Tab title="Mithril">
      <p>Only 7.8 kB gzipped, no dependencies<br/>
        Small API, small learning curve</p>

      <p>Safe-by-default templates<br/>
        Hierarchical MVC via components</p>
      <p>Virtual DOM diffing and compilable templates<br/>
        Intelligent auto-redrawing system</p>

🕑 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.