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.jsonWe only use it for receipts.
Input
Using it in a form? See the react-hook-form and zod recipe.
Label, description and icon
Press / to focus from anywhere.
import { Input } from "@/components/sheenui/input/input";
// Package build (after the first npm release, or a packed tarball): import { Input } from "@sheenui/theme";
import { Search as SearchIcon } from "lucide-react";
export function Example() {
return (
<Input
label="Search"
placeholder="Find components…"
description="Press / to focus from anywhere."
leading={<SearchIcon />}
/>
);
}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.
import { useState } from "react";
import { Input } from "@/components/sheenui/input/input";
// Package build (after the first npm release, or a packed tarball): import { Input } from "@sheenui/theme";
export function Example() {
const [email, setEmail] = useState("hello@");
const error = /^\S+@\S+\.\S+$/.test(email) ? undefined : "Enter a valid email address.";
return (
<Input label="Email" type="email" value={email} onChange={(e) => setEmail(e.target.value)} error={error} />
);
}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.
import { Input } from "@/components/sheenui/input/input";
// Package build (after the first npm release, or a packed tarball): import { Input } from "@sheenui/theme";
export function Example() {
return (
<div className="flex w-full max-w-sm flex-col gap-3">
<Input size="sm" placeholder="Small" aria-label="Small" />
<Input size="md" placeholder="Medium" aria-label="Medium" />
<Input size="lg" placeholder="Large" aria-label="Large" />
</div>
);
}Props
Keyboard
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
Related pages
67 components pages in all: browse them on All components.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .