Skip to content

Input

Terminal-styled text input primitives with size variants, invalid state, and optional prefix/suffix grouping.

Info:

Sizes sm and md are desktop densities (28/36px tall; the tap target spans the full row width and meets WCAG 2.5.8 AA). On coarse-pointer/mobile-first forms prefer size="lg" (44px).

Preview

Installation

$pnpm exec dgadd add ui/input
[Installs to]src/components/ui/input[Item]ui/input

dgadd is not public on npm yet. Until the first release, pack @diffgazer/add from the repository and install that tarball into this app, which is what puts dgadd on pnpm exec.

UI components require Tailwind CSS v4. Local copy mode imports src/styles/styles.css; package mode uses @diffgazer/ui CSS once packages are available.

Usage

tsx
import { Field } from "@/components/ui/field";import { Input } from "@/components/ui/input";export default function InputDefault() {  return (    <Field>      <Field.Label>Label</Field.Label>      <Field.Control>        <Input placeholder="Enter text..." />      </Field.Control>    </Field>  );}

Examples

Group

Preview

Variants

Preview

Focus

Preview

Form

Preview

API Reference

Input

NameTypeDefaultDescription
size"sm" | "md" | "lg""md"Height/padding/font size token.
aria-invalidboolean | "true" | "false" | "grammar" | "spelling"The native ARIA invalid state. The error border applies to true/"true"; the error ring joins on focus. Field.Control sets this automatically when Field.invalid is true.

InputGroup

NameTypeDefaultDescription
size"sm" | "md" | "lg""md"Height/padding/font size token applied to the wrapper and the inner input.
prefixReactNodeDecorative content rendered before the input. Plain text is aria-hidden; interactive affixes must provide their own accessible labels.
suffixReactNodeDecorative content rendered after the input. Plain text is aria-hidden; interactive affixes must provide their own accessible labels.
prefixAriaHiddenbooleantrue for string/number prefixes; false otherwiseHide the prefix from assistive tech. Controls whether the prefix wrapper is hidden from assistive technology and overrides the content-based default.
suffixAriaHiddenbooleantrue for string/number suffixes; false otherwiseHide the suffix from assistive tech. Controls whether the suffix wrapper is hidden from assistive technology and overrides the content-based default.
inputClassNamestringclassName applied to the inner input element. The outer className targets the wrapper.

Accessibility

Notes

Read-only vs Disabled

Input styles the two states on different channels so they cannot be confused. Disabled dashes the border and dims the ink: the field is not part of this form. Read-only fills the surface with the recessed token and keeps full-contrast ink: the value matters, it just cannot be edited. A read-only field stays focusable and copyable, and the focus ring still applies on top of the fill because one is an edge and the other a surface.

Invalid State

Set aria-invalid=true on Input or InputGroup to apply the error border. The error ring joins on focus, so focus stays the strongest edge a field shows. Field.Control sets aria-invalid automatically when Field.invalid is true.

InputGroup

Use InputGroup for prefix and suffix content around a text input. Plain text and number affixes are decorative by default; set prefixAriaHidden or suffixAriaHidden to false when that text contributes meaning. Non-text affixes remain exposed by default and can be hidden explicitly. Interactive affixes must remain exposed and provide their own accessible labels. Use Field when you need label, description, and error wiring.

Source

Install via CLI: pnpm exec dgadd add ui/input.

Highlighted source loads after this disclosure opens. Browse the source repository.