Column Mapper

Column Mapper is a copy-paste React component that stops spreadsheet imported into wrong fields 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/column-mapper
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

StopsSpreadsheet imported into wrong fields

Was this component page useful?

How do I install Column Mapper?

pnpm dlx shadcn@latest add @bollard/column-mapper

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

How do I use Column Mapper in React?

column-mapper-usage.tsx
import { ColumnMapper, type ColumnTarget, type MapperColumn, type MapperField } from "@/components/ui/column-mapper"

<ColumnMapper columns={columns} fields={fields} defaultValue={saved} onContinue={(m) => setDone(`Mapped ${m.filter((x) => x.field).length} columns.`)} />

What input mistakes does Column Mapper catch?

  • Values that don't fit the mapped field (an email in Phone)
  • First and last name columns swapped, using a first-name list
  • Day/month order misread, with a readback of what a sample date becomes
  • The same field mapped twice, and required fields left unmapped

What props does Column Mapper accept?

ColumnMapper props
PropTypeDefault
columns* (required)

The spreadsheet's columns, each with its heading and a sample of values.

MapperColumn[]—
fields* (required)

The fields you import into. `kind` drives the swap and date checks.

MapperField[]—
value

Controlled mapping, one entry per column.

ColumnTarget[]—
defaultValue

Initial mapping when uncontrolled (e.g. your auto-match or last saved mapping).

ColumnTarget[]—
onValueChange

Called with the mapping on every change.

(value: ColumnTarget[]) => void—
onContinue

Shows a Continue button; receives the mapping with every date order filled in.

(value: ColumnTarget[]) => void—
firstNames

First names used to spot swapped first/last name columns.

string[]COMMON_FIRST_NAMES
messages

Every visible string, for copy changes and translation.

Partial<ColumnMapperMessages>—

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

How is Column Mapper accessible?

  • Each column uses a native <select>
  • After a fix, focus moves to the affected select
  • Issues use icons plus text, and each fix and keep action is a button

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 types and required fields again on the server during import.

  • Works from the sample rows you pass; problems further down the file are not seen
  • Name-swap detection depends on the firstNames list and can miss uncommon names

What expensive mistakes does Column Mapper stop?

Spreadsheet imported into wrong fields

Also known as

csv import · excel upload · column mapping · bulk import · spreadsheet · data import · field mapping · xlsx

Field type

What dependencies does Column Mapper require?

Column Mapper facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameColumn Mapper
Registry identifier@bollard/column-mapper
Install commandnpx shadcn@latest add @bollard/column-mapper
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 Column Mapper

What form validation mistake does Column Mapper catch?

Column Mapper prevents spreadsheet imported into wrong fields. Checks a spreadsheet column mapping against the actual values, so emails don't land in the phone field and DD/MM dates aren't read as MM/DD. Catches: Values that don't fit the mapped field (an email in Phone), First and last name columns swapped, using a first-name list, Day/month order misread, with a readback of what a sample date becomes, The same field mapped twice, and required fields left unmapped. Limitation: validate column-mapper schemas on backend.

How do I install column-mapper with shadcn?

Run `npx shadcn@latest add @bollard/column-mapper`. Sources added: registry/default/column-mapper/column-mapper.tsx, registry/default/column-mapper/column-sniff.ts. Package requirements: lucide-react.

What props customize Column Mapper?

Column Mapper accepts `columns`, `fields`, `value`, `defaultValue`, `onValueChange`. Configures csv import, excel upload, column mapping behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of column-mapper?

Works from the sample rows you pass; problems further down the file are not seen. Name-swap detection depends on the firstNames list and can miss uncommon names Server requirement: Validate types and required fields again on the server during import.

How does Column Mapper meet accessibility guidelines?

Each column uses a native <select>. After a fix, focus moves to the affected select. Issues use icons plus text, and each fix and keep action is a button. Minimizes errors: csv import wrong columns, date dd mm swapped import.

Which components pair with Column Mapper?