Presence Lock

Presence Lock is a copy-paste React component that stops two people editing the same field 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/presence-lock
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

StopsTwo people editing the same field

Was this component page useful?

How do I install Presence Lock?

pnpm dlx shadcn@latest add @bollard/presence-lock

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

How do I use Presence Lock in React?

presence-lock-usage.tsx
import { PresenceAvatars, PresenceLock, type Collaborator } from "@/components/ui/presence-lock"

<PresenceLock field="price" label="Price per guest" htmlFor="pl-price" people={people}>
  <input id="pl-price" defaultValue="₹650" className={input} />
</PresenceLock>

What input mistakes does Presence Lock catch?

  • Two people editing the same field
  • Edit anyway: warns once before overriding
  • Locks held by people who went idle are released
  • Someone already typing is never locked out

What props does Presence Lock accept?

PresenceLock props
PropTypeDefault
field* (required)

The field's key, matched against `Collaborator.field`.

string—
label* (required)

Visible label.

string—
htmlFor

The id of the field's input, so the label is a real `<label>`.

string—
children* (required)

The field itself.

React.ReactNode—
people* (required)

Everyone else on the record.

Collaborator[]—
idleAfter

After this many ms without activity, a person stops locking the field.

number45_000
onEditAnyway

Called when you take the field anyway, e.g. to tell the others.

(field: string) => void—
editingText

Templates: `{names}`, `{label}` and `{when}` are filled in.

string"{names} is editing {label}"
editingManyText

Template when several people edit the field.

string"{names} are editing {label}"
editAnywayLabel

Button text to edit a locked field.

string"Edit anyway"
confirmText

Warning shown before editing anyway.

string"Your change could overwrite theirs."
cancelLabel

Cancel button text.

string"Cancel"
bothText

Template when you and one other are editing.

string"{names} is editing this too. The last save wins."
bothManyText

Template when you and several others are editing.

string"{names} are editing this too. The last save wins."
idleText

Template for people who went idle.

string"{names} was editing {label}, idle for {when}"
freeText

Shown when the field is free.

string"{label} is free to edit now."

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

How is Presence Lock accessible?

  • Avatars are a labelled group; images have empty alt with names in titles
  • Joins and leaves are announced in a polite live region
  • A locked field is inert until Edit anyway

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: Use versioning or merge rules on save so a late write can't silently overwrite another.

  • Soft lock only; your backend must handle conflicting saves
  • Presence comes from your transport; latency can show stale state
  • Idle detection depends on your heartbeats

What expensive mistakes does Presence Lock stop?

Two people editing the same field

Also known as

presence · collaboration · field lock · liveblocks · multiplayer · realtime · avatars · who's editing

Field type

What dependencies does Presence Lock require?

Presence Lock facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component namePresence Lock
Registry identifier@bollard/presence-lock
Install commandnpx shadcn@latest add @bollard/presence-lock
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 Presence Lock

What form validation mistake does Presence Lock catch?

Presence Lock prevents two people editing the same field. Shows who is editing which field and softly locks it in their colour, so two people don't silently overwrite each other's edit. Catches: Two people editing the same field, Edit anyway: warns once before overriding, Locks held by people who went idle are released, Someone already typing is never locked out. Limitation: validate presence-lock schemas on backend.

How do I install presence-lock with shadcn?

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

What props customize Presence Lock?

Presence Lock accepts `field`, `label`, `htmlFor`, `children`, `people`. Configures presence, collaboration, field lock behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of presence-lock?

Soft lock only; your backend must handle conflicting saves. Presence comes from your transport; latency can show stale state. Idle detection depends on your heartbeats Server requirement: Use versioning or merge rules on save so a late write can't silently overwrite another.

How does Presence Lock meet accessibility guidelines?

Avatars are a labelled group; images have empty alt with names in titles. Joins and leaves are announced in a polite live region. A locked field is inert until Edit anyway. Minimizes errors: two users editing same field, collaborative edit overwrite.

Which components pair with Presence Lock?