// Accessible labelled input with error and hint state. import { cn } from "../../lib/utils"; export interface InputProps extends React.InputHTMLAttributes { /** Visible label text — also used to derive the `htmlFor` id */ label: string; /** Validation error message — sets aria-invalid and renders red helper text */ error?: string; /** Neutral helper / hint text shown below the input */ hint?: string; /** Optional right-side icon node */ icon?: React.ReactNode; } /** * @example * * * */ export function Input({ label, error, hint, id, icon, className, ...rest }: InputProps) { const inputId = id ?? `input-${label.toLowerCase().replace(/\s+/g, "-")}`; const errorId = `${inputId}-error`; const hintId = `${inputId}-hint`; return (
{icon && ( )}
{error && ( )} {hint && !error && (

{hint}

)}
); }