Skip to content

fix(InputOTP): limit slot transition to color and box-shadow only#11179

Open
gonzoblasco wants to merge 2 commits into
shadcn-ui:mainfrom
gonzoblasco:fix/11157-input-otp-keyboard-layout-shift
Open

fix(InputOTP): limit slot transition to color and box-shadow only#11179
gonzoblasco wants to merge 2 commits into
shadcn-ui:mainfrom
gonzoblasco:fix/11157-input-otp-keyboard-layout-shift

Conversation

@gonzoblasco

Copy link
Copy Markdown

Description

The InputOTPSlot uses transition-all which animates every CSS property when the data-active state changes during keyboard navigation (Tab/Shift+Tab). This causes a visual layout shift where the page content jumps to the left.

Root Cause

When the hidden input inside the input-otp library gains or loses focus via keyboard navigation, the data-active attribute toggles on the slot div. Only border-color and box-shadow actually change (via data-[active=true]:border-ring and data-[active=true]:ring-3), but transition-all animates every property — including z-index and other layout-affecting changes during the transition frame — causing visible content shift.

Fix

Replaced transition-all with transition-[color,box-shadow] to scope transitions to only the properties that actually change on focus. This eliminates the layout shift while keeping smooth visual feedback.

Changes

Updated all 15 files that had transition-all across the codebase:

  • apps/v4/registry/new-york-v4/ui/input-otp.tsx (registry component)
  • 14 style variants in apps/v4/styles/ (base-luma, base-lyra, base-maia, base-mira, base-nova, base-nova/ui-rtl, base-vega, radix-luma, radix-lyra, radix-maia, radix-mira, radix-nova, radix-nova/ui-rtl, radix-vega)

The rhea and sera variants already used scoped transitions (transition-[color,box-shadow] and transition-[color,border-color] respectively), confirming this pattern is correct.

Fixes #11157

Testing

  • Verified no transition-all remains in any input-otp.tsx file
  • All changes are consistent with the existing rhea and sera variants
  • Manual testing: Tab/Shift+Tab on Input OTP no longer causes layout shift

@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown
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.

@gonzoblasco
gonzoblasco force-pushed the fix/11157-input-otp-keyboard-layout-shift branch 2 times, most recently from f013644 to d0eb827 Compare July 16, 2026 11:36
Replace transition-all with transition-[color,box-shadow] in all
InputOTPSlot variants to prevent unwanted layout shift during keyboard
navigation (Tab/Shift+Tab).

When the hidden input in the input-otp library gains or loses focus via
keyboard navigation, the data-active attribute toggles on the slot div.
Only border-color and box-shadow actually change, but transition-all
animates every property including z-index and potential layout-affecting
changes during the transition frame, causing visible content shift.

This change covers all 14 style variants that used transition-all plus
the new-york-v4 registry component, aligning them with the rhea and sera
variants which already used scoped transitions.

Fixes shadcn-ui#11157
@gonzoblasco
gonzoblasco force-pushed the fix/11157-input-otp-keyboard-layout-shift branch from d0eb827 to 5f7dad3 Compare July 16, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: Input OTP - Keyboard navigation causes unwanted layout shift

1 participant