See how Frete cut frontend build time by 70%

What are best AI tools? Take the State of AI survey

Builder.io
Builder.io
Contact sales

See how Frete cut frontend build time by 70%

What are best AI tools? Take the State of AI survey

Builder.io
Builder.io
< Back to blog

Web Development

Active Navlink Transitions with HTML, CSS and JavaScript

January 9, 2024

Written By Vishwas Gopinath

In this blog post, we'll explore how to create an active navlink transition using HTML, CSS, and JavaScript, a feature that can add a nice touch to your portfolio or landing page.

Generating markup from your design

To begin, we'll use Visual Copilot, an AI powered Figma to Code plugin, to accelerate the process. This tool can convert Figma designs into HTML and CSS code, saving us valuable time. Here are the steps:

1. Start with a mockup in Figma, which you can find here.

2. Run Builder.io's Figma plugin, select your design, and click the Generate code button. This action generates the initial HTML and CSS.

3. Copy and paste the generated code into a playground of your choice like Codepen, for example.

Here's the HTML code generated by Visual Copilot in Quality mode:

And here’s the generated CSS:

Adding the navlink transition

HTML changes

In the HTML, add a div tag with the underline class right after the 4 links to create the visual underline effect:

CSS changes

In the CSS styles, make the following changes to customize the navlink appearance:

  • Remove the underline from all the navlinks using text-decoration: none; to prepare for the custom underline effect.
  • Set the nav container to a relative position.
  • Add styles for the underline class to create the underline effect.

JavaScript changes

For the JavaScript logic, find all the link elements and attach a click event handler. Within the handler, update the width and left properties of the underline element to match the clicked link’s offsetWidth and offsetLeft properties:

The active navlink underline should now transition smoothly when a link is clicked.

Light bulb tip icon.

You can find the full source code on my Codepen

Share

Twitter
LinkedIn
Facebook
Code the hard parts.
Offload the follow ups.
Push your branch to Builder so Design, PM, and QA can polish pixels, edit copy, and test in the real app - saving you time and feedback cycles.

Continue Reading
Agent-Native8 MIN
The Real Reason Coding Agents Get More Done
WRITTEN BY Pratham
September 17, 2026
AI11 MIN
How to De-Slop an AI-Generated Codebase
WRITTEN BY Alice Moore
September 16, 2026
AI9 MIN
Introducing Agent Native Analytics
WRITTEN BY Matt Abrams
September 10, 2026

Product

Visual CMS

Theme Studio for Shopify

Sign up

Login

Featured Integrations

React

Angular

Next.js

Gatsby

Resources

User Guides

Developer Docs

Forum

Blog

Github

Get In Touch

Chat With Us

Twitter

Linkedin

Careers

© 2020 Builder.io, Inc.

Security

Privacy Policy

Terms of Service

  • Fusion

  • Publish

  • Product Updates

  • Design to Code

  • Headless CMS

    Multi-Brand CMS

  • Landing Pages

  • Web Apps

  • Prototypes

  • Marketing Sites

  • Headless Commerce

Developer Resources

  • Documentation

  • Fusion Docs

  • Publish Docs

  • Figma AI to Production Code

  • AI Prototyping for Product Managers

  • Figma to Storybook

  • Figma to App Converter

  • All Resources

  • Blog

  • Webinars

  • Guides

  • Customer Stories

  • Community Forum

  • Partners

  • Affiliate Program

  • CMS Integrations

  • CMS Blueprints

  • Explainers

  • Glossary

  • Agent-Native

  • Figma to Code Guide

  • Headless CMS Guide

  • Headless Commerce Guide

  • Composable DXP Guide

  • About

  • Careers

  • Contact Sales

Security

Privacy Policy

SaaS Terms

Trust Center

Cookie Preferences

YouTube icon
Github icon
Twitter "X" icon
LinkedIn icon
Feed Icon