Skip to content

feat(input-otp): add new input-otp component #30386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 81 commits into
base: feature-8.6
Choose a base branch
from

Conversation

brandyscarney
Copy link
Member

@brandyscarney brandyscarney commented Apr 30, 2025

Issue number: internal


What is the current behavior?

In order to re-create an OTP Input component users have to custom style an <ion-input>, possibly multiple, to get the design and functionality they want.

What is the new behavior?

  • Adds a new component ion-input-otp which provides the OTP input functionality
    • Displays as an input group with multiple boxes accepting a single character
    • Accepts type which determines whether the boxes accept numbers or text/numbers and determines the keyboard to display
    • Supports changing the displayed keyboard using the inputmode property
    • Accepts a length property to control the number of input boxes
    • Accepts the following properties to change the design: fill, shape, size, color
    • Accepts a separators property to show a separator between 1 or more input boxes
    • Supports the disabled, readonly and invalid states
    • Supports limiting the accepted input via the pattern property
    • Emits the following events: ionInput, ionChange, ionComplete, ionBlur, ionFocus
    • Exposes the following methods: reset, setFocus

Does this introduce a breaking change?

  • Yes
  • No

Other information

Dev build: 8.5.7-dev.11748379940.12698faf

Previews

Documentation

Copy link

vercel bot commented Apr 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ionic-framework ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 28, 2025 7:23pm

@github-actions github-actions bot added package: core @ionic/core package package: angular @ionic/angular package package: vue @ionic/vue package package: react @ionic/react package labels Apr 30, 2025
@exorex
Copy link

exorex commented May 2, 2025

Thank you, @brandyscarney, for your work on this component.

One feature suggestion: pressing CTRL+A (or CMD+A on macOS) inside the component could select and clear all input fields at once. This would align with common input behavior and improve UX for users needing to re-enter their code quickly.

Example: https://input-otp.rodz.dev/

Copy link
Contributor

@thetaPC thetaPC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found with core and Angular. I'm waiting on React and Vue to be ready for review.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these changes needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the change to rsync because creating the Vue test app was ridiculously slow for me, but I can revert it for now since it actually caused CI to fail.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much!

Copy link
Contributor

@thetaPC thetaPC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: angular @ionic/angular package package: core @ionic/core package package: react @ionic/react package package: vue @ionic/vue package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants