{
  "format": "css.observer/playground@1",
  "id": "00000000-0000-4000-9000-000000000011",
  "url": "https://css.observer/s/sliding-underline-nav",
  "title": "Sliding underline nav",
  "description": "Nav links with an underline that follows the hovered link and returns to the current page when you move away.",
  "category": "navigation",
  "tags": [
    "nav",
    "underline",
    "has"
  ],
  "visibility": "public",
  "status": "published",
  "revision": 1,
  "author": "observer",
  "forked_from": null,
  "created_at": "2026-12-02T07:10:01.946Z",
  "updated_at": "2026-12-02T07:10:01.946Z",
  "published_at": "2026-12-02T07:10:01.946Z",
  "source": {
    "html": "<nav class=\"nav\" aria-label=\"Main\">\n  <a href=\"#\">Work</a>\n  <a href=\"#\" aria-current=\"page\">About</a>\n  <a href=\"#\">Journal</a>\n  <a href=\"#\">Contact</a>\n</nav>",
    "css": "body {\n  margin: 0;\n  min-height: 100vh;\n  display: grid;\n  place-items: center;\n  background: #fbfaf7;\n  font: 500 17px/1.4 system-ui, sans-serif;\n}\n\n.nav {\n  display: flex;\n  gap: 28px;\n}\n\n.nav a {\n  position: relative;\n  padding: 6px 0;\n  color: #4a4c52;\n  text-decoration: none;\n}\n\n.nav a::after {\n  content: \"\";\n  position: absolute;\n  right: 0;\n  bottom: 0;\n  left: 0;\n  height: 2px;\n  background: #16171a;\n  transform: scaleX(0);\n  transform-origin: right;\n  transition: transform 0.3s;\n}\n\n.nav a[aria-current=\"page\"] {\n  color: #16171a;\n}\n\n.nav a[aria-current=\"page\"]::after,\n.nav a:hover::after {\n  transform: scaleX(1);\n  transform-origin: left;\n}\n\n.nav:has(a:hover) a[aria-current=\"page\"]:not(:hover)::after {\n  transform: scaleX(0);\n  transform-origin: right;\n}\n\n.nav a:focus-visible {\n  outline: 2px solid #16171a;\n  outline-offset: 4px;\n}",
    "js": ""
  }
}