Skip to content

Add toggle prop to OTP for private mode visibility#2449

Closed
aydinza wants to merge 1 commit intolivewire:mainfrom
aydinza:feat/otp-private-toggle
Closed

Add toggle prop to OTP for private mode visibility#2449
aydinza wants to merge 1 commit intolivewire:mainfrom
aydinza:feat/otp-private-toggle

Conversation

@aydinza
Copy link
Copy Markdown

@aydinza aydinza commented Mar 1, 2026

Summary

  • Adds a toggle prop to flux:otp that renders an eye/eye-slash button to toggle input visibility when used alongside private
  • Uses Alpine's x-effect to reactively switch input types between password and text
  • Only renders the toggle button when both private and toggle are set

Usage

<flux:otp wire:model="pin" length="6" private toggle />

Also works with custom slot markup:

<flux:otp wire:model="pin" private toggle>
    <flux:otp.group>
        <flux:otp.input />
        <flux:otp.input />
        <flux:otp.input />
        <flux:otp.input />
        <flux:otp.input />
        <flux:otp.input />
    </flux:otp.group>
</flux:otp>

Motivation

PIN and OTP inputs often need a visibility toggle for accessibility and usability. Currently, achieving this requires custom Alpine code outside the component. This prop provides a native, zero-config solution.

Adds a `toggle` prop to `flux:otp` that renders an eye/eye-slash button
to toggle input visibility when used with `private`. This allows users
to reveal masked OTP values without requiring custom Alpine code.

Usage:
```blade
<flux:otp wire:model="pin" length="6" private toggle />
```

The toggle button uses Alpine to reactively switch input types between
`password` and `text`. It only renders when both `private` and `toggle`
are set.
@ganyicz
Copy link
Copy Markdown
Collaborator

ganyicz commented Mar 23, 2026

Hi @aydinza

Thanks for contributing. We're going to hold off on this for now. I see the need for this however I'm unsure about the API, design and implementation. If you believe this should be part of Flux please open a discussion with a feature request and we will consider this once there's enough demand from community.

@ganyicz ganyicz closed this Mar 23, 2026
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.

2 participants