react-code-input icon indicating copy to clipboard operation
react-code-input copied to clipboard

Placeholder?

Open stephengardner opened this issue 7 years ago • 2 comments

Is there any way to add a placeholder (ex: "-") for the input fields?

stephengardner avatar Nov 27 '18 21:11 stephengardner

not yet possible, but could be useful feature

40818419 avatar Nov 28 '18 16:11 40818419

import ReactCodeInput from "react-code-input";

export default function ExampleComponent({}: {}) {
    ...
    const inputRef = useRef<any>(null)

    useEffect(() => {
        if (null !== inputRef.current){
            document.querySelectorAll("input")
                    .forEach((node: HTMLInputElement) => node.setAttribute('placeholder', '0'));
        }
    })

    return (
       ...
        <ReactCodeInput
            ref={inputRef}
            fields={4}
            name="pin"
            type="text"
            inputMode="latin"
        />
       ...
    )} 

alex-andreiev avatar Dec 28 '20 16:12 alex-andreiev