JSFiddle - React, Tailwind, and code Playground
HTML
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.1/angular.min.js"></script>
<tab-control tabs="tasks, parts">
<!-- somehow add sections here that will show/hide when their tab is clicked -->
</tab-control>
CSS
.tab-container {
width: 100%;
display: block;
position: relative;
}
.tab-container p {
width: auto;
border: 1px solid #ccc;
border-top: 1px solid #ccc;
border-right: 1px solid #ccc;
border-bottom: none;
border-left: 1px solid #ccc;
background-color: #d5d5d5;
display: inline-block;
margin-right: -5px;
margin-bottom: -1px;
}
.tab-container p a {
padding: 0.9375em;
display: inline-block;
color: #333;
font-size: 0.875em;
white-space: nowrap;
}
.tab-container section {
z-index: 999;
border: 1px solid #ccc;
padding: 0.9375em;
}
.tab-container .active-tab {
background-color: #fff;
margin-bottom: -1px !important;
z-index: 1000;
}
JavaScript
var app = angular.module('app', []);
app.directive('tabControl', function ($rootScope) {
'use strict';
return {
restrict: 'E',
link: function (scope, element, attrs) {
console.log(attrs.tabs);
var tabs = attrs.tabs.split(',');
var tabContainer = angular.element('<div class="tab-container"></div>'),
tab = angular.element('<p><a href=""></a></p>'),
content = angular.element('<section></section>');
for (var i = 0; i < tabs.length; i++) {
tabContainer.append(tab);
var title = tab.find('a');
title.html(tabs[i]);
tabContainer.append(content);
}
}
}
});