Skip to content

Components / Input

Input

A square, monospaced native input. Collect a value with a clear label, keep keyboard focus visible, and explain what needs correcting.

Storybook runs locally or as a separately hosted build; no hosted Storybook is configured. Source and setup links match the install revision.

Usage playground

Edit a labeled email field. Change its availability or inspect an explicit invalid state; Input itself does not validate or manage values.

React / TSX
'use client';

import { useId, useState } from 'react';
import { Input } from "@/components/ui/yads-input";
import { Label } from "@/components/ui/yads-label";

Installation

pnpm dlx [email protected] add biehlio/yet-another-design-system/input#e7b31d0e0c9d8b24d53e97ca38b3b68d345e9f40

Documentation samples use basic Tailwind utilities for layout. Install each YADS component imported by the sample.

Run this revision-pinned command in a project configured for shadcn. It installs yads-input, its scoped stylesheet and JetBrains Mono. Import { Input } from @/components/ui/yads-input (adjust the alias to your project). No global CSS, Tailwind utilities, theme install or form library is required.

Copy sample includes the complete consumer module and any recipe CSS, even when collapsed. Interactive examples include a client boundary for React Server Component apps. These examples compose the separately installed YADS Label and, for form actions, Button. Input itself does not depend on other primitives.

Helper text and errors

Connect help and errors with aria-describedby. This controlled example starts invalid and uses native email validity as you type; your application decides when to show feedback.

We only use this to reply to your message.

Enter a valid email address.

React / TSX
'use client';

import { useId, useState } from 'react';
import { Input } from "@/components/ui/yads-input";
import { Label } from "@/components/ui/yads-label";

Native form submission

Uncontrolled defaultValue, required validation, Enter to submit and native reset. A name includes the value in FormData. This local demo reports a result without sending a request.

React / TSX
'use client';

import { useId, useState } from 'react';
import { Input } from "@/components/ui/yads-input";
import { Label } from "@/components/ui/yads-label";

className customization

Use ordinary CSS with enough specificity. This border recipe keeps the scoped colors, invalid border and keyboard focus ring. Inline style also passes through. The copied module includes the CSS.

React / TSX
'use client';

import { useId } from 'react';
import { Input } from "@/components/ui/yads-input";
import { Label } from "@/components/ui/yads-label";

Accessibility

  • Give every field a name. Prefer a visible native label with htmlFor matching a unique input id. Use React useId when a field is rendered repeatedly. A placeholder is not a label.
  • Explain requirements and errors. Mark required fields visibly and with required. Connect helper and error IDs using aria-describedby; set aria-invalid="true" when you show an error. Include text rather than relying on color. The browser validates native constraints; Input does not manage feedback, focus or validation timing.
  • Preserve keyboard access. Tab focuses editable and read-only fields; the visible focus ring remains in both themes. Disabled fields are skipped and omitted from submission. Use readOnly when a value must remain selectable and submitted. Explain unavailable fields nearby.
  • Use native form semantics. Set name, a suitable type and autoComplete. Enter submits a valid form with a submit button; native constraints can prevent submission. For server failures, retain the entered value and connect an actionable error.

Light is standalone by default. A containing className="dark" opts into scoped dark colors without a theme provider or global variables.

API reference

Import { Input, type InputProps } from @/components/ui/yads-input. InputProps is React.InputHTMLAttributes<HTMLInputElement>; there are no custom variants or form-library dependencies. It renders one native input and forwards its ref.

On narrow screens, focus the table and scroll horizontally to read all columns.

Input props, types, defaults and behavior
PropTypeDefaultDescription
typeHTMLInputTypeAttributeBrowser default: textNative input type. Examples use email; this primitive adds no type-specific widgets.
id / namestringNot setUse id with label htmlFor; name includes the value in native form submission. No IDs or labels are generated.
value / onChangeNative value / ChangeEventHandler<HTMLInputElement>Not setControlled usage: supply value and update it synchronously in onChange. Do not switch between controlled and uncontrolled.
defaultValueNative input valueNot setInitial value for uncontrolled usage; browser reset restores it. Do not combine with value.
disabledbooleanfalseNative: not editable, skipped by Tab and excluded from FormData.
readOnlybooleanfalseNative: not editable, still focusable, selectable and submitted. Dashed border distinguishes it.
requiredbooleanfalseUses browser constraint validation. Input does not generate messages or aria-invalid.
aria-invalidNative ARIA valueNot settrue adds error styling; connect explanatory text with aria-describedby. Does not block submission by itself.
className / stylestring / CSSPropertiesNot setAdds a class or inline styles to the input, without replacing the scoped class.
refReact.Ref<HTMLInputElement>Not setForwarded to the actual input for focus, selection and native validity methods.

Native attributes and events

Native attributes including placeholder, autoComplete, inputMode, pattern, minLength, maxLength, form, aria-*, data-* and event handlers are forwarded unchanged. No type, value, ID, validation, or label is supplied automatically. Styles are designed for text-like inputs, not as a substitute for dedicated controls such as checkboxes, radios or file pickers.

Playground defaults

Reset restores an editable controlled email field containing “[email protected]”. The state menu is a documentation control, not an Input prop. The explicit invalid preview only demonstrates error presentation, not a validation algorithm.