Fixed-format input for phone, IBAN, VAT and card numbers: the caret is a ball thrown group to group and a wrong character is refused with a kick.
TypeType
Where monthly payouts are sent.
masked-input, lively
Use it for identifiers with a fixed shape: phone numbers, IBANs, VAT numbers, card numbers, EAN barcodes, SKUs, tax ids and tracking numbers on contact, invoice, product and payout screens. The format is drawn in the field, so people see how long the value is and where they are in it. For one-time codes of 4 to 8 characters use the OTP Input; for free text use the Text Field.
The moment: the format is drawn as hollow pills, one per group, with muted ghost glyphs. The caret
is an 8 px primary ball. Typing fills a group glyph by glyph while its tint grows from the left;
when the group completes, its pill sets down and the ball is thrown to the next group, where it
kisses the wall and settles. Between two typed glyphs the ball squeezes into a thin bar. A
character that does not fit (a letter in a digit group) is refused: the ball kicks against the
wall it rests on and the value does not change. Nothing shakes and nothing turns red. A complete,
valid value sweeps the rim to success from the left and a check traces in the trailing slot.
As soon as the prefix says something, a chip is put in the trailing slot: the card network
(VISA, MC, AMEX, DISC) for card, the country flag for iban. A paste, autofill or a
value set from outside lands glyph by glyph, and each group sets down as its last glyph lands.
pnpm dlx shadcn@latest add @motionkit-pro/masked-inputnpx shadcn@latest add @motionkit-pro/masked-inputyarn dlx shadcn@latest add @motionkit-pro/masked-inputbunx --bun shadcn@latest add @motionkit-pro/masked-inputRequires a Signature license and the @motionkit-pro registry with your token. See Installation.
import { MaskedInput } from "@/components/ui/masked-input"
export function PayoutIban() {
const [iban, setIban] = useState("")
return <MaskedInput mask="iban" label="IBAN" copyable value={iban} onValueChange={setIban} />
}mask takes a preset or a pattern. Presets: phone (pattern by dialling code), iban (length
by country, mod-97 check), vat (pattern by country), card (Amex by prefix, Luhn check),
ean (EAN-13 check digit) and sku. A pattern uses 0 for a digit, A for a letter, * for a
letter or digit and # for any character; everything else is a literal drawn between groups:
<MaskedInput mask="AAA-0000-00" aria-label="SKU" />
<MaskedInput mask="iban" countries={{ SM: "AA00 A000 0000 0000 0000 0000 000" }} label="IBAN" />value and onValueChange use the raw characters (unmask, on by default);
onValueChange(raw, { formatted, complete, valid }) also gives the formatted text.
cardNetwork(raw) ("Visa", "Mastercard") is exported for your own summaries. With name,
a hidden input submits the raw value. validate(raw) replaces the preset's checksum and returns
true, false or a message; it may return a promise (a spinner shows in the trailing slot; pass
a stable function). transform="upper" is the default for IBAN, VAT and SKU.
description is helper text under the field (an example, where to find the value); it steps aside
while the error or validMessage takes its line. validMessage ("Checksum verified") shows
under the field and is announced while the value is complete and valid, as in the
Text Field. required adds the 4 px primary dot after the label.
detect (on by default for card and iban; its room is reserved, so the glyphs never move) can
be turned off with detect={false}.
The preset picks the layout: field (groups inside one field, the default), segmented (one
field with tinted group pills and wider gaps, label above, like a card form) and cell (a table cell with
glyphs and the ball only, no pills, no kick). size is sm, md or lg. Set the motion
character with temperament (calm, lively, playful) or the app-wide MotionKitProvider;
at calm the ball glides without kiss or kick, the fill and the success sweep still play.
Prop
Type
Also accepts all props of NativeInputProps.
TypeType
Team plan, renews on the 1st of each month.
masked-input, lively
The network chip appears with the first digit; the summary under the form reads the same prefix
with cardNetwork(raw) and adds the last four digits once the Luhn check passes.
preset="segmented" keeps one field and one rim; each group is a tinted pill with a wider gap,
and the ball is thrown across the gaps. When a long value is too wide for the field (an IBAN at
320 px), the groups wrap to a second row inside the field, and the ball crosses rows by a
crossfade, never by flying over the wrap.
TypeType
Click a SKU to edit it.
| Product | SKU | Stock |
|---|---|---|
| Desk lamp, brass | 42 | |
| Oak shelf, 80 cm | 7 | |
| Wool throw, sand | 0 |
masked-input, lively
preset="cell" drops the pills and the field surface so the input sits in a dense table row; the
ball moves on the calm spring and never kicks.
<input type="text"> carries the value, the label (label renders a <label>; use
aria-label in cell), aria-describedby with an sr-only format hint ("Format: +00 000 000
0000") and the error message, aria-invalid, aria-busy while an async check runs, the
derived inputMode (tel, numeric for digit-only masks, text) and autocomplete (tel,
cc-number, off).aria-hidden; the
native text, caret and selection are transparent but present, so screen readers, autofill,
password managers and IMEs work on the real field.detect found ("Visa", "Portugal"); the chip itself is
aria-hidden. description and validMessage are linked by aria-describedby; the
required dot is aria-hidden and the input carries aria-required. The copy button announces
"Copied".muted-foreground (AA on background), typed glyphs
foreground. Focus is the 2 px ring rim plus the 3 px halo for keyboard focus (a press on the
field or its label shows the rim alone); forced-colors gets a Highlight outline. Error: a
destructive rim rising from the bottom edge and a message under the field. The hit area is the
whole field; the copy button is 24 px.success is shipped in the item's cssVars for light and dark.| Key | Action |
|---|---|
| Allowed character | Fills the next slot; a complete group throws the caret ball to the next group |
| Wrong character | Refused: the ball kicks against its wall, the value does not change |
| Backspace | Deletes the previous character, across separators (the ball goes back one group) |
| Delete | Deletes the next character, across separators |
| Arrow Left/Right | Moves one character, stepping over separators |
| Home / End | Jumps to the start or the end of the value |
| Shift + arrows | Selects characters (drawn as a primary pill over the glyphs) |
| Mod + V | Pastes: spaces and separators stripped, letters uppercased; a wrong character refuses it all |
| Tab / Shift + Tab | Moves to the copy button and out of the field |
A double click selects the group under the pointer. On touch, the caret lands on the drawn glyph you tap.
With reduced motion (the OS setting, or MotionKitProvider reducedMotion="always") the ball still
moves to the caret, gliding in the short fade time without kiss, kick or squeeze stretch. Group
tints deepen in place instead of growing from the left, typed glyphs fade in without rising, the
success and error rims fade in and the check appears without tracing. A paste lands at once
(no glyph cascade) and the detection chip fades in without the pop. Every state is a complete
picture at rest.
ball, beats,
field-label, the copy button). Peer, not counted: motion.ResizeObserver), never per
frame. The caret position is read once per input or selection event.transform and opacity only. The validation
spinner pauses off screen and in hidden tabs.field, long masks shrink their glyphs with a container query (down to 10 px) to stay on
one line; when even 10 px does not fit (a 25-character IBAN at 320 px), the glyphs keep their
size and the groups wrap to a second row inside the field, never clipped.validate reserves the line of its error message, so the message
appears on blur without moving the rows below. Typing never turns the field red.Main spring of each temperament. Set it with the temperament prop or MotionKitProvider; the default is lively.
Not measured yet · budget 15.9 kB gzip
Component and MotionKit helpers; excludes react, react-dom, motion.
typing, keyboard focus, a value change
The ball glides without kiss or kick, group tints deepen in place, glyphs and the success rim fade in the check appears without tracing, a paste lands at once and the detection chip fades in.
Last 2 versions of Chrome, Edge, Firefox and Safari (iOS 16.4+)