Input mask
Guide people toward a valid format as they type with an input mask for constrained text fields.
Examples
Breakpoints
Mobile
320pxMobile Lg
480pxTablet
640pxDesktop
1024pxFor example, 123 45 6789
For example, 123-456-7890
For example, 12345-6789
For example, A1B 2C3
input-mask-demo.tsx
Component API
Put Label, Control, Placeholder, and Input inside Root to guide entry in a fixed format.
Root<div>
Owns the mask and input value.
| Prop | Type | Description |
|---|---|---|
placeholder | string (required) | Defines the mask format. |
charset | string | Defines accepted characters for placeholder positions. |
defaultValue | string | Initial uncontrolled value. |
value | string | Controlled value. |
onValueChange | ({ value: string }) => void | Receives value changes. |
ids | { root?: string; content?: string; input?: string } | Overrides generated part IDs. Use Root IDs when a label or external control needs a stable input or trigger target. |
Label<label>
Native label. Set htmlFor to the input ID explicitly, or use Field.Label with an enclosing Field.Root.
Control<div>
Aligns the placeholder guide and input.
Placeholder<span>
Displays the unentered mask characters.
Input<input>
Receives the typed value. Field.Root can supply validation state; the mask itself does not validate completeness.
| Attribute | Value | Purpose |
|---|---|---|
data-invalid | Present when invalid | Style the error state. |