Menu
CoddyTech

Current Navigation Links

Part of the Routing and State section of Coddy's Vue journey. Lesson 9 of 55.

Vue Router adds classes to links that match the current route. For these simple top-level records, the exact current link receives router-link-exact-active and the default aria-current="page". A scoped style can highlight that link.

nav a { color: gray; }
nav .router-link-exact-active { color: teal; }

The router manages the class as navigation changes; do not permanently attach it to every link. A link can use exact-active-class="selected-page" to choose a custom class. Active matching uses route records and parameters, not an arbitrary path substring; nested-route behavior is covered later.

challenge icon

Challenge

Medium

Style the three supplied router links so only the exact current destination has font weight 700, while the others have 400. Use Vue Router's exact-active class. Preserve real links, including their generated aria-current="page" for the current destination.

Keep the supplied route readout and bootstrap files.

Try it yourself

<!doctype html><html><head><meta charset="UTF-8"><title>Routing practice</title></head><body><div id="app"></div><script type="module" src="./main.js"></script></body></html>
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Routing and State