Repeat Rows

Repeat Rows is a copy-paste React component that stops duplicate line items in add-another form before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/repeat-rows
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsDuplicate line items in add-another form

Was this component page useful?

How do I install Repeat Rows?

pnpm dlx shadcn@latest add @bollard/repeat-rows

The files land in your project. They're yours to edit.

How do I use Repeat Rows in React?

repeat-rows-usage.tsx
import { cleanRows, RepeatRows, type RepeatField, type RepeatRow } from "@/components/ui/repeat-rows"

<RepeatRows label="Guests" itemLabel="Guest" fields={fields} value={guests} onValueChange={setGuests} uniqueBy={["email"]} min={1} max={5} />

What input mistakes does Repeat Rows catch?

  • Duplicate rows, compared case- and space-insensitively on uniqueBy keys
  • Blank rows, with a one-tap clean-up
  • Accidental removes, with Undo in place
  • Enter in the last row adding a row instead of submitting
  • Min and max row counts

What props does Repeat Rows accept?

RepeatRows props
PropTypeDefault
label* (required)

Legend for the group.

string—
fields* (required)

The columns in each row.

RepeatField[]—
value

Controlled rows.

RepeatRow[]—
defaultValue

Initial rows when uncontrolled.

RepeatRow[]—
onValueChange

Called with every row, blanks included. Use `cleanRows` before saving.

(rows: RepeatRow[]) => void—
min

Fewest rows; remove is disabled at this count.

number1
max

Most rows; add is disabled at this count.

numberInfinity
uniqueBy

Fields that make two rows the same thing, e.g. `["email"]`.

string[]—
itemLabel

What one row is, e.g. "Guest".

string"Item"
undoMs

How long Undo stays after a remove, in ms.

number5000
addLabel

Label of the add-row button.

string"Add {item}"
undoLabel

Label of the Undo button after a remove.

string"Undo"
duplicateText

Templates: `{item}`, `{n}`, `{max}` and `{count}` are filled in.

string"Same as {item} {n}."
removeDuplicateLabel

Label of the one-tap remove on a duplicate row.

string"Remove this one"
emptyText

Shown when blank rows would be submitted.

string"{count} blank {rows} will be skipped."
cleanLabel

Label of the button that removes blank rows.

string"Remove blank rows"
maxText

Shown when the maximum number of rows is reached.

string"That's the limit of {max}."

* required. Also accepts the native props of <fieldset> (className, aria-*, data-*…), passed through to it.

How is Repeat Rows accessible?

  • Each row is a group labelled "Item n of m"; inputs carry per-row aria-labels
  • Enter moves to the next row or adds one; focus moves to the new or next logical field after add/remove
  • Remove buttons have aria-labels and disable at the minimum
  • Duplicate and blank notices render in polite live regions

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

  • Duplicate check compares only the keys you list in uniqueBy
  • Undo is time-limited (undoMs) and in-memory
  • Validation of field contents is up to you

What expensive mistakes does Repeat Rows stop?

Duplicate line items in add-another form

Also known as

add another · field array · line items · useFieldArray · guests · invoice items · dynamic rows · react hook form

Field type

What dependencies does Repeat Rows require?

Repeat Rows facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameRepeat Rows
Registry identifier@bollard/repeat-rows
Install commandnpx shadcn@latest add @bollard/repeat-rows
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Repeat Rows

How does Repeat Rows prevent financial transaction errors?

Repeat Rows prevents duplicate line items in add-another form. Blocks Duplicate rows, compared case- and space-insensitively on uniqueBy keys, Blank rows, with a one-tap clean-up, Accidental removes, with Undo in place, Enter in the last row adding a row instead of submitting, Min and max row counts before processing. Limitation: apply idempotency keys for repeat-rows.

How do I install repeat-rows with shadcn?

Run `npx shadcn@latest add @bollard/repeat-rows`. Sources added: registry/default/repeat-rows/repeat-rows.tsx. Package requirements: lucide-react.

What props customize Repeat Rows?

Repeat Rows accepts `label`, `fields`, `value`, `defaultValue`, `onValueChange`. Configures add another, field array, line items behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of repeat-rows?

Duplicate check compares only the keys you list in uniqueBy. Undo is time-limited (undoMs) and in-memory. Validation of field contents is up to you Server requirement: backend verification for repeat-rows.

How does Repeat Rows meet accessibility guidelines?

Each row is a group labelled "Item n of m"; inputs carry per-row aria-labels. Enter moves to the next row or adds one; focus moves to the new or next logical field after add/remove. Remove buttons have aria-labels and disable at the minimum. Duplicate and blank notices render in polite live regions. Minimizes errors: duplicate rows in form, removed row by mistake.

Which components pair with Repeat Rows?