S.Khan
S.Khan

Reputation: 177

OTP Input using textfield material UI

Can we make OTP input using textfield of material UI in react typescript? I have seen people did it with input field but i am looking if it can be done through textfield of material UI

Upvotes: 1

Views: 8534

Answers (1)

Victor dlf
Victor dlf

Reputation: 346

There is a package for Material UI v5 (or MUI) called Mui OTP input and it's working with React 17 and 18 !

Simply way to use.

Check the doc here : https://github.com/viclafouch/mui-otp-input

import React from 'react'
import { MuiOtpInput } from 'mui-one-time-password-input'

const MyComponent = () => {
  const [value, setValue] = React.useState('')

  const handleChange = (newValue) => {
    setValue(newValue)
  }

  return <MuiOtpInput length={6} value={value} onChange={handleChange} />
}

Upvotes: 6

Related Questions