UI.MD

Input

A text input field with optional start/end icon decoration and an interactive in-field action slot.

Installation

$
npx shadcn@latest add https://ui.mattdowney.com/r/input.json

Usage

import { Input } from "@/components/ui/input"

Examples

Default

The plain field. It is full-width, so give it a width or a cap (max-w-xs here) or it takes whatever its container happens to be.

Sizes

Heights are 24/28/32/40, the same ramp and the same names as Button, so the same size on a field and the button beside it gives one height and one corner radius. The pair at the bottom is the case this exists for: a field and its submit, stacked at the same width.

With Icons

iconStart and iconEnd render decorative, non-interactive icons inside the field. Same two forms as Button: an element (<Search />) or a bare component (Search).

With Action

actionEnd renders an interactive control inside the field: a copy, clear, or reveal-password button. Pass an icon-sm Button.

API Reference

PropTypeDefaultDescription
variant"default" | "ghost""default"default is the bordered form field. ghost is borderless and transparent with no forced height or font-size and minimal focus, for title composers and inline-edit fields; size it via className.
size"xs" | "sm" | "default" | "lg""default"Control height (24/28/32/40), using Button's size names so the same size on a field and the button beside it gives the same height and the same corner radius. Height, side padding, and radius move together. Ignored by ghost, which has no chrome. Note that this replaces the native HTML size attribute, which sets character width and is superseded by className="w-*".
iconStartTablerIcon | ReactNode-Decorative, non-interactive icon rendered at the leading edge of the field. Prefer an element (<Search />); a bare component (Search) still works but cannot be passed from a Server Component.
iconEndTablerIcon | ReactNode-Decorative, non-interactive icon rendered at the trailing edge of the field. Prefer an element (<Mail />); a bare component still works but cannot be passed from a Server Component.
actionEndReact.ReactNode-Interactive element rendered inside the field at the trailing edge: a copy, clear, or reveal-password button. Pass an icon-sm Button.
classNamestring-Applied to the input itself, or to the wrapper div when any icon/action adornment is present.