Build the preset once at module level, so the mask does not rebuild, and add MaskedInputClear as a child at the end.
The sample also uses Field. One command adds them with this item:
card-number.tsx
MaskedInputControl
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| class | string | — | |
| rounded | "default""full" | — | |
| size | "default""lg""sm""xs" | — | |
| mask | MaskPreset<Raw> | — | A preset from #/lib/masks (or #/lib/phone-model). Build it once: a new object rebuilds the mask. |
| value | string | — | The shown value (controlled). It is formatted by the mask, so "4155550132" shows formatted. |
| default | string | — | The first shown value (uncontrolled), formatted by the mask. |
| on | — | Runs on every change with the shown value, the raw value, and the checks. | |
| guide | boolean | true | The ghost guide of the slots still to fill, while the input has focus. Default true. |
| raw | string | — | Also submit the raw value under this name (a hidden input), next to the shown one. |
| reject | boolean | true | Nudge the field 2px when the mask rejects a key. Default true. |
| on | — | Runs when the mask rejects a key (a letter in a number, a 13th month). | |
| ref | Ref<HTMLInputElement> | — | |
| ...props | <div> attributes | — | Every other attribute goes to the <div>. |
MaskedInput
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| class | string | — | |
| rounded | "default""full" | — | |
| size | "default""lg""sm""xs" | — | |
| mask | MaskPreset<Raw> | — | A preset from #/lib/masks (or #/lib/phone-model). Build it once: a new object rebuilds the mask. |
| value | string | — | The shown value (controlled). It is formatted by the mask, so "4155550132" shows formatted. |
| default | string | "" | The first shown value (uncontrolled), formatted by the mask. |
| on | — | Runs on every change with the shown value, the raw value, and the checks. | |
| guide | boolean | — | The ghost guide of the slots still to fill, while the input has focus. Default true. |
| raw | string | — | Also submit the raw value under this name (a hidden input), next to the shown one. |
| reject | boolean | — | Nudge the field 2px when the mask rejects a key. Default true. |
| on | — | Runs when the mask rejects a key (a letter in a number, a 13th month). | |
| ref | Ref<HTMLInputElement> | — | |
| addons | boolean | true | Show the start and end text of the preset (a currency symbol, "%", a unit). Default true. |
| ...props | <div> attributes | — | Every other attribute goes to the <div>. |
MaskedInputClear
<button>| Prop | Type | Default | Description | ||||
|---|---|---|---|---|---|---|---|
| class | string | — | |||||
| size | "icon-sm""icon-xs""sm""xs" | — | |||||
| rounded | "default""full" | — | |||||
| variant | "dashed""default""destructive""destructive-outline""ghost""link""media""outline""secondary" | — | |||||
| on | — | ||||||
From Base UIButtonBase UI docs | |||||||
| focusable | boolean | false | Whether the button should be focusable when disabled. | ||||
| render | — | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. | |||||
| style | — | Style applied to the element, or a function that returns a style object based on the component's state. | |||||
| |||||||
| ...props | <button> attributes | — | Every other attribute goes to the <button>, with a ref. | ||||
| EnterorSpace | On MaskedInputClear: clears the field and puts focus back in it. |
|---|
Built with
Installs with Masked Input
- Components
- Input Group





