x
1
2
3
4
5
6
7
<div class="input input--actor flex items-center gap" data-controller="clearable-input"> <input type="text" name="clearable_input" id="clearable_input" data-clearable-input-target="input" /> <button class="btn btn--plain" data-action="clearable-input#clear"> <img aria-hidden="true" src="/assets/x-2fabf707.svg" width="20" height="20" /> <span class="sr-only">Clear input</span> </button></div>
1
2
3
4
5
6
7
<div class="input input--actor flex items-center gap" data-controller="clearable-input"> <%= text_field_tag "clearable_input", nil, data: { clearable_input_target: "input" } %> <button class="btn btn--plain" data-action="clearable-input#clear"> <%= image_tag "x.svg", size: 20, aria: { hidden: true } %> <span class="sr-only">Clear input</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 clearable_input_controller.js