Import Preview

Import Preview is a copy-paste React component that stops bad csv import created junk records 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/import-preview
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

StopsBad CSV import created junk records

Was this component page useful?

How do I install Import Preview?

pnpm dlx shadcn@latest add @bollard/import-preview

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

How do I use Import Preview in React?

import-preview-usage.tsx
import { ImportPreview, type ImportField } from "@/components/ui/import-preview"

<ImportPreview
  fileName="contacts-oct.csv"
  rows={rows}
  fields={fields}
  uniqueKey="email"
  isExisting={(key) => existing.has(key)}
  onImport={async (records) => {
    await new Promise((r) => setTimeout(r, 600))
    setDone(records.length)
  }}
/>

What input mistakes does Import Preview catch?

  • Title lines above the real headings, and headings about to be imported as a record
  • Columns matched by heading or by their values, with a confidence
  • Required fields left unmapped: import is held
  • Duplicates in the file and against existing records
  • Repeated headings and cells that fail a field's check

What props does Import Preview accept?

ImportPreview props
PropTypeDefault
rows* (required)

The parsed file, one array of cells per line, as CSV/XLSX parsers return it.

string[][]—
fields* (required)

The fields you import into.

ImportField[]—
fileName

File name shown in the header.

string—
uniqueKey

Field that identifies a record, for duplicate checks (compared trimmed and case-insensitively).

string—
isExisting

Whether a record with this (lower-cased) key already exists.

(key: string) => boolean—
onImport

Receives the clean records. Return a promise to show a pending state.

(records: Record<string, string>[]) => void | Promise<void>—
importLabel

Templates: `{count}` and `{skip}` are filled in.

string"Import {count}"
skipLabel

Template for the skip count; {skip} is filled in.

string"skip {skip}"
notMappedLabel

Option text for a column that won't be imported.

string"Don't import"
requiredText

Shown while a required field is unmapped.

string"{field} is required. Pick the column that holds it."

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

How is Import Preview accessible?

  • Each column mapping select has a label in a labelled list
  • Status and counts are in polite live regions; unmapped required fields use role=alert
  • Skipped-line groups expand with aria-expanded

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

What are the limitations and server boundaries?

This is a UX guard rail. Enforce on the server: Validate rows and enforce uniqueness constraints on the server during the import.

  • Needs rows already parsed; it doesn't read CSV or XLSX itself
  • Value-based matching is a guess; check low-confidence columns
  • Duplicate check uses one key field, trimmed and case-insensitive

What expensive mistakes does Import Preview stop?

Bad CSV import created junk records

Also known as

csv import · excel upload · bulk upload · column mapping · import contacts · xlsx · papaparse · data import

Field type

What dependencies does Import Preview require?

Import Preview facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameImport Preview
Registry identifier@bollard/import-preview
Install commandnpx shadcn@latest add @bollard/import-preview
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 Import Preview

What form validation mistake does Import Preview catch?

Import Preview prevents bad CSV import created junk records. Previews a CSV or spreadsheet import, finds the real heading row and maps columns, so a bad file doesn't create junk records. Catches: Title lines above the real headings, and headings about to be imported as a record, Columns matched by heading or by their values, with a confidence, Required fields left unmapped: import is held, Duplicates in the file and against existing records, Repeated headings and cells that fail a field's check. Limitation: validate import-preview schemas on backend.

How do I install import-preview with shadcn?

Run `npx shadcn@latest add @bollard/import-preview`. Sources added: registry/default/import-preview/import-match.ts, registry/default/import-preview/import-preview.tsx. Package requirements: lucide-react.

What props customize Import Preview?

Import Preview accepts `rows`, `fields`, `fileName`, `uniqueKey`, `isExisting`. Configures csv import, excel upload, bulk upload behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of import-preview?

Needs rows already parsed; it doesn't read CSV or XLSX itself. Value-based matching is a guess; check low-confidence columns. Duplicate check uses one key field, trimmed and case-insensitive Server requirement: Validate rows and enforce uniqueness constraints on the server during the import.

How does Import Preview meet accessibility guidelines?

Each column mapping select has a label in a labelled list. Status and counts are in polite live regions; unmapped required fields use role=alert. Skipped-line groups expand with aria-expanded. Minimizes errors: csv import wrong columns, header row imported as data.

Which components pair with Import Preview?