Hidden Field Guard

Hidden Field Guard is a copy-paste React component that stops hidden field still submitted old value 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/hidden-field-guard
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

StopsHidden field still submitted old value

Was this component page useful?

How do I install Hidden Field Guard?

pnpm dlx shadcn@latest add @bollard/hidden-field-guard

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

What input mistakes does Hidden Field Guard catch?

  • Values left in a section the user has hidden
  • Whether those values will still be submitted
  • Clearing that bypasses React state: it fires real input events instead

What props does Hidden Field Guard accept?

HiddenFieldGuard props
PropTypeDefault
hidden* (required)

Whether the section is currently hidden (toggle off, another tab or step selected).

boolean—
label* (required)

The section's name, e.g. "Shipping address".

string—
hiddenValues

What happens to hidden values on submit. `submitted`: they're still sent. `discarded`: the section is disabled, so the browser leaves them out.

"submitted" | "discarded""submitted"
onClear

Called after Clear with the names of the fields that were emptied.

(names: string[]) => void—
message

Templates: `{label}`, `{count}` and `{fields}` ("3 filled fields") are filled in.

string"{label} is hidden but still has {fields}."
submittedText

Detail line. `{names}` is filled in.

string"{names} will still be submitted."
discardedText

Shown when hidden values will be dropped on submit.

string"{names} won't be sent while it's hidden."
clearedText

Shown after the values are cleared.

string"Cleared {fields} from {label}."
clearLabel

Clear button text.

string"Clear them"
keepLabel

Keep button text.

string"Keep"
undoLabel

Undo button text.

string"Undo"

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

How is Hidden Field Guard accessible?

  • Banner is a labelled region inside a polite live region
  • Field names come from the field's label, aria-label, placeholder or name
  • Keep, Clear and Undo are buttons; icons are aria-hidden

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

What are the limitations and server boundaries?

  • Only sees native inputs inside the section's DOM; custom widgets that keep values elsewhere are missed
  • Submitted vs dropped depends on the hiddenValues/submitted setting you pass, not on inspecting your submit code

What expensive mistakes does Hidden Field Guard stop?

Hidden field still submitted old value

Also known as

conditional fields · hidden fields · show hide · react hook form · shouldUnregister · form state · toggle section

What dependencies does Hidden Field Guard require?

Hidden Field Guard facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameHidden Field Guard
Registry identifier@bollard/hidden-field-guard
Install commandnpx shadcn@latest add @bollard/hidden-field-guard
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 Hidden Field Guard

What form validation mistake does Hidden Field Guard catch?

Hidden Field Guard prevents hidden field still submitted old value. When a conditional form section is hidden, it names the fields still filled in there, so old values don't ride along unseen. Catches: Values left in a section the user has hidden, Whether those values will still be submitted, Clearing that bypasses React state: it fires real input events instead. Limitation: validate hidden-field-guard schemas on backend.

How do I install hidden-field-guard with shadcn?

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

What props customize Hidden Field Guard?

Hidden Field Guard accepts `hidden`, `label`, `hiddenValues`, `onClear`, `message`. Configures conditional fields, hidden fields, show hide behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of hidden-field-guard?

Only sees native inputs inside the section's DOM; custom widgets that keep values elsewhere are missed. Submitted vs dropped depends on the hiddenValues/submitted setting you pass, not on inspecting your submit code Server requirement: backend verification for hidden-field-guard.

How does Hidden Field Guard meet accessibility guidelines?

Banner is a labelled region inside a polite live region. Field names come from the field's label, aria-label, placeholder or name. Keep, Clear and Undo are buttons; icons are aria-hidden. Minimizes errors: hidden field submitted, conditional field kept value.

Which components pair with Hidden Field Guard?