Skip to content

feat(input-otp): add input-otp - #49

Merged
MGREMY merged 2 commits into
mainfrom
feat/input-otp
Jul 27, 2026
Merged

MGREMY merged 2 commits into
mainfrom
feat/input-otp

Conversation

@MGREMY

@MGREMY MGREMY commented Jul 27, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added an OTP input component with individual character slots.
    • Supports reactive form integration, configurable colors, disabled state, and five sizes from extra-small to extra-large.
    • Added themed styling, including focus states and an animated caret.
  • Documentation

    • Added OTP input usage, previews, examples, theming guidance, and package documentation.
    • Improved button size examples for consistency.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@MGREMY, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 38 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 145b9fcc-7ae7-4139-9b01-c1816cd2aa7d

📥 Commits

Reviewing files that changed from the base of the PR and between b94e7b6 and 82f9e1d.

📒 Files selected for processing (2)
  • packages/ng-primitives/_theme/components/input-otp.css
  • packages/ng-primitives/input-otp/src/lib/mgnp-input-otp/mgnp-input-otp.ts

Walkthrough

Adds a new Angular OTP input primitive with ControlValueAccessor support, public package exports, theme styles and caret animation, dynamic documentation examples, and a dedicated documentation page.

Changes

Input OTP primitive

Layer / File(s) Summary
OTP directives and package API
packages/ng-primitives/input-otp/..., tsconfig.base.json
Adds the OTP control, input, and slot directives; synchronizes values with the underlying state; supports disabled and touched states; and configures package exports and path mapping.
OTP theme styling
packages/ng-primitives/_theme/...
Adds container, hidden-input, slot color and size styles, caret animation, and the compiled theme import.
OTP previews and documentation
apps/documentation/src/...
Adds color and size examples, dynamic slot rendering, a reusable button size loop, and the OTP documentation page.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant NgpInputOtpState
  participant MgnpInputOtp
  participant AngularForm
  User->>NgpInputOtpState: Enter OTP characters
  NgpInputOtpState-->>MgnpInputOtp: Emit valueChange
  MgnpInputOtp->>AngularForm: Call onChange
  NgpInputOtpState-->>MgnpInputOtp: Emit complete
  MgnpInputOtp->>AngularForm: Call onTouched
Loading

Possibly related PRs

  • MGREMY/nx_source#36: Both changes update shared animation theme wiring used by the OTP caret.

Poem

A rabbit taps six slots in line,
With blinking caret, crisp and fine.
Colors bloom and sizes hop,
Forms now know when entries stop.
Documentation joins the cheer—
OTP magic lands right here! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding the input-otp primitive and its docs/theme support.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/input-otp

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/ng-primitives/_theme/components/input-otp.css`:
- Around line 21-29: Remove the fixed horizontal padding utility from the OTP
slot base styles while preserving the vertical padding, border, rounding, and
size-specific utilities in the input OTP slot styling. Ensure fixed-size slots
retain usable content width under border-box sizing.

In `@packages/ng-primitives/input-otp/src/lib/mgnp-input-otp/mgnp-input-otp.ts`:
- Line 47: Update MgnpInputOtp.writeValue to assign the incoming form-control
value through the host directive’s mgnpInputOtpValue state rather than only
updating the local value accessor. Normalize null and undefined to an empty
string, preserving the primitive’s expected value representation so
initialization, setValue, and reset update the slots and hidden input.
- Around line 60-64: Remove the onTouched subscription from the state().complete
stream and register it on the hidden input’s blur or focusout event instead.
Update the relevant input event wiring in the mgnp-input-otp component so
onTouched is invoked when focus leaves, regardless of OTP completion state.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 13cf480d-7463-475f-9e4b-312f6e89d0bd

📥 Commits

Reviewing files that changed from the base of the PR and between 9fc8730 and b94e7b6.

📒 Files selected for processing (16)
  • apps/documentation/src/content/documentation/ng-primitives/input-otp.md
  • apps/documentation/src/examples/button/size.ts
  • apps/documentation/src/examples/input-otp/size.ts
  • apps/documentation/src/previews/input-otp.ts
  • packages/ng-primitives/_theme/_animation.css
  • packages/ng-primitives/_theme/components/input-otp.css
  • packages/ng-primitives/_theme/components/input-otp/color.css
  • packages/ng-primitives/_theme/components/input-otp/size.css
  • packages/ng-primitives/_theme/mgnp.css
  • packages/ng-primitives/input-otp/README.md
  • packages/ng-primitives/input-otp/ng-package.json
  • packages/ng-primitives/input-otp/src/index.ts
  • packages/ng-primitives/input-otp/src/lib/mgnp-input-otp-input/mgnp-input-otp-input.ts
  • packages/ng-primitives/input-otp/src/lib/mgnp-input-otp-slot/mgnp-input-otp-slot.ts
  • packages/ng-primitives/input-otp/src/lib/mgnp-input-otp/mgnp-input-otp.ts
  • tsconfig.base.json

Comment on lines +21 to +29
@apply py-2 px-4;
@apply border rounded-lg;

/* Sizes */
@apply data-[mgnp-input-otp-slot-size=xs]:mgnp-input-otp-slot-size-xs;
@apply data-[mgnp-input-otp-slot-size=sm]:mgnp-input-otp-slot-size-sm;
@apply data-[mgnp-input-otp-slot-size=md]:mgnp-input-otp-slot-size-md;
@apply data-[mgnp-input-otp-slot-size=lg]:mgnp-input-otp-slot-size-lg;
@apply data-[mgnp-input-otp-slot-size=xl]:mgnp-input-otp-slot-size-xl;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Remove fixed horizontal padding from fixed-size slots.

Line [21] applies px-4 to every slot while Lines [25-29] apply fixed size-* utilities. With Tailwind’s default border-box sizing, size-8 is 2rem wide but px-4 already consumes 2rem horizontally, leaving no usable content width for the OTP character; larger sizes are also unnecessarily constrained. (tailwindcss.com)

Proposed fix
-    `@apply` py-2 px-4;
+    `@apply` p-0;

Based on the supplied Tailwind v4 theme and fixed slot-size contract.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@apply py-2 px-4;
@apply border rounded-lg;
/* Sizes */
@apply data-[mgnp-input-otp-slot-size=xs]:mgnp-input-otp-slot-size-xs;
@apply data-[mgnp-input-otp-slot-size=sm]:mgnp-input-otp-slot-size-sm;
@apply data-[mgnp-input-otp-slot-size=md]:mgnp-input-otp-slot-size-md;
@apply data-[mgnp-input-otp-slot-size=lg]:mgnp-input-otp-slot-size-lg;
@apply data-[mgnp-input-otp-slot-size=xl]:mgnp-input-otp-slot-size-xl;
`@apply` p-0;
`@apply` border rounded-lg;
/* Sizes */
`@apply` data-[mgnp-input-otp-slot-size=xs]:mgnp-input-otp-slot-size-xs;
`@apply` data-[mgnp-input-otp-slot-size=sm]:mgnp-input-otp-slot-size-sm;
`@apply` data-[mgnp-input-otp-slot-size=md]:mgnp-input-otp-slot-size-md;
`@apply` data-[mgnp-input-otp-slot-size=lg]:mgnp-input-otp-slot-size-lg;
`@apply` data-[mgnp-input-otp-slot-size=xl]:mgnp-input-otp-slot-size-xl;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/ng-primitives/_theme/components/input-otp.css` around lines 21 - 29,
Remove the fixed horizontal padding utility from the OTP slot base styles while
preserving the vertical padding, border, rounding, and size-specific utilities
in the input OTP slot styling. Ensure fixed-size slots retain usable content
width under border-box sizing.

@MGREMY
MGREMY merged commit 0e4037a into main Jul 27, 2026
5 checks passed
@MGREMY
MGREMY deleted the feat/input-otp branch July 27, 2026 15:12
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.

1 participant