guilhermerodz / input-otp

One time passcode Input. Accessible & unstyled.
https://input-otp.rodz.dev
2.29k stars 46 forks source link

InputOTP Placeholders #49

Open almond5 opened 2 months ago

almond5 commented 2 months ago

Is there no support for placeholders on each InputOTPSlot or the whole InputOTPGroup? image

guilhermerodz commented 2 months ago

Hey @almond5 thanks for opening this issue.

I totally forgot implementing a good DX for the placeholder option.

There's a workaround for rendering that placeholder, but that's logical and not ideal. However, as a workaround, you may be able to check if the placeholder is active by checking isPlaceholderActive = value.length === 0 && placeholder !== null. Then, you should be able to render only the placeholder[slotIdx] and style it as you wish.

I should definitely add a feature around this. There's currently no direct support to placeholder. I am now considering creating a feature for that.

Again, thanks for reporting.