Components & UI Animation — Reference
Tab Underline
The Tab Underline is a CSS animation component that an animated underline indicator that smoothly slides to track the active tab in navigation bars. Ideal for tab-based navigation, settings pages, or content sections where context switching needs visual continuity. It ships as self-contained HTML and CSS with no external dependencies, making it drop-in ready for any modern web project regardless of framework or build system.
When to use the Tab Underline
- App chrome, admin dashboards, and multi-section SPAs
- Component libraries and design systems that need consistent motion patterns
- Progressive enhancement — works in all modern browsers, degrades gracefully
Performance characteristics
- GPU-accelerated — uses CSS transform and opacity so compositing happens off the main thread
- Zero JavaScript dependency in most configurations — no framework, no bundler required
- Approximately 60 fps on any device that supports CSS animations (Chrome 43+, Firefox 16+, Safari 9+)
- Self-contained in a single HTML file — no npm install, no build step, paste and ship
How it compares
Unlike equivalent JavaScript implementations, the Tab Underline does not require any runtime library — there is nothing to install, bundle, or load asynchronously.
Compared to animated GIFs or video embeds, this CSS component is resolution-independent, theme-able via CSS custom properties, and weighs a fraction of the equivalent media file.
Source code
CSS
body { margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #0f0f0f; font-family: 'Geist', system-ui, -apple-system, sans-serif; }
.tabs { display: flex; gap: 0; width: 320px; border-bottom: 2px solid #27272a; position: relative; }
.tabs .indicator { position: absolute; bottom: -2px; left: 0; height: 2px; background: #3b82f6; width: 80px; transition: transform 0.35s ease; }
.tab { padding: 12px 20px; cursor: pointer; color: #71717a; font-weight: 500; transition: color 0.2s; }
.tab.active { color: #fff; }HTML
<div class="tabs"><div class="indicator"></div><span class="tab active">Home</span><span class="tab">About</span><span class="tab">Contact</span></div>Full source
<!DOCTYPE html>
<html><head><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&display=swap" rel="stylesheet"><style>
body { margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #0f0f0f; font-family: 'Geist', system-ui, -apple-system, sans-serif; }
.tabs { display: flex; gap: 0; width: 320px; border-bottom: 2px solid #27272a; position: relative; }
.tabs .indicator { position: absolute; bottom: -2px; left: 0; height: 2px; background: #3b82f6; width: 80px; transition: transform 0.35s ease; }
.tab { padding: 12px 20px; cursor: pointer; color: #71717a; font-weight: 500; transition: color 0.2s; }
.tab.active { color: #fff; }
</style></head><body>
<div class="tabs"><div class="indicator"></div><span class="tab active">Home</span><span class="tab">About</span><span class="tab">Contact</span></div>
</body></html>Frequently asked questions
How do I add the Tab Underline to my project?
Copy the full source code from the code block on this page. Paste the <style> block into your stylesheet (or a <style> tag in your HTML head) and the HTML markup into your template. No npm install or build step is required — the animation is self-contained. To customize colors, speed, or size, use Grepped's workspace at grepped.dev/animations/components-ui/tab-underline.
Is the Tab Underline free to use?
Yes. All Grepped preset animations are free to use in personal and commercial projects. You may copy, modify, and redistribute the code without attribution. The only limitation is that you may not resell the presets themselves as part of a competing animation library.
Does the Tab Underline work on mobile browsers?
Yes. The Tab Underline uses standard CSS animations and transforms that are supported in all modern mobile browsers — Chrome for Android, Safari on iOS 9+, Samsung Internet, and Firefox for Android. Where JavaScript is used for interactivity (e.g. cursor effects), it falls back gracefully on touch devices.
Can I customize the Tab Underline's colors, speed, or size?
Yes. Open the live customization workspace at grepped.dev/animations/components-ui/tab-underline to adjust the animation with real-time sliders, color pickers, and toggles — no code required. For deeper changes, the source code uses CSS custom properties (variables) so you can edit them directly in your stylesheet.
Want to customize this animation or generate a new one from a text prompt?
Open in Workspace — it's free