A pill that goes where you look, and comes home to where you are.
The prompt17,486 characters
Add the "Navbar" component from notboring to my project.
It is licensed for use in my projects — notboring.dev/license. Please:
1. Create the component at a sensible path for this
project, named Navbar, from the source below.
2. Install what it needs: npm i framer-motion
3. Add the CSS to the project's stylesheet.
4. THE PART THAT NEEDS YOUR JUDGMENT. The CSS reads
these custom properties and does not define them:
--card
--font-ui
--ink
--ink-2
--ink-3
--ink-rgb
They are notboring's design tokens. Map each one to
whatever this project already uses for the same
job — its own ink, ground, surface and UI font —
rather than defining them as new globals. If the
project has no equivalent, define it locally on
the component's own root so nothing leaks out.
Anything ending -rgb wants three bare numbers,
because the CSS builds rgba() from it.
Keep the comments. They say why the numbers are what
they are, and they are most of what makes this worth
copying rather than rewriting.
--- Navbar.tsx ---
import { useEffect, useLayoutEffect, useRef, useState } from "react";
import { motion, useSpring, useTransform, useVelocity } from "framer-motion";
/* ══ Navbar ═══════════════════════════════════════════════
Four links in a pill, and one thumb that goes where you
look and comes home to where you are.
ONE THUMB, NOT FOUR HOVER STATES. The obvious build gives
every link a background that fades in under the pointer,
and it is obvious because it is one line of CSS — but four
fills fading in and out are four events, and a bar whose
highlight blinks from link to link reads as four buttons
that happen to be adjacent. One element that TRAVELS reads
as a single control with four positions, which is what a
nav is.
And it comes home. Leave the bar and the thumb returns to
the active link rather than staying where the pointer last
was, so at rest the bar always says where you are and
never where you were about to go.
THE THUMB IS PLACED BY ARITHMETIC ON LAYOUT PIXELS. Its x
and width are read from each link's offsetLeft and
offsetWidth — numbers in the block's own coordinates that
The rest — the source and its comments — is what you are buying.