Skip to content

Input

Collect a single line of text with clear focus and validation states.

import { Input } from '@youj/react'

Installation & usage

npm i @youj/react

For an app already set up with npx @youj/cli init, which installs the peers (@youj/core, @youj/motion, motion and Base UI) and wires the provider. New app? Start at Installation.

Use Input for short text such as a name, email address or URL. Choose a Textarea for multiple lines, an Input Group for a prefix, icon or button inside the field, or a Select for a known list of answers.

import { Field, FieldLabel, Input } from '@youj/react'

export function DisplayName() {
  return (
    <Field>
      <FieldLabel>Display name</FieldLabel>
      <Input name="displayName" autoComplete="name" />
    </Field>
  )
}

Inside a Field, the input is labeled, described and validated with no extra wiring, and it takes required from the Field. On its own, name it with aria-label or a Label.

Reference

PropsEvery native input attribute passes through, plus Base UI's…

Props

Input adds no props of its own. They pass through to InputPrimitive.Props.

Every native input attribute passes through, plus Base UI's onValueChange(value, details), which reports the new value as a string.

MotionHover and focus · reduced motion

Motion

Motion tokens
MomentTokens
Hover and focusborder color, fill and the focus halo
duration.fastease.standard

140ms · cubic-bezier(0.2, 0, 0, 1)

140mscubic-bezier(0.2, 0, 0, 1)

Reduced motion

There is nothing to reduce: the input only changes color, on the fast token.

Reduced motion

The input doesn't move. Its border, fill and halo change color on the fast token with or without reduced motion.

AccessibilityKeyboard, ARIA, focus

Accessibility

  • It's a native <input>. Give it a visible label through a Field, or an aria-label when the context names it, like a search box.
  • Focus shows as an accent border and halo. A transparent outline rides along, so Windows high-contrast mode still draws a focus indicator.
  • Text is 13px, and 16px on touch screens, so iOS doesn't zoom the page when the input takes focus.
  • Pick the right type, inputMode and autoComplete. They choose the on-screen keyboard and let browsers and password managers fill the field.