Input
A one-line text field: a name, an address, a number. It is the native input with the theme's border, focus ring and error state. For several lines use the textarea; for a fixed list of answers use the select.
Install
npx shadcn@latest add https://thrumui.dev/r/input.jsonAdds components/ui/input.tsx. Nothing else in your project changes.
import { Input } from "@/components/ui/input";Props
| Prop | Type | Default | Description |
|---|---|---|---|
type | string | Default "text" | The native input type: text, email, password, number, search, tel, url and the rest. |
aria-invalid | boolean | – | Marks the value as wrong: the border takes the destructive colour. Pair it with a message linked by aria-describedby. |
disabled | boolean | Default false | The native attribute: the field is dimmed and cannot be focused or edited. |
className | string | – | Extra classes, merged last. The field fills its container; set a width here. |
...props | ComponentProps<"input"> | – | Every other input attribute and event handler: value, defaultValue, onChange, name, autoComplete, placeholder. |
Motion and sound
Motion
- The border colour changes over 150 ms when the field becomes invalid or valid again.
- Reduced motion: the border changes at once.
Sound
Silent. This component makes no sound.
Accessibility
- It is a native input element. Its name comes from a label element linked with htmlFor and id: a placeholder is not a name.
- The focus ring is 2 pixels of the theme's ring colour, drawn over the border.
- An invalid field is marked with aria-invalid and its border changes colour. The message next to it carries the meaning, so colour is never the only sign.
- Text is 16 pixels on phones, so the page does not zoom when the field takes focus, and 14 pixels on wider screens.
- The border has 3 to 1 contrast against the page in both themes.
| Keys | Action |
|---|---|
| Tab | Focus the field. Typing, selection and editing keys are the browser's own. |
Source
"use client";
import type { ComponentProps } from "react";
import { cn } from "@/lib/utils";
export type InputProps = ComponentProps<"input">;
/**
* A one-line text field. It is a native `<input>`: give it a `<label>`, a `name`, the right `type` and `autoComplete`.
* Mark a wrong value with `aria-invalid` and the border says so.
*/
export function Input({ type = "text", className, ...props }: InputProps) {
return (
<input
data-slot="input" data-surface="control"
type={type}
className={cn(
// 16px text on phones: anything smaller makes iOS zoom the page when the field takes focus.
"h-8 w-full min-w-0 rounded-md border border-input bg-background px-2.5 text-base text-foreground placeholder:text-muted-foreground md:text-sm",
"transition-[border-color] duration-150 ease-out motion-reduce:transition-none",
"focus-visible:outline-2 focus-visible:-outline-offset-1 focus-visible:outline-ring",
"disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive",
className,
)}
{...props}
/>
);
}Files and dependencies
- Adds
components/ui/input.tsx- Packages
- None
- Brings along
- Nothing
Changelog
- 1.0.0 · 2026-12-03First release.