Input Mask 5

PreviousNext

A credit card CVC input field with secure formatting and length validation

Docs
shadcn-studiocomponent

Preview

Loading preview…
registry/new-york/components/input-mask/input-mask-05.tsx
'use client'

import { useId } from 'react'

import { usePaymentInputs } from 'react-payment-inputs'

import { Input } from '@/registry/new-york/ui/input'
import { Label } from '@/registry/new-york/ui/label'

const InputCVCCodeDemo = () => {
  const id = useId()
  const { getCVCProps } = usePaymentInputs()

  return (
    <div className='w-full max-w-xs space-y-2'>
      <Label htmlFor={id}>CVC code</Label>
      <Input {...getCVCProps()} id={id} />
      <p className='text-muted-foreground text-xs'>
        Built with{' '}
        <a
          className='hover:text-foreground underline'
          href='https://github.com/medipass/react-payment-inputs'
          target='_blank'
          rel='noopener noreferrer'
        >
          React Payment Inputs
        </a>
      </p>
    </div>
  )
}

export default InputCVCCodeDemo

Installation

npx shadcn@latest add @shadcn-studio/input-mask-05

Usage

import { InputMask05 } from "@/components/input-mask-05"
<InputMask05 />