x
1
2
3
4
5
6
7
8
<div class="input input--actor flex items-center gap" data-controller="revealable-input"> <input type="password" name="revealable_input" id="revealable_input" data-revealable-input-target="input" /> <button type="button" class="btn btn--plain" data-action="revealable-input#reveal"> <img hidden="hidden" aria-hidden="true" data-revealable-input-target="showIcon" src="/assets/eye-3f1f6fb1.svg" width="20" height="20" /> <img hidden="hidden" aria-hidden="true" data-revealable-input-target="hideIcon" src="/assets/eye-off-60549f66.svg" width="20" height="20" /> <span class="sr-only">Reveal password</span> </button></div>
1
2
3
4
5
6
7
8
<div class="input input--actor flex items-center gap" data-controller="revealable-input"> <%= password_field_tag "revealable_input", nil, data: { revealable_input_target: "input" } %> <button type="button" class="btn btn--plain" data-action="revealable-input#reveal"> <%= image_tag "eye.svg", hidden: true, size: 20, aria: { hidden: true }, data: { revealable_input_target: "showIcon" } %> <%= image_tag "eye-off.svg", hidden: true, size: 20, aria: { hidden: true }, data: { revealable_input_target: "hideIcon" } %> <span class="sr-only">Reveal password</span> </button></div>
CSS is not required or multiple files are needed, check the notes.
Java Script is not required or multiple files are needed, check the notes.
The javascript is avilable at revealable_input_controller.js