Input

Alpha

An accessible text input with built-in label, hint text, error handling, and aria attributes.

Import

import { Input } from "@compa11y/react";

Usage

Example.tsx
import { Input } from "@compa11y/react";

function Example() {
  return (
    <div style={{ display: "flex", flexDirection: "column", gap: "16px" }}>
      <Input label="Email" type="email" hint="We'll never share your email." />
      <Input label="Password" type="password" required />
      <Input label="Username" error="Username is already taken" />
    </div>
  );
}

Features

  • Automatic label-input association
  • Hint text support
  • Error state with aria-invalid and aria-describedby
  • Required field indicator
  • Compound component API for custom layouts
  • CSS variable customization

Props

Input component props
PropTypeDefaultDescription
label*string-Label text for the input
hintstring-Help text shown below the label
errorstring-Error message (sets aria-invalid)
valuestring-Controlled input value
onValueChange(value: string) => void-Called when value changes
typestring'text'Input type attribute
requiredbooleanfalseMarks as required
disabledbooleanfalseDisables the input

Keyboard Interactions

Accessibility
All keyboard interactions follow WAI-ARIA best practices and work without any additional configuration.
Keyboard shortcuts for Input
KeyAction
TabFocuses the input