Input with a spring-animated caret.
npx shadcn@latest add @iconiq/input"use client";
import { useState } from "react";
import { Input } from "@/components/ui/input";
export function InputPreview() {
const [value, setValue] = useState("");
return (
<div className="flex w-full items-center justify-center px-4 py-6">
<div className="flex w-full max-w-sm flex-col gap-2.5">
<Input
description="We only use this for account notifications."
label="Work email"
onValueChange={setValue}
placeholder="name@company.com"
showClear
value={value}
/>
<p className="text-pretty text-left text-[13px] text-muted-foreground leading-snug tracking-tight sm:text-sm">
Type to watch the spring caret follow each keystroke.
</p>
</div>
</div>
);
}valueControlled input value. Pair with `onValueChange` or `onChange` when the parent owns the text.
Type string
defaultValueInitial value for uncontrolled usage.
Type string
onValueChangeBase UI change handler with the next string value and event metadata. Preferred for controlled forms.
Type (value: string, eventDetails: InputChangeEventDetails) => void
onChangeNative change handler fired after typing, paste, cut, or autofill.
Type React.ChangeEventHandler<HTMLInputElement>
typeNative input type. Smooth caret is enabled for text-like types only (`text`, `search`, `url`, `email`, `password`, `tel`).
Type React.HTMLInputTypeAttribute·Default text
labelOptional field label rendered above the control with an associated `htmlFor` id.
Type React.ReactNode
labelClassNameClasses merged onto the optional label element.
Type string
descriptionOptional helper text rendered below the input shell and linked with `aria-describedby`.
Type React.ReactNode
descriptionClassNameClasses merged onto the description element.
Type string
errorMessageValidation message rendered below the field. Also sets `aria-invalid` and links through `aria-describedby`.
Type React.ReactNode
errorMessageClassNameClasses merged onto the error message element.
Type string
invalidApplies destructive shell styling and forwards `aria-invalid` to the native input.
Type boolean·Default false
requiredForwards native required validation and appends a visual asterisk to the label.
Type boolean·Default false
sizeControls the input shell height.
Type "sm" | "default"·Default default
shellClassNameClasses merged onto the bordered input shell.
Type string
wrapperClassNameClasses merged onto the outer field wrapper when `label`, `description`, or `errorMessage` is set. Otherwise merged onto the shell.
Type string
startAdornmentOptional leading slot rendered inside the input shell.
Type React.ReactNode
endAdornmentOptional trailing slot rendered inside the input shell after built-in actions.
Type React.ReactNode
childrenAdditional trailing content rendered inside the input shell after adornments and actions.
Type React.ReactNode
showClearWhen true, renders a clear button while the field has a value and is not disabled or read-only.
Type boolean·Default false
showPasswordToggleWhen `type="password"`, shows a visibility toggle by default. Pass `false` to hide it.
Type boolean
placeholderPlaceholder shown when the field is empty.
Type string
fontSizeOptional pixel font size override for the inner field. Defaults to the standard `text-sm` input sizing.
Type number
springSpring config for caret movement. Defaults to stiffness 500, damping 30, mass 0.5.
Type { stiffness?: number; damping?: number; mass?: number }
idOptional id forwarded to the input. A generated id is used when omitted so labels stay associated.
Type string
classNameClasses merged onto the native input element. Base UI also supports a state callback.
Type string | ((state: InputState) => string)
styleInline styles merged onto the native input element. Base UI also supports a state callback.
Type React.CSSProperties | ((state: InputState) => React.CSSProperties)
renderBase UI render override for the native input element. Custom renders disable the smooth caret.
Type React.ReactElement | ((props: React.ComponentProps<'input'>) => React.ReactElement)
disabledDisables interaction on the native input.
Type boolean·Default false
readOnlyKeeps the field focusable while applying muted shell styling and blocking edits.
Type boolean·Default false
Install the exact registry entry shown on the right when you want the component file and its declared runtime dependencies together.
Dependencies: @base-ui/react/input, motion.
This page documents the Base UI install only. Input uses the Base UI Input primitive for value handling and Field integration.
The generated registry file is /r/input.json.
Contact
Additionally, if you find any bug or issue, feel free to raise an issue.