본문으로 건너뛰기
cccskills
무료GitHub에 공개

code-confirmation

Use when implementing verify codes with segmented input.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(2)

  • SKILL.md5.5 KB
  • references/pattern.md24.0 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Code Confirmation

Verify codes with segmented input

What it solves

A Code Confirmation (also called an OTP input or verification code input) is a specialized form component that allows users to enter short numeric or alphanumeric codes — typically 4–8 characters — sent via SMS, email, or authenticator app to verify identity. The defining characteristic is the segmented layout: each character occupies its own individual input box, providing a clear visual structure that guides users digit-by-digit and reduces transcription errors.

When to use

  • Two-factor authentication (2FA) – SMS or TOTP codes used alongside password login.
  • Email verification – Confirm account ownership after registration.
  • Password reset flows – Short codes sent via SMS or email to authorize resets.
  • Transaction confirmation – PIN or code required before sensitive financial actions.
  • Access codes – Short invite or gift codes entered to unlock content.

When to avoid

  • Long passwords or passphrases – A standard password field is better; segmented inputs are meant for short, structured codes.
  • Free-form text entry – Use a text field instead.
  • When the code length is unknown or variable – Use a standard single-line input.
  • Codes longer than 8 digits – Cognitive load increases significantly; consider a text field with masking.

Implementation workflow

  1. Confirm the pattern matches the problem and constraints before copying the example.
  2. Start from the anatomy and examples in references/pattern.md, then choose the smallest viable variation.
  3. Apply accessibility, performance, and interaction guardrails before layering visual polish.
  4. Use the testing guidance to verify behavior across keyboard, screen reader, responsive, and failure scenarios.

Accessibility guardrails

Keyboard Interaction Pattern

KeyAction
0–9 / A–ZEnters a digit or character and advances focus to the next input
BackspaceClears current digit; if empty, moves focus to previous input
DeleteClears current digit without moving focus
Arrow LeftMoves focus to the previous digit input
Arrow RightMoves focus to the next digit input
TabMoves focus to the next focusable element outside the group
Shift + TabMoves focus to the previous focusable element outside the group

Performance guardrails

  • Initial render: < 50ms for digit group appearance
  • Auto-advance response: < 16ms (single frame) after digit entry
  • Paste distribution: < 50ms to fill all digits from clipboard
  • Error state transition: < 200ms including shake animation
  • Memory usage: < 2KB per OTP component instance

Common mistakes

Using type="number" for Digit Inputs

The Problem: <input type="number"> accepts e, +, - and shows stepper arrows in some browsers. It also returns an empty string for checkValidity on certain non-numeric entries.

<!-- Bad -->
<input type="number" min="0" max="9" class="otp-digit" />

How to Fix It? Use type="text" with inputmode="numeric" and pattern="[0-9]".

<!-- Good -->
<input type="text" inputmode="numeric" pattern="[0-9]" maxlength="1" class="otp-digit" />

Blocking Paste Events

The Problem: Disabling paste breaks SMS autofill and forces users to type digit-by-digit from a copied code, causing significant frustration.

// Bad
input.addEventListener('paste', (e) => e.preventDefault());

How to Fix It? Handle paste to distribute characters across boxes.

// Good: distribute pasted text across all digit inputs
container.addEventListener('paste', (e) => {
  e.preventDefault();
  const text = e.clipboardData.getData('text').replace(/\D/g, '');
  const digits = inputs; // NodeList of digit inputs
  [...text].slice(0, digits.length).forEach((char, i) => {
    digits[i].value = char;
  });
  // Move focus to the last filled digit or the next empty one
  const lastFilled = Math.min(text.length, digits.length) - 1;
  digits[lastFilled]?.focus();
});

No Backspace Navigation

The Problem: Users who mistype a digit expect Backspace to clear it and return focus to the previous box. Without this, they're stranded on an empty box.

How to Fix It? Listen for keydown and navigate backward when the input is already empty.

input.addEventListener('keydown', (e) => {
  if (e.key === 'Backspace' && input.value === '') {
    const prev = getPreviousInput(input);
    if (prev) {
      prev.value = '';
      prev.focus();
    }
  }
});

Related patterns


For full implementation detail, examples, and testing notes, see references/pattern.md.

Pattern page: https://uxpatterns.dev/patterns/forms/code-confirmation

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

accordion

무료

Use when implementing expand and collapse content sections.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

thedaviddias/ux-patterns-for-developers2662026년 10월 5일 업데이트

Use when implementing user account configuration and preferences.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

thedaviddias/ux-patterns-for-developers2662026년 10월 5일 업데이트

Use when implementing social activity and updates stream.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

thedaviddias/ux-patterns-for-developers2662026년 10월 5일 업데이트

ai-chat

무료

Use when implementing conversational AI chat interfaces.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

thedaviddias/ux-patterns-for-developers2662026년 10월 5일 업데이트

Use when implementing handling AI-specific errors.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

thedaviddias/ux-patterns-for-developers2662026년 10월 5일 업데이트

Use when implementing loading states for AI operations.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

thedaviddias/ux-patterns-for-developers2662026년 10월 5일 업데이트

thedaviddias의 스킬 모두 보기

이 스킬의 문제 신고