Mixed Value Field

Mixed Value Field is a copy-paste React component that stops bulk edit overwrites every record 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/mixed-value-field
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

StopsBulk edit overwrites every record

Was this component page useful?

How do I install Mixed Value Field?

pnpm dlx shadcn@latest add @bollard/mixed-value-field

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

How do I use Mixed Value Field in React?

mixed-value-field-usage.tsx
import { countChanged, MixedValueField, type BulkChange } from "@/components/ui/mixed-value-field"

<MixedValueField
  label="Status"
  values={status}
  options={statusOptions}
  value={statusChange}
  onValueChange={setStatusChange}
  formatItems={tasks}
/>

What input mistakes does Mixed Value Field catch?

  • Mixed values hidden behind a blank or the first record's value
  • Saving overwrites records nobody meant to touch: nothing changes unless a value is picked
  • Count of records that would really change, skipping those that already match
  • Clearing a field on every record: explicit Clear button

What props does Mixed Value Field accept?

MixedValueField props
PropTypeDefault
label* (required)

Field name, e.g. "Status".

string—
values* (required)

The field's current value on each selected record. Empty strings count as empty.

(string | null | undefined)[]—
options

Choices for a select. Leave out for a free-text field.

{ value: string; label?: string }[]—
value

Controlled change.

BulkChange—
defaultValue

Initial change when uncontrolled.

BulkChangenull
onValueChange

Called with the planned change: null keeps values, { set } writes one value.

(change: BulkChange) => void—
allowClear

Offer "Clear on all" so emptying the field is an explicit choice, never an accident.

booleanfalse
formatItems

"40 tasks". Override to name your records or translate.

(count: number) => stringdefaultItems
mixedText

Templates: `{count}`, `{field}`, `{value}`, `{changed}`, `{total}`, `{already}`, `{items}` are filled in.

string"Mixed ({count} values)"
uniformText

Shown when every record has the same value.

string"{value} on all"
emptyText

Label for empty values.

string"Empty"
keepText

Readback when nothing will change.

string"{field} stays as it is on each of the {items}."
setText

Readback template for setting a value.

string"Set {field} to {value} on {changed} of {items}."
alreadyText

Readback for records that already hold the value.

string"{already} already {value}."
clearText

Readback template for clearing the field.

string"Clear {field} on {changed} of {items}."
noopText

Shown when the change alters no records.

string"All {items} are already {value}. Nothing changes."
clearLabel

Clear button text.

string"Clear on all"
revertLabel

Revert button text.

string"Keep as is"

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

How is Mixed Value Field accessible?

  • Visible label; the control is described by the readback
  • Clear uses aria-pressed; Revert is a button
  • The distribution bar is aria-hidden and summarised in text

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

What are the limitations and server boundaries?

  • Works on one field at a time
  • The save itself is yours; it only reports the planned change

What expensive mistakes does Mixed Value Field stop?

Bulk edit overwrites every record

Also known as

bulk edit · batch edit · mixed values · multi select · table actions · admin · multiple records · mass update

Field type

What dependencies does Mixed Value Field require?

Mixed Value Field facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameMixed Value Field
Registry identifier@bollard/mixed-value-field
Install commandnpx shadcn@latest add @bollard/mixed-value-field
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 Mixed Value Field

What form validation mistake does Mixed Value Field catch?

Mixed Value Field prevents bulk edit overwrites every record. In a bulk edit, shows "Mixed (3 values)" with the spread instead of a blank, so saving doesn't silently overwrite every record. Catches: Mixed values hidden behind a blank or the first record's value, Saving overwrites records nobody meant to touch: nothing changes unless a value is picked, Count of records that would really change, skipping those that already match, Clearing a field on every record: explicit Clear button. Limitation: validate mixed-value-field schemas on backend.

How do I install mixed-value-field with shadcn?

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

What props customize Mixed Value Field?

Mixed Value Field accepts `label`, `values`, `options`, `value`, `defaultValue`. Configures bulk edit, batch edit, mixed values behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of mixed-value-field?

Works on one field at a time. The save itself is yours; it only reports the planned change Server requirement: backend verification for mixed-value-field.

How does Mixed Value Field meet accessibility guidelines?

Visible label; the control is described by the readback. Clear uses aria-pressed; Revert is a button. The distribution bar is aria-hidden and summarised in text. Minimizes errors: bulk edit overwrite, mixed values multi select.

Which components pair with Mixed Value Field?