AnimationsTabsTutorials

Tab Bar with Sliding Animation

Tab Bar with Sliding Animation

Tab Bar with Sliding Animation

Before We Start to Tab Bar with Sliding Animation

Tab Bar with Sliding Animation can be used to animate a Navigation bar, Menu, etc. and create user attractive UI components.

So if you are a person who wishes to develop a website, you have to know how to create animations properly. Check out our tutorial and you can learn this techniques and use it on your web development. Below sections shows how to develop this animations.

How to create? We are here to solve your problem. In this article we discuss how to create a hover effect animations. Before we start please read the below articles which easier you to understand the process, if you are new to development.

Step 1 – Add HTML

It’s too easy and simple. Just copy and paste below code in your HTML editor between <body> </body> tag as below.

<body>
 <div class="container">
        <div class="tabs">
            <input type="radio" id="radio-1" name="tabs" checked />
            <label class="tab" for="radio-1">Notification<span class="notification">7</span></label>
            <input type="radio" id="radio-2" name="tabs" />
            <label class="tab" for="radio-2">Tab 2</label>
            <input type="radio" id="radio-3" name="tabs" />
            <label class="tab" for="radio-3">Tab 3</label>
            <span class="glider"></span>
        </div>
    </div>
</body>

Step 2 – Add CSS

Copy and paste below code in your HTML editor between <style></style> tag as below.

<style>
        :root {
            --primary-color: #465d12;
            --secondary-color: #c1cda6;
        }

        *,
        *:after,
        *:before {
            box-sizing: border-box;
        }

        body {
            font-family: "Inter", sans-serif;
            background-color: rgba(230, 238, 249, 0.5);
        }

        .container {
            position: absolute;
            left: 0;
            top: 0;
            right: 0;
            bottom: 0;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .tabs {
            display: flex;
            position: relative;
            background-color: #fff;
            box-shadow: 0 0 1px 0 rgba(24, 94, 224, 0.15), 0 6px 12px 0 rgba(24, 94, 224, 0.15);
            padding: 0.75rem;
            border-radius: 99px;
        }

        .tabs * {
            z-index: 2;
        }

        input[type=radio] {
            display: none;
        }

        .tab {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 54px;
            width: 200px;
            font-size: 1.25rem;
            font-weight: 500;
            border-radius: 99px;
            cursor: pointer;
            transition: color 0.15s ease-in;
        }

        .notification {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 2rem;
            height: 2rem;
            margin-left: 0.73rem;
            border-radius: 50%;
            background-color: var(--secondary-color);
            transition: 0.15s ease-in;
        }

        input[type=radio]:checked+label {
            color: var(--primary-color);
        }

        input[type=radio]:checked+label>.notification {
            background-color: var(--primary-color);
            color: #fff;
        }

        input[id=radio-1]:checked~.glider {
            transform: translateX(0);
        }

        input[id=radio-2]:checked~.glider {
            transform: translateX(100%);
        }

        input[id=radio-3]:checked~.glider {
            transform: translateX(200%);
        }

        .glider {
            position: absolute;
            display: flex;
            height: 54px;
            width: 200px;
            background-color: var(--secondary-color);
            z-index: 1;
            border-radius: 99px;
            transition: 0.25s ease-out;
        }

        @media (max-width: 700px) {
            .tabs {
                transform: scale(0.6);
            }
        }
    </style>

At the end we will have something like this. You can change fonts, colors, backgrounds and all things that you want. Enjoy it.

Out Put

Video Tutorial

Please watch this video to better understand this tutorial and don’t forget to subscribe to our channel.


Help others to find out about this article on Social Media sites. If you have any doubt or any problem, don’t hesitate to contact us. Thereafter we will be able to help you and also make sure you bookmark our site on your browser.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button