react.jsを使い、タブ文字列をクリックで伸びて移動開始し縮んで移動終了するアニメーションエフェクトが付いたバーです。次の薄いグレーの背景の部分がサンプルです。4つのテキストがタブで、現在の位置は「CURRENT QUARTER」で、他のタブをクリックすると、そこへバーが伸び、縮みながら移動します。
なお、タブの名称変更は、外部のScriptファイル内のTABSの値を書き換える必要があります。
サンプルのhtmlソース
<div id="app"></div>
サンプルのCSSソース
.tabs {
width: auto;
height: 40px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
.tab {
width: auto;
height: 36px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
color: rgba(0, 0, 0, 0.3);
font-size: 16px;/*12px;*/
font-weight: 700;
line-height: 18px;
text-transform: uppercase;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-transition: .35s ease;
transition: .35s ease;
}
.tab:not(:last-child) {
margin-right: 30px;
}
.tab.tab--active {
color: black;
-webkit-transition: .35s ease;
transition: .35s ease;
}
.tab:hover {
color: #333333 !important;
-webkit-transition: .35s ease;
transition: .35s ease;
}
.line {
width: 100%;
height: 3px;
position: absolute;
left: 0;
bottom: 0;
background: -webkit-gradient(linear, left top, right top, from(#b721ff), to(#21d4fd));
background: linear-gradient(to right, #b721ff, #21d4fd);
-webkit-clip-path: polygon(var(--left-side) 0, var(--right-side) 0, var(--right-side) 100%, var(--left-side) 100%);
-webkit-transition: .35s ease;
transition: .35s ease;
}