astralyxdev

Mask Input

Forms 2

About

A text input that formats as you type using a pattern mask (digits, letters, or either), such as a card number, phone number, or date, while also handing back the raw unformatted characters for submission.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Mask Input to your project and fits it to your theme.

Code

How Mask Input is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import { MaskInput } from "@/components/ui/mask-input";
import { useState } from "react";

export default function MaskInputDemo() {
  const [raw, setRaw] = useState("");

  return (
    <div className="flex w-full max-w-xs flex-col gap-2 bg-background text-foreground">
      <label
        className="text-sm font-medium text-muted-foreground"
        htmlFor="card-number"
      >
        Card number
      </label>
      <MaskInput
        id="card-number"
        mask="#### #### #### ####"
        onValueChange={(_, value) => setRaw(value)}
      />
      <p className="text-xs text-muted-foreground">
        Raw digits sent to the API: {raw || "—"}
      </p>
    </div>
  );
}

More by astralyxdev

View all
  • Rate Limit Meter

    Rate Limit Meter

    34
  • Note Graph

    Note Graph

    26
  • Checkout Summary

    Checkout Summary

    22
  • IP Cluster

    IP Cluster

    12
  • Migration List

    Migration List

    11
  • Budget Guard

    Budget Guard

    11
  • Prompt Versions

    Prompt Versions

    10
  • Attribution

    Attribution

    9

More in Forms

View all
  • Premium Auth

    Premium Auth

    562
  • Contact Card

    Contact Card

    1.1K
  • Book A Demo 1

    Book A Demo 1

    90
  • Authentication Card

    Authentication Card

    51
  • Form

    Form

    139
  • Card Studio

    Card Studio

    46
  • Login 2

    Login 2

    12
  • Book A Demo 3

    Book A Demo 3

    101