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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                
              
            
!

CSS

              
                body {
    background: #eaeaea;
}

.Tabs {
    background: #fff;
    width: 60%;
    margin: 200px auto;
    padding: 1em;
}

.TabsNav {
    border-bottom: 1px solid lightgray;
}

.TabsNav-btn {
    display: inline-block;
    background: none;
    border: 1px solid lightgray;
    border-bottom: 0;
    padding: 1em 2em;
    
    & + & {
        margin-left: -1px;
    }
}

.TabsContent {
    
}

.TabsContent-tabPane {
    padding: 1em;
    border: 1px solid lightgray;
    border-top: 0;
}
              
            
!

JS

              
                const _tabs = [
    {
        name: 'Overview',
        content: "<p>ugue inceptos eu in scelerisque condimentum id pharetra ligula consectetur vestibulum condimentum varius sit parturient facilisi adipiscing lobortis inceptos nec ultricies a scelerisque posuere adipiscing porttitor cum ullamcorper scelerisque. Aenean consectetur etiam lacus nec adipiscing curabitur sed lacus etiam sociis sem in adipiscing scelerisque egestas eleifend suspendisse mi tristique condimentum. Varius laoreet malesuada aliquam malesuada fusce parturient adipiscing etiam a diam magnis gravida condimentum neque ligula ac tempor ullamcorper scelerisque luctus augue interdum parturient non arcu consequat. Faucibus a parturient dictum sit sociosqu a dis sem ad eros vel suspendisse cum quisque laoreet lacinia commodo.</p><p>Orci sit nulla orci justo sapien ultricies parturient condimentum fusce scelerisque adipiscing morbi mi a a scelerisque justo tortor suspendisse fames a semper mi convallis venenatis porta tellus adipiscing. Ac ullamcorper commodo aenean sem a id praesent platea praesent a commodo sociosqu diam nam habitasse mus hac a dui velit ut parturient nisi adipiscing senectus ornare lobortis. Mauris ullamcorper parturient tincidunt phasellus sem suspendisse ad a lacus tortor facilisi duis vitae a parturient porta adipiscing adipiscing mi parturient rhoncus urna aptent ad suspendisse condimentum sit a.</p>"
    },
    {
        name: 'Features',
        content: 'features tab content'
    },
    {
        name: 'Specifications',
        content: 'specs tab content'
    }
];

class TabsNav extends React.Component {
    handleClick(index) {
        this.props.handleClick(index);
    }
    
    render() {
        let activeStyles = {
            backgroundColor: 'deepskyblue',
            borderColor: 'deepskyblue',
            color: '#fff'
        }
        
        let buttons = this.props.links.map((item, i) => {
            return (<button className="TabsNav-btn" onClick={this.handleClick.bind(this, i)} key={i} style={this.props.active === i ? activeStyles : {}}>{item.name}</button>);
        });
        
        return (
            <nav className="TabsNav">
                {buttons}
            </nav>
        );       
    }
}
            
class TabsContent extends React.Component {
    render() {            
        let tabs = this.props.content.map((item, i) => {
            return (<div className="TabsContent-tabPane" key={i} style={{display: this.props.active === i ? 'block' : 'none'}} dangerouslySetInnerHTML={{__html: item.content}} />);
        });
            
        return (
            <div className="TabsContent">
                {tabs}
            </div>
        );
    }   
}

class Tabs extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            items: this.props.content,
            activeTab: 0
        }
    }
    
    handleClick(index) {
        this.setState({
            activeTab: index
        });
    }
    
    render() {
        return (
            <div className="Tabs">
                <TabsNav links={this.state.items} handleClick={this.handleClick.bind(this)} active={this.state.activeTab} />
                <TabsContent content={this.state.items} active={this.state.activeTab} />
            </div>
        );
    }
}

React.render(<Tabs content={_tabs} />, document.body);
              
            
!
999px

Console