Text input whose floating label is thrown onto the rim, with async validation that sweeps the rim to success, a password reveal and strength meter, and errors that never shake.
Tab to focusTap to focus
Add member
They get an invite with a temporary password.
7 of 10 seats
text-field · , lively
text-field-demo.tsx
When to use
Use for any single-line text input. It has a floating label, helper and error text, prefix and suffix, password reveal and strength meter, character count. Presets: floating, stacked, search.
When not to use
For several lines use Textarea. For a long fixed list of choices use Combobox.
Use it for any single-line text input in a form: names, emails, URLs, search boxes, amounts with a
unit, passwords. It brings the label, helper text, error and success messages, prefix and suffix,
clear button, password reveal, strength meter and character counter that a bare input leaves to
you. For several lines of text use the textarea; for
a fixed list of choices use a select or combobox.
The field follows the MotionKit motion grammar in three beats. Pressing an empty field charges:
the surface sinks a little and the floating label's pill stretches up toward the top edge, while
the 2px ring rim is already lit (focus arrives on pointer down, so the focus indicator never
waits). On release the label is thrown onto the rim on a small spring, shrinking to 85% and
tinting toward ring. It settles with a squash against the rim instead of overshooting it,
then sits there as a capsule that cuts the lit line. Keyboard focus throws it at once; a field that
already shows its label on the rim (filled, or with a prefix) gets a small press in place. Errors
never shake: the destructive rim rises from the bottom edge and the message rises in under the
field. When an async check passes (valid), the success rim sweeps in from the left edge, the
way the value is read, a check is traced in the suffix and the message ("Available") rises in
where the helper was. In a form of twenty fields only the focused one moves. The stacked and search presets
have no floating label: their focus is the sink and the lit rim.
Async validation: pass loading while the check runs (spinner, aria-busy), then valid with a
message or error. The suffix keeps the check's room whenever valid is passed, so the text
never reflows.
<TextField label="Work email" type="email" required value={email} onValueChange={change} loading={status === "checking"} valid={status === "available" ? "Available: no member uses this address" : false} error={status === "taken" ? "Already a member of this workspace" : undefined}/>
Passwords get a show / hide eye on their own (revealable={false} turns it off). strength adds a
four-segment meter under the field that fills from the left, red, amber, then green; true uses
the exported scorePassword (length, mixed case, digit and symbol), or pass your own scorer
returning 0 to 4. strengthLabels renames the four levels.
required sets required and aria-required and draws the same 4px primary dot after the label
as FormLabel, so a field outside a Form looks the same as one inside. Inside FormField, use
preset="stacked" without a label and let FormLabel / FormMessage carry the text:
FormControl passes id, aria-describedby, aria-invalid and aria-required straight to the
input.
Three presets change the layout, not the look or the motion: floating (default, label inside the
field), stacked (label above, for dense forms) and search (leading icon, clear button, no
visible label, so pass aria-label). shortcut="/" focuses the field from anywhere on the page and
shows the key as a hint. size is sm, md or lg, loading swaps the suffix for a spinner and
sets aria-busy, and prefix / suffix take an icon or text. Every other prop goes to the native
<input>.
Set the character for the whole app with the provider, or per field with temperament:
It is a native <input>. The label is a real <label htmlFor>, also while floating, so clicking
it focuses the field. The search preset has no visible label: pass aria-label.
Description, error and success message are joined in aria-describedby; error sets
aria-invalid, required sets aria-required, loading sets aria-busy. The error and success
containers are aria-live="polite", so "Already a member" or "Available" is read without moving
focus. The success words stay foreground; only the icon and rim are success, so contrast never
depends on the green.
The password eye is a real, tabbable <button aria-label="Show password" aria-pressed> with
aria-controls on the input; pressing it keeps focus and the caret in the field.
The strength meter's segments and word are aria-hidden; a hidden live region says
"Strength: Fair" only when the level changes, never per keystroke. The required dot is
aria-hidden too (the input carries aria-required).
The counter is aria-hidden; a visually hidden live region announces it only when 10 characters
are left and at the limit, never per keystroke.
The pill's decorative layers, the spinner, icons and the shortcut hint are aria-hidden; the
label text is the label. The clear button is a real
<button aria-label="Clear"> with tabIndex={-1}, since Escape is the keyboard path.
Focus is always visible: the lit 2px rim is there the instant focus arrives (it never waits for the
label), plus a 3px ring/50 halo for keyboard focus (destructive/20 on an invalid field). In
forced-colors mode the rim is replaced by a Highlight outline.
Any press on the surface, the label or an adornment focuses the input.
Colors come from your theme: label and helper in muted-foreground, the lifted label in
foreground (never ring, which can be a mid grey), errors in destructive, so contrast follows
your shadcn theme in light and dark. The pill's 14% ring tint is decoration and never carries
text contrast.
The native placeholder shows only once the label pill has left the text line, so the two never
overlap.
With reduced motion (the OS setting, or MotionKitProvider reducedMotion="always") nothing
disappears; only the physics goes. The surface does not sink and the pill does not stretch or
squash: it glides to the top edge in the short fade time while its tint and the lit rim fade in.
The destructive and success rims, the messages, the check and the strength segments fade in, and the counter digits crossfade instead of
rolling. The finished picture (lit rim, tinted pill cutting it, error colors) is the same as in the
animated version.
The lit rim is one box-shadow transition on the surface: no SVG, no path, no measurement.
The label pill moves on transform only, three small spans driven by motion values, so React does
not re-render while it flies; its tint is one background-color transition.
The sink, the error and success rims, the strength segments and the messages use transform and
opacity. One ResizeObserver reads
the surface size, only to scale the sink to the field's shape.
The loading spinner pauses when the field is off screen or the tab is hidden.
Nothing is lazy-loaded. The only dependency besides React is motion.
Technical sheet
Motion
calm
260 ms · bounce 0
lively
400 ms · bounce 0.3
playful
540 ms · bounce 0.45
Main spring of each temperament. Set it with the temperament prop or MotionKitProvider; the default is lively.
Size
Not measured yet · budget 15.0 kB gzip
Component and MotionKit helpers; excludes react, react-dom, motion.
Dependencies
motion · peer
Triggers
keyboard focus, press, typing, an app event
Reduced motion
No sink, no stretch, no squash: the label pill glides to the rim in the 120ms fade while its tint and the 2px lit rim fade in; the error and success rims, messages, check and strength segments fade in, counter digits crossfade.
Keyboard
Tab / Shift + Tab
Focuses the field (the label pill is thrown onto the rim at once, the rim lights with the halo) and leaves it (the pill returns)
Escape
Clears the value when the field is clearable and not empty
Tab to the eye, Space / Enter
With `type="password"`, shows or hides the password (a pressed toggle; the caret stays put)
Shortcut key (e.g. /)
With `shortcut`, focuses the field from anywhere outside another text input
Typing, arrows, Home / End
Native input editing, untouched
Enter
Native form submit
Browsers
Last 2 versions of Chrome, Edge, Firefox and Safari (iOS 16.4+)