Skip to content

Glass Input for React

A glass text input for React with its label, description and error message wired up for screen readers, and a soft accent glow on focus.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/input.json

We only use it for receipts.

Label, description and icon

Press / to focus from anywhere.

Files to copy

4 folders · 2 files · 3 packages
From theme/src/
  • components/input/
  • components/spinner/
  • lib/{cn.ts, field-size.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/input.jsonRegistry item: input. The styles need the Tailwind v4 glass UI setup.
Packages
pnpm add @base-ui/react clsx tailwind-merge

Validation

Pass error to mark the field invalid; the message is linked to the input and announced.

Enter a valid email address.

Sizes

sm (32px), md (40px, default) and lg (48px): the same scale as Button, so a button beside an input lines up. On touch screens sm and md are 44px.

Props

PropTypeDefaultDescription
classNamestringNoneClass for the outer wrapper (label + field + messages), same as Select and Combobox.
onBlurFocusEventHandler<HTMLInputElement>NoneCalled when the field loses focus (native onBlur; also the point where a form library marks the field touched).
sizeFieldSize"md"Height and padding, the same scale as Button and every other field: "sm" 32px, "md" 40px, "lg" 48px (sm and md are 44px on touch screens).
labelReactNodeNoneText above the field, linked to the input as its accessible name.
descriptionReactNodeNoneMuted helper text under the field. Hidden while an error shows.
errorReactNodeNoneError message; marks the field invalid and is announced to screen readers.
leadingReactNodeNoneIcon or text shown inside the field, on the left.
trailingReactNodeNoneIcon, text or button shown inside the field, on the right.
loadingbooleanfalseShows a spinner at the field's trailing edge and sets aria-busy (a lookup or validation is running). The field stays editable.
namestringNoneField name for form submission and for matching an error from a form library.
readOnlybooleanfalseThe value can be selected and copied but not edited; the field stays focusable and is submitted with the form.
requiredbooleanfalseThe field must be filled before the form can be submitted.
autoCompletestring"email" for type="email"Autofill hint (the HTML autocomplete token, for example "email" or "one-time-code").
enterKeyHint"search" | "enter" | "done" | "go" | "next" | "previous" | "send""search" for type="search"Label of the on-screen keyboard's Enter key.
inputClassNamestringNoneAdds extra classes to the native <input> element.

Keyboard

KeysAction
Tab/Shift + TabMove focus to or from the input.
Type, select, pasteEverything the native input does works, including autofill and undo.

Accessibility

  • label, description and error are linked with aria-labelledby and aria-describedby; an error is announced politely.
  • Icons and affixes are decorative (aria-hidden); the input keeps its own name.
  • Text is 16 px on touch screens so iOS does not zoom on focus; the border keeps 3:1 contrast.

When to use Input

  • Use Input as a text input with label and error for single-line entry like email, password, search and names in a sign-in or checkout form, where a label and an error message must be tied to the field.
  • Use leading and trailing for a search box with a magnifier icon, or a password field with a show button inside the right edge of the field.
  • Use the error prop for server-side validation messages, which mark the field invalid with aria-invalid and are announced without moving focus.
  • Skip it when the text spans several lines or the value is a stepped number. Use Textarea for multi-line text, NumberField for a stepper, and OtpInput for a fixed-length code.
  • Pair it with Button for submit, its label, description and error props for the field text, and Select or Combobox in the same form, since all three share the className wrapper convention.

Frequently asked questions

67 components pages in all: browse them on All components.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .