Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Forms

Input

Free12.7 KB gzipped

A single-line text field built on the native <input>. Supports every text-like type (text, email, url, tel, number, search, password, date, ...), addons, decorative icons, interactive slots, a clear button, and a loading state.

Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Tab · Full report

Import

tsx
import { Input } from "@vjdesigns/vjdesigns-ui";

Importing only Input adds about 12.7 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.

Examples

Basic

Wrap inputs in a Field for a label, hint and error message.

We'll send the receipt here.

tsx
import {
  Field,
  Input,
  MailIcon,
  SearchIcon,
  Stack,
} from "@vjdesigns/vjdesigns-ui";

export function Basic() {
  return (
    <Stack gap={5} style={{ width: "100%", maxWidth: "22rem" }}>
      <Field label="Email" hint="We'll send the receipt here.">
        <Input type="email" placeholder="you@example.com" startIcon={<MailIcon />} />
      </Field>
      <Field label="Search">
        <Input type="search" startIcon={<SearchIcon />} clearable defaultValue="Card components" />
      </Field>
    </Stack>
  );
}

Addons and elements

Addons attach static text to an edge; elements put interactive controls inside it.

$USD
tsx
import { useState } from "react";
import {
  Field,
  IconButton,
  Input,
  Stack,
  CopyIcon,
} from "@vjdesigns/vjdesigns-ui";

export function AddonsAndElements() {
  const [link] = useState("https://dhui.dev/invite/7Hq2");
  return (
    <Stack gap={5} style={{ width: "100%", maxWidth: "22rem" }}>
      <Field label="Price">
        <Input inputMode="decimal" startAddon="
quot;
endAddon="USD" defaultValue="49.00" />
</Field> <Field label="Invite link"> <Input readOnly value={link} endElement={ <IconButton aria-label="Copy link" size="xs" variant="ghost" tone="neutral" onClick={() => navigator.clipboard.writeText(link)}> <CopyIcon /> </IconButton> } /> </Field> </Stack> ); }

Sizes and variants

tsx
import { Input, Stack } from "@vjdesigns/vjdesigns-ui";

export function SizesAndVariants() {
  return (
    <Stack gap={3} style={{ width: "100%", maxWidth: "22rem" }}>
      <Input aria-label="Small" size="sm" placeholder="Small" />
      <Input aria-label="Medium" placeholder="Medium (default)" />
      <Input aria-label="Large" size="lg" placeholder="Large" />
      <Input aria-label="Filled" variant="filled" placeholder="Filled variant" />
    </Stack>
  );
}

States

That username is taken.

tsx
import { Field, Input, Stack } from "@vjdesigns/vjdesigns-ui";

export function States() {
  return (
    <Stack gap={5} style={{ width: "100%", maxWidth: "22rem" }}>
      <Field label="Disabled" disabled>
        <Input defaultValue="Can't change this" />
      </Field>
      <Field label="Username" error="That username is taken.">
        <Input defaultValue="jordan" />
      </Field>
      <Field label="Checking availability">
        <Input defaultValue="jordan.lee" loading />
      </Field>
    </Stack>
  );
}

Accessibility

Every input needs a visible label. Field connects the label, hint and error to the input (aria-labelledby, aria-describedby, aria-invalid), the right autoComplete lets browsers and password managers fill it, and the clear button is named by clearLabel.

We send the invoice here.

Enter an email like name@company.com.

tsx
import { useState } from "react";
import { Field, Input, MailIcon } from "@vjdesigns/vjdesigns-ui";

export function Accessibility() {
  const [email, setEmail] = useState("ana@example");
  const invalid = !/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(email);
  return (
    <div style={{ width: "100%", maxWidth: "22rem" }}>
      <Field
        label="Work email"
        hint="We send the invoice here."
        error={invalid ? "Enter an email like name@company.com." : undefined}
        required
      >
        <Input
          type="email"
          autoComplete="email"
          value={email}
          onValueChange={setEmail}
          startIcon={<MailIcon />}
          clearable
          clearLabel="Clear email"
          fullWidth
        />
      </Field>
    </div>
  );
}

Translated

Inside a LocaleProvider, the input's built-in words, like the clear button's name, come from the locale (German here). The label and value are your own text, so you translate those yourself.

Mindestens drei Zeichen.

tsx
import {
  Field,
  Input,
  SearchIcon,
  LocaleProvider,
} from "@vjdesigns/vjdesigns-ui";
import de from "@vjdesigns/vjdesigns-ui/locales/de";

export function Translated() {
  return (
    <LocaleProvider locale="de" messages={de}>
      <div style={{ width: "100%", maxWidth: "22rem" }}>
        <Field label="Suche" hint="Mindestens drei Zeichen.">
          <Input defaultValue="Wanderschuhe" startIcon={<SearchIcon />} clearable fullWidth />
        </Field>
      </div>
    </LocaleProvider>
  );
}

Right to left

The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.

Basic

We'll send the receipt here.

tsx
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";

// Basic is the "Basic" example above.
<LocaleProvider locale="ar" messages={ar}>
  <Basic />
</LocaleProvider>

Usage notes

Works controlled (value + onChange/onValueChange) or uncontrolled (defaultValue). Inside a Field, the id, description, invalid, required, disabled, read-only, and size are wired automatically.

ref points at the <input>; className styles the wrapper and inputClassName the input itself.

tsx
<label htmlFor="team">Team name</label>
<Input id="team" placeholder="The Villains" clearable onValueChange={setName} />

API reference

Input

Input props
PropTypeDefault
size

Control height, padding, and type size. Inherits from a surrounding Field when not set.

"sm""md""lg""md"
variant

Visual style.

"outline""filled""outline"
radius

Corner rounding. When omitted, uses --field-radius. Use pill for search bars.

"none""xs""sm""md""lg""xl""2xl""pill"—
invalid

Marks the value as invalid: sets aria-invalid and a danger border. Pair it with a visible error message (a Field does this for you). Inherits from a surrounding Field.

booleanfalse
startIcon

Decorative icon before the text. Hidden from assistive technology.

ReactNode—
endIcon

Decorative icon after the text. Hidden from assistive technology.

ReactNode—
startAddon

Static content attached to the start edge, such as "https://" or a currency symbol. Text addons are announced as part of the input's description (aria-describedby).

ReactNode—
endAddon

Static content attached to the end edge, such as ".com" or a unit ("kg"). Text addons are announced as part of the input's description.

ReactNode—
startElement

Interactive content inside the start edge (for example an IconButton with size="sm" and variant="ghost"). Stays in the tab order; give it its own accessible name.

ReactNode—
endElement

Interactive content inside the end edge (for example a copy or show-password IconButton). Stays in the tab order; give it its own accessible name.

ReactNode—
clearable

Shows a clear button (aria-label="Clear") while the input has a value. Clearing fires a native-like change (so onChange runs), calls onValueChange(""), and moves focus back to the input. Hidden while disabled or read-only.

booleanfalse
clearLabel

Accessible name of the clear button.

string"Clear"
onClear

Called after the clear button empties the field (after onChange/onValueChange).

() => void—
loading

Shows a decorative spinner at the end and sets aria-busy on the input. Announce the outcome of the async work elsewhere (e.g. a status message).

booleanfalse
fullWidth

Stretches the field to fill its container.

booleantrue
htmlSize

The native size attribute (visible width in characters). Mostly useful with fullWidth={false}.

number—
onValueChange

Called with the new value on every change (typing, pasting, clearing).

(value: string) => void—
inputClassName

Class name for the <input> element. className goes to the wrapper.

string—
ref

Ref to the <input> element.

Ref<HTMLInputElement>—

Also accepts native <input> attributes, plus className, style and ref.

See what changed in each version in the Changelog.

Accessibility report

Input targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.

axe-core audit (live)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

37 passed · 0 failed · 28 not applicable · 10 to check by hand

Dark mode

Score 100

37 passed · 0 failed · 28 not applicable · 10 to check by hand

Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.

Built-in behavior

Keyboard

Keyboard
KeyAction
TabMoves focus into the field.
TypingEdits the text, with the browser's usual caret and selection keys.

Roles and states

Roles and states
ElementRoleStates and properties
<input>textbox (searchbox for type="search")aria-invalid, aria-describedby → hint and error, aria-busy while loading
Clear buttonbuttonaria-label, aria-controls → input

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck.2.1.1 (A), 2.1.2 (A)
FocusFocus moves in a logical order, is always visible, and isn't hidden behind sticky headers.2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA)
Screen readersNames, roles and states are announced correctly, and status changes are announced without moving focus.1.3.1 (A), 4.1.2 (A), 4.1.3 (AA)
ColorMeaning never depends on color alone; your own colors meet contrast in both modes.1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA)
Zoom and reflowAt 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed.1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA)
Pointer targetsClick and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap.2.5.8 (AA), 2.5.5 (AAA)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)