HoneypotField
SM, under 950B gzippedA bot trap invisible to real users without trapping keyboard or screen reader users.
- Category
- Forms & input
- Budget
- sm, single-purpose control
- Runtime deps
- None
Preview
This is the exact fixture the conformance suite renders in CI. Switch the language to see the component mirror and reformat.
Install
npx shadcn@latest add https://kata-ui-rho.vercel.app/r/honeypot-field.jsonCopies the source into your project. Pulls in 1 primitive: visually-hidden.
Source
import { VisuallyHidden } from "./visually-hidden";
export interface HoneypotFieldProps {
name?: string;
}
/**
* A bot trap that stays invisible to real users without becoming invisible
* to assistive technology in the wrong way. `VisuallyHidden` (clip-based, not
* `display: none`) keeps it out of the visual layout while `tabIndex={-1}`
* and `aria-hidden` keep a keyboard or screen reader user from ever landing
* on it — a simple bot filling every field still fills this one.
*
* Server-side: reject the submission if this field arrives non-empty.
*/
export function HoneypotField({ name = "company_website" }: HoneypotFieldProps) {
return (
<VisuallyHidden as="div">
<label htmlFor={`hp-${name}`}>Leave this field empty</label>
<input id={`hp-${name}`} name={name} type="text" tabIndex={-1} autoComplete="off" aria-hidden="true" />
</VisuallyHidden>
);
}
What CI checks
- Bundled, minified and gzipped against its tier budget
- Audited by axe in the state previewed above
- Rendered through react-dom/server with no browser globals
- Scanned for network calls, dangerous sinks, and unguarded animation