Skip to content

HoneypotField

SM, under 950B gzipped

A 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

Preview language

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.json

Copies 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

← All components