DevPlatform
Home
Components
Search
Submit
Earn
Login
Sign Up Free
Animated Tabs - Preview | DevPlatform
DevPlatform
Categories
Accordion
Animation
Box Shadow
Button
Card
Footer
Form
Gallery
Hero Section
Inputs
Loader
Marquee
Modal
Modules
Navbar
Progress Bar
Radio Buttons
Search-Bar
Sections
Slider
Tab
Timeline
Toggle
Animated Tabs
jitesh208
Jan 17, 2026
7
0
Share
Live Preview
Refresh
Live Editor
HTML
CSS
JS
HTML
CSS
JavaScript
1
<div class="tabs"> <div class="tab-indicator"></div> <button class="tab active" data-tab="0">Bank</button> <button class="tab" data-tab="1">Card</button> <button class="tab" data-tab="2">Pay Later</button> </div>
1
*{box-sizing:border-box} body{ margin:0; height:100vh; display:grid; place-items:center; background:#f2f2f2; font-family:-apple-system, BlinkMacSystemFont, system-ui; } /* Tabs container */ .tabs{ position:relative; width:300px; background:#f7f7f8; border-radius:18px; padding:4px; display:flex; gap:4px; box-shadow: inset 0 1px 0 rgba(255,255,255,.9), 0 10px 30px rgba(0,0,0,.12); } /* Sliding pill */ .tab-indicator{ position:absolute; top:4px; left:4px; width:calc(100% / 3 - 4px); height:calc(100% - 8px); background:linear-gradient(180deg,#111,#000); border-radius:14px; transition:.45s cubic-bezier(.16,1,.3,1); box-shadow: 0 6px 14px rgba(0,0,0,.35); } /* Tabs */ .tab{ flex:1; border:none; background:none; padding:12px 0; font-size:14px; color:#8a8a8a; cursor:pointer; position:relative; z-index:1; transition:.3s; } .tab.active{ color:#fff; font-weight:500; }
1
const tabs = document.querySelectorAll('.tab'); const indicator = document.querySelector('.tab-indicator'); tabs.forEach((tab, index) => { tab.addEventListener('click', () => { document.querySelector('.tab.active').classList.remove('active'); tab.classList.add('active'); indicator.style.transform = `translateX(${index * 100}%)`; }); });
Comments
0
Want to comment?
Please
login
or
sign up
to post comments.
No comments yet
Be the first to comment on this component!
Comments 0
Want to comment?
Please login or sign up to post comments.
No comments yet
Be the first to comment on this component!