a11ypros

A11y Label

Forms

About

An accessible form label that pairs with any input via htmlFor and shows an aria-hidden required-field asterisk, built to WCAG 1.3.1 and 2.5.3. Ported to React from A11Y Pros' a11y-ui web-component library (the project's own React Label, kept byte-faithful); credit to Ryan Mack / A11YPros.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds A11y Label to your project and fits it to your theme.

Code

How A11y Label is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

import Label from "@/components/ui/a11y-label";

export default function LabelDemo() {
  return (
    <div className="flex w-full max-w-sm flex-col gap-5 p-6">
      <div className="flex flex-col gap-1.5">
        <Label htmlFor="email" required>
          Email address
        </Label>
        <input
          id="email"
          type="email"
          required
          placeholder="you@example.com"
          className="rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm text-neutral-900 placeholder:text-neutral-400 focus:outline-none focus:ring-2 focus:ring-sky-500"
        />
      </div>
      <div className="flex flex-col gap-1.5">
        <Label htmlFor="full-name">Full name</Label>
        <input
          id="full-name"
          type="text"
          placeholder="Taylor Morgan"
          className="rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm text-neutral-900 placeholder:text-neutral-400 focus:outline-none focus:ring-2 focus:ring-sky-500"
        />
      </div>
    </div>
  );
}

More by a11ypros

View all
  • Accessible Tooltip

    Accessible Tooltip

    1
  • Accessible Accordion

    Accessible Accordion

    1
  • Accessible Radio Group

    Accessible Radio Group

More in Forms

View all
  • Premium Auth

    Premium Auth

    497
  • Login 2

    Login 2

    7
  • Authentication Card

    Authentication Card

    45
  • Login 1

    Login 1

    52
  • Contact Card

    Contact Card

    1K
  • Form

    Form

    16
  • Form

    Form

    136
  • Card Studio

    Card Studio

    41