- var entries = [['calendar', 'Events'], ['files', 'Files'], ['notification', 'Notification'], ['settings', 'Settings']];
nav(class='tabbar')
ul
each entry, i in entries
- var cls = ''
- if(i == 0)
- cls = 'active'
li(class=cls + ' ' + entry[0])
a(href='')
div
span=entry[1]
a(class='dribbble' href='https://dribbble.com/shots/7164420-Liquid-tab-bar-animation' target='_blank')
img(src='https://cdn.dribbble.com/assets/dribbble-ball-mark-2bd45f09c2fb58dbbfb44766d5d1d07c5a12972d602ef8b32204d28fa3dda554.svg')
View Compiled
.tabbar {
--primary: #275EFE;
--background: #fff;
--inactive: #99A3BA;
--shadow: rgba(18, 22, 33, .24);
--line: #CDD9ED;
background: var(--background);
box-shadow: 0 1px 4px -1px var(--shadow);
border-radius: 5px 5px 21px 21px;
width: 360px;
-webkit-tap-highlight-color: transparent;
overflow: hidden;
ul {
--x: 54px;
margin: 0;
padding: 0 12px;
list-style: none;
display: grid;
position: relative;
overflow: hidden;
text-align: center;
grid-template-columns: repeat(4, minmax(0, 1fr));
&:before {
content: '';
position: absolute;
top: 0;
left: var(--x);
background: var(--primary);
width: 60px;
margin-left: -30px;
height: 40px;
}
li {
position: relative;
&:before,
&:after {
content: '';
background: var(--background);
height: 44px;
width: 84px;
position: absolute;
top: 0;
left: 50%;
margin-left: -42px;
}
&:before {
border-radius: 0 48% 0 0;
}
&:after {
border-radius: 48% 0 0 0;
}
a {
padding: 20px 0;
display: block;
text-decoration: none;
position: relative;
z-index: 1;
color: var(--primary);
transition: transform .2s ease;
&:active {
transform: scale(.9);
}
&:before,
&:after {
content: '';
top: 0;
left: 50%;
position: absolute;
background: var(--primary);
border-radius: 1px;
width: 2px;
margin-left: -1px;
transform-origin: 50% 0;
transform: translateY(-14px) scaleX(.6);
}
&:before {
height: 8px;
}
&:after {
height: 4px;
}
div {
background: var(--inactive);
width: 24px;
height: 24px;
margin: 0 auto 4px auto;
&:before {
--y: -100%;
content: '';
display: block;
width: 100%;
height: 100%;
top: 0;
left: 0;
transform: translateY(var(--y));
position: absolute;
transition: transform .4s linear;
background: var(--primary);
}
}
span {
display: block;
font-weight: 500;
font-size: 14px;
opacity: 0;
transition: opacity .36s linear;
}
}
&.active {
&:before {
animation: before 1.1s ease;
}
&:after {
animation: after 1.1s ease;
}
a {
animation: bounce .9s linear .3s;
&:before {
animation: drop .4s linear .1s forwards;
}
&:after {
animation: drop .5s linear .13s forwards;
}
div {
&:before {
--y: 0;
transition-delay: .3s;
}
}
span {
opacity: 1;
transition-delay: .38s;
}
}
}
&.calendar {
a {
div {
-webkit-mask-box-image: url('https://aaroniker.me/feather-icons/calendar.svg');
mask: url('https://aaroniker.me/feather-icons/calendar.svg');
}
}
}
&.files {
a {
div {
-webkit-mask-box-image: url('https://aaroniker.me/feather-icons/file.svg');
mask: url('https://aaroniker.me/feather-icons/file.svg');
}
}
}
&.notification {
a {
div {
-webkit-mask-box-image: url('https://aaroniker.me/feather-icons/bell.svg');
mask: url('https://aaroniker.me/feather-icons/bell.svg');
}
}
}
&.settings {
a {
div {
-webkit-mask-box-image: url('https://aaroniker.me/feather-icons/settings.svg');
mask: url('https://aaroniker.me/feather-icons/settings.svg');
}
}
}
}
}
}
@keyframes bounce {
40% {
transform: translateY(9px);
}
55% {
transform: translateY(-1px);
}
70% {
transform: translateY(4px);
}
}
@keyframes drop {
50% {
transform: translateY(10px) scaleY(1.2) scaleX(.5);
}
100% {
transform: translateY(20px) scaleY(0) scaleX(.5);
}
}
@keyframes before {
45%,
55% {
transform: translateX(-41px);
}
}
@keyframes after {
45%,
55% {
transform: translateX(41px);
}
}
html {
box-sizing: border-box;
-webkit-font-smoothing: antialiased;
}
* {
box-sizing: inherit;
&:before,
&:after {
box-sizing: inherit;
}
}
// Center & dribbble
body {
font-family: 'Roboto', Arial;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: #EEF4FF;
.dribbble {
position: fixed;
display: block;
right: 20px;
bottom: 20px;
img {
display: block;
height: 28px;
}
}
}
View Compiled
$('.tabbar ul li a').click(function(e) {
let link = $(this),
li = link.parent();
setActive(li.parent(), li);
return false;
});
function setActive(nav, li) {
nav.find('li').removeClass('active');
li.addClass('active');
nav.css('--x', li.position().left + li.outerWidth() / 2 + 'px');
}