PIN input component for entering verification codes and PINs with auto-advance and paste support
Example
Enter the 6-digit code sent to your phone
code
<scripttype="module">import'@blueprintui/components/include/pin.js';</script><bp-field><label>Verification Code</label><bp-pinlength="6"></bp-pin><bp-field-message>Enter the 6-digit code sent to your phone</bp-field-message></bp-field>
<bp-form-grouplayout="vertical"><bp-field><label>Masked PIN (password)</label><bp-pinlength="4"mask></bp-pin><bp-field-message>PIN is masked like a password</bp-field-message></bp-field><bp-field><label>Visible PIN</label><bp-pinlength="4"></bp-pin><bp-field-message>PIN is visible</bp-field-message></bp-field></bp-form-group>
Types
Only numbers allowedLetters and numbers allowedUppercase letters and numbers only
code
<bp-form-grouplayout="vertical"><bp-field><label>Numeric (default)</label><bp-pinlength="6"type="number"></bp-pin><bp-field-message>Only numbers allowed</bp-field-message></bp-field><bp-field><label>Text (alphanumeric)</label><bp-pinlength="6"type="text"></bp-pin><bp-field-message>Letters and numbers allowed</bp-field-message></bp-field><bp-field><label>With Pattern (uppercase only)</label><bp-pinlength="6"type="text"pattern="[A-Z0-9]"></bp-pin><bp-field-message>Uppercase letters and numbers only</bp-field-message></bp-field></bp-form-group>
<scripttype="module">const form = document.querySelector('#pin-form');const result = document.querySelector('#form-result');
form.addEventListener('submit',(e)=>{
e.preventDefault();const formData =newFormData(form);
result.textContent ='Submitted PIN: '+ formData.get('verification-code');});</script><formid="pin-form"><bp-fieldvalidate><label>Verification Code</label><bp-pinname="verification-code"length="6"required></bp-pin><bp-field-message>Enter all 6 digits to submit</bp-field-message></bp-field><bp-buttontype="submit"style="margin-top:var(--bp-space-300)">Verify</bp-button><pid="form-result"style="margin-top:var(--bp-space-300)"></p></form>
Paste Support
Copy "123456" and paste into the first field
code
<bp-field><label>Try Pasting a Code</label><bp-pinlength="6"></bp-pin><bp-field-message>Copy "123456" and paste into the first field</bp-field-message></bp-field>