← Gallery
Input
UI primitiveinputSingle-line text entry: a name, an email, an amount, a search term.
Live preview
Single-line text entry: a name, an email, an amount, a search term. Pair it with a visible label;
multi-line text uses Textarea.
Live examples
Label above, placeholder
Invalid
Add the part after the dot, like .com.
Disabled
Anatomy
- Label — a separate
Labelabove the field, linked withhtmlFor/id. - Field — the
<input>. - Help or error text — a separate element below, linked with
aria-describedby.
From the code
- Tokens consumed
destructiveforegroundinputinput-backgroundmuted-foregroundprimaryprimary-foregroundring- Radius
- the skin's
rounded-md, or--ss-field-radiuswhen the project sets it (ss-pattern-field) - Focus
- focus-visible:border-ring · focus-visible:ring-[3px] · focus-visible:ring-ring/50
- Motion
- transition-[color,box-shadow]
States
| State | Looks | Note |
|---|---|---|
| Default | input-background fill, input border. | — |
| Placeholder | muted-foreground text. | An example, never the label. |
| Focus | Border in ring, 3px ring at 50%. | focus-visible. |
| Invalid | Border in destructive, ring in destructive at 20%. | Set aria-invalid and show the message below the field. |
| Disabled | 50% opacity, not-allowed cursor. | — |
Do
- Put the label above the field (DESIGN-LANGUAGE §44).
- Validate on blur, and for Korean, Japanese or Chinese input only after
compositionend(DESIGN-LANGUAGE §44). - Say what happened and how to fix it next to the field (UX-WRITING WE-1, WE-2).
- Keep 16px text on phones so iOS does not zoom on focus; the component does this below the
mdbreakpoint.
Don't
- Don't use the placeholder as the label.
- Don't validate while the user is still typing.
- Don't put inputs inside consumer-service cards; use a separate page or bottom sheet (DESIGN-LANGUAGE §44, consumer-service scope).
Known gaps
- DESIGN-LANGUAGE §44 specifies a 48px field (
h-12),rounded-xl, a transparent border and a brand-coloured focus ring. The code is the brand recipe's control height, or the project's recorded default height, 40px at:root(h-[var(--ss-control-height,40px)]),rounded-md, aninputborder and aring-coloured focus ring. The two disagree; the code is what ships until the designer decides (#96). - At the
:rootcontrol height the input is 40px, under the 44px touch minimum (DESIGN-LANGUAGE §41); its height follows--ss-control-height. - The radius is the skin's
rounded-md(or--ss-field-radius), not the recipe control radius used by Button and Tabs; a button and a field side by side can have different corners.recipes.cssstays outside cascade layers and Tailwind's utilities inside one, as@import "tailwindcss"gives. Once a project sets--ss-field-radius, a caller'srounded-*class no longer changes the corner; set[--ss-field-radius:…]on the element instead. A value that is not a length gives a square field.
Machine checks
- Height under the 44px touch minimum (DESIGN-LANGUAGE §41) at the
:rootcontrol height (40px):input40px. On touch surfaces, extend the hit area or use a taller size. - Radius is the skin's
rounded-md(or--ss-field-radius), not the recipe control radius used by Button and Tabs; a button and a field side by side can have different corners.
Sources: DESIGN-LANGUAGE §44 Input & form rules; §41 Touch targets · UX-WRITING §W2 Errors (WE-1, WE-2) · CRAFT-BASELINE: control heights (rule CRAFT-control-heights)
Size
1.0 KB
Exports
1
Imports
2
Type
ui
Exports
InputImports
- react
- ./utils
Source
View on GitHub →import * as React from "react";
import { cn } from "./utils";
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
return (
<input
type={type}
data-slot="input"
className={cn(
"file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-[var(--ss-control-height,40px)] w-full min-w-0 rounded-md ss-pattern-field border px-3 py-1 text-base bg-input-background transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
className,
)}
{...props}
/>
);
}
export { Input };