How to Use Claude Code to Build a Responsive Navbar
Claude Code can scaffold a production-ready responsive navbar — mobile hamburger menu, desktop links, accessibility attributes and all — in a single session. This guide is for developers who want to stay in flow: no context switching, no copy-pasting from Stack Overflow, just a working component. The main trade-off is token usage: complex, back-and-forth iterations consume your hourly limit fast, so knowing how much headroom you have before you start matters.
- Claude Code uses an hourly rolling usage window — a long navbar session can consume a significant chunk of it.
- The
/usageslash command lets you check remaining tokens without leaving your terminal. - Usage resets on a 5-hour rolling window; getting locked out mid-PR is a real risk on complex UI tasks.
What does "responsive navbar" mean in the context of Claude Code prompts?
Before writing your first prompt, be explicit about what "responsive" means for your project. Claude Code works best when you front-load specifics rather than iterate from vague starting points. A well-scoped prompt produces a usable first draft; a vague one burns tokens on clarifying rounds.
Decide upfront:
- Framework: React, Vue, plain HTML/CSS, Tailwind, CSS Modules?
- Breakpoints: mobile-first (<768 px hamburger) or desktop-first?
- Behaviour: slide-in drawer, dropdown mega menu, sticky/fixed position?
- Accessibility: ARIA roles (
role="navigation",aria-expanded), keyboard nav, focus trap in mobile drawer?
How to prompt Claude Code to build a responsive navbar step by step
Step 1 — open a Claude Code session and check your usage
Before you start any substantial UI task, run the built-in usage command so you know your headroom:
/usage
This shows your remaining token budget for the current window (more on what the /usage command shows). If you're already at 70%+ of your limit, finish any open tasks before starting a new component — a mid-session lockout on a navbar means losing context and momentum. You can also view your usage at any time on claude.ai/settings/usage.
Step 2 — write a scoped, single-shot prompt
A good first prompt for a responsive navbar looks like this:
Build a responsive navbar in React with Tailwind CSS.
Requirements:
- Logo on the left, nav links (Home, About, Blog, Contact) on the right
- On mobile (<768px): hamburger icon toggles a slide-down menu
- Active link gets an underline indicator
- Sticky at the top, white background, subtle bottom shadow
- Fully accessible: role="navigation", aria-label, aria-expanded on the toggle button
- No external icon libraries — use inline SVG for the hamburger icon
The more constraints you give upfront, the fewer correction rounds you'll need — and the less of your hourly budget you'll spend.
Step 3 — review the generated component
Claude Code will produce a complete component file. Check for:
- State management — is
isOpenstate handled correctly for the mobile toggle? - CSS breakpoints — do Tailwind responsive prefixes (
md:,lg:) match your design system? - Accessibility — is
aria-expandedtoggling dynamically? Does pressingEscapeclose the menu? - Router compatibility — if you're using Next.js or React Router, are links using the correct
<Link>component?
Step 4 — iterate with targeted follow-up prompts
Rather than sending one massive revision prompt, make targeted asks. Each is cheaper in tokens and easier for the model to execute accurately:
- "Add a CTA button ('Get Started') in the top-right corner styled as a primary button."
- "Add a smooth height transition to the mobile menu open/close animation using Tailwind's transition utilities."
- "Make the navbar hide on scroll down and reappear on scroll up (hide-on-scroll pattern)."
Step 5 — ask for a dark mode variant
If your app supports dark mode, a single follow-up prompt handles it:
Update the navbar to support Tailwind dark mode using the 'class' strategy.
Dark background: bg-gray-900, text: text-gray-100, border: border-gray-700.
Step 6 — generate tests
Once the component looks right, ask Claude Code to write tests:
Write React Testing Library tests for this navbar:
- Toggle opens and closes the mobile menu
- Active link class is applied to the current route
- Hamburger button has correct aria-expanded attribute
How to use Claude Code slash commands during a navbar build
Claude Code's slash commands are useful throughout a UI build session:
/usage— check remaining token budget before starting a large iteration./clear— clears conversation context; useful before switching from navbar to a new component so you're not wasting tokens on stale context./review— ask Claude Code to review the component it just generated for potential issues.
Slash commands run in-terminal, so you never have to leave your editor environment to check in on your session.
Why usage limits matter when building UI components with Claude Code
Responsive UI components are iterative by nature. You'll go back and forth — tweak spacing, adjust breakpoints, add animations. Each exchange uses tokens, and Claude Code operates on a 5-hour rolling usage window (see when Claude Code usage resets). If you're 90% through your limit while debugging a stubborn mobile layout, you'll hit a lockout at the worst possible time.
This is exactly what Usagebar solves. It sits in your macOS menu bar and shows your Claude Code usage in real time — no browser tab needed, no context switching. You'll see your current usage percentage at a glance while you code, and get smart notifications at 50%, 75%, and 90% so you can pace your session or wrap up a component before hitting the wall.
- Credentials are stored securely in macOS Keychain — nothing leaves your machine.
- Shows exactly when your usage window resets so you can plan multi-step builds.
- Pay what you want model; free for students.
Get Usagebar — instant download, no subscription required.
Common pitfalls when generating navbars with Claude Code
| Pitfall | What goes wrong | Fix |
|---|---|---|
| Vague initial prompt | Claude produces a generic navbar that needs 5+ correction rounds | Specify framework, breakpoints, and behaviour upfront |
| Not specifying the router | Links use plain <a> instead of <Link> from Next.js/React Router | Mention your router in the prompt |
| Skipping accessibility requirements | Missing aria-expanded, no keyboard close on Escape | Add an explicit accessibility checklist to your prompt |
| Running low on usage mid-session | Session interrupted; lose context on partially refactored component | Check /usage before starting; use Usagebar for passive monitoring |
| One giant revision prompt | Model misses some changes; harder to verify output | Break revisions into targeted single-concern prompts |
Key takeaways
- Front-load your prompt with framework, breakpoints, behaviour, and accessibility requirements to minimise iteration rounds.
- Run
/usagebefore starting any substantial UI task to check your remaining token budget. - Use targeted follow-up prompts (one concern at a time) rather than large revision dumps.
- Ask for tests as a final step — Claude Code can write React Testing Library specs from the component it just built.
- Monitor your usage passively with Usagebar in your macOS menu bar to avoid a 5-hour lockout mid-PR.
Further reading
Track Your Claude Code Usage
Never hit your usage limits unexpectedly. Usagebar lives in your menu bar and shows your 5-hour and weekly limits at a glance.
Get Usagebar