Dev.to AI 🤖 Ai 👁 0 📖 2 min read

Make the agent use the existing Tabs primitive, not a homemade tablist of buttons

The PR adds three in-page views with a row of buttons and a useState index. The repo already has a Tabs primitive with a tablist, tab panels, keyboard movement, and the ARIA pattern already wired. Nearby settings screens

The PR adds three in-page views with a row of buttons and a useState index. The repo already has a Tabs primitive with a tablist, tab panels, keyboard movement, and the ARIA pattern already wired. Nearby settings screens use it. The new control looks like tabs, cannot be arrowed through, and does not set aria-selected or associate panels with tabs.

I've started treating a homemade tablist as an incomplete component, not as a lighter toggle. Switching the panel is the easy part. Keyboard access and the tab/panel relationship are why the primitive is there.

Why the homemade tablist shows up

A tutorial "tabs" example is a button row and a slice of state. The model can write that without finding components/Tabs. Your primitive may wrap Radix or a design-system Tabs, or it may be named TabGroup, which is easy to miss if the prompt only says "add three tabs."

You also skip things reviewers only catch later: arrow keys, Home and End, a focusable tablist, and not putting the selected tab behind a click-only style change.

A simple Tabs policy

  • New in-page panel switchers use the existing Tabs primitive
  • Do not build a button row and a useState index in a feature file
  • Do not use tabs when the job is a route or a stepper — use the existing router or stepper instead
  • A new orientation or size is a primitive change, with a story

If each panel is a separate URL, that is navigation, not tabs. If the steps are sequential, that is a stepper. The primitive is for peer panels on one page.

What to put in the prompt

Use the existing Tabs primitive for this in-page panel switcher.
Do not build a button row with useState in this file.
Keep keyboard movement and the tab/panel relationship on the primitive.
If these views are separate routes or a sequence of steps, use the existing router or stepper instead.

Paste one existing Tabs usage. In review, search the diff for a raw role="tablist", a row of buttons that set a tab index, and a useState panel switch that is not the shared primitive.

Reject / send back

Reject

  • A feature-level tablist that reimplements the Tabs primitive
  • Tabs that only switch on click and ignore arrow keys
  • A second tabs library added for one settings screen
  • Tabs used where the existing router or stepper is the right control

Accept

  • An in-page switcher that uses the existing Tabs primitive
  • A primitive PR that adds a documented orientation or size and a story
  • Separate URLs or sequential steps moved to the existing router or stepper
📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.