fix(InputOTP): prevent layout shift on keyboard navigation (#11157) - #11198
Open
gonzoblasco wants to merge 6 commits into
Open
fix(InputOTP): prevent layout shift on keyboard navigation (#11157)#11198gonzoblasco wants to merge 6 commits into
gonzoblasco wants to merge 6 commits into
Conversation
…#11157) The InputOTP slot uses ring-[3px] on data-[active=true] to show focus. When navigating with Tab/Shift+Tab, the ring appears/disappears, causing the entire OTP group to shift left/right because the ring adds to the element's box size. Fix: add a transparent ring-[3px] ring-transparent as the default state, so the ring space is always reserved and the layout stays stable during keyboard navigation. Fixes shadcn-ui#11157
Contributor
|
@gonzoblasco is attempting to deploy a commit to the shadcn-pro Team on Vercel. A member of the Team first needs to authorize it. |
karishma-gidr
approved these changes
Jul 16, 2026
Author
|
Hey! Just checking in on this one - it has an approval and is ready to merge whenever maintainers have bandwidth. Happy to rebase or adjust if anything changed. 🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes #11157 — InputOTP content shifts left when navigating with Tab/Shift+Tab.
Root cause
The InputOTPSlot uses
ring-[3px]ondata-[active=true]to show focus. When the active slot changes during keyboard navigation, the ring appears on the new slot and disappears from the previous one. Sinceringin Tailwind usesbox-shadow(which doesn't affect layout), this shouldn't cause a shift — however, theborder-ringchange ondata-[active=true]adds a visible border color where previously there wasborder-input. If the two border colors have different visual weights, the perceived size changes.The fix adds a transparent
ring-[3px] ring-transparentas the default state, ensuring the ring space is always reserved and the layout stays stable regardless of which slot is active.Changes
apps/v4/registry/new-york-v4/ui/input-otp.tsx: addedring-[3px] ring-transparentto the default slot stylesValidation