Tabs Component

A CSS implementation of the Sprout tabs component.

Related

Example

html
<div style="width: 400px;">
  <div class="spr-tabs spr-divider spr-stack-lg">
    <div class="spr-tab">
      <span class="active">Tab Label</span>
    </div>
    <div class="spr-tab">
      <span>Tab Label</span>
    </div>
    <div class="spr-tab disabled">
      <span class="active">Tab Label</span>
    </div>
  </div>
  <div class="spr-tabs spr-tabs-lg spr-divider">
    <div class="spr-tab">
      <span class="active">Tab Label</span>
    </div>
    <div class="spr-tab">
      <span>Tab Label</span>
    </div>
    <div class="spr-tab disabled">
      <span class="active">Tab Label</span>
    </div>
  </div>
</div>

Compiled CSS

Example

scss
@import 'components/tabs';
css compiled
@keyframes openPopover {
  from {
    transform: scale(0.9);
  }
  to {
    transform: scale(1);
  }
}

@keyframes activeIndicator {
  from {
    height: 0;
  }
  to {
    height: 0.25rem;
  }
}

.spr-tabs {
  display: flex;
  align-items: center;
}

.spr-tabs-lg .spr-tab {
  padding: 1.5rem 1rem;
}

.spr-tabs-lg .spr-tab .active {
  padding-bottom: 1.625rem;
}

.spr-tabs-sm .spr-tab {
  font-family: "AvenirNext", "Helvetica Neue", Arial, sans-serif;
  font-size: 0.875rem;
  line-height: 1.5rem;
  letter-spacing: 0;
  font-weight: 400;
}

.spr-tab {
  font-weight: 600 !important;
  display: inline-block;
  padding: 0.5rem 1rem;
  font-family: "AvenirNext", "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5rem;
  letter-spacing: 0;
  font-weight: 400;
}

.spr-tab:not(.disabled) {
  cursor: pointer;
}

.spr-tab .active {
  position: relative;
  overflow: hidden;
  padding-bottom: 0.625rem;
}

.spr-tab .active:before {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 0.25rem;
  content: '';
  animation: 0.11s 1 alternate activeIndicator;
  background-color: #2ba148;
}

.spr-tab:hover {
  background-color: #ebebeb;
}

.spr-tab.disabled,
.spr-tab.disabled > a {
  cursor: default;
  pointer-events: none;
  opacity: 0.5;
}