JSFiddle - React, Tailwind, and code Playground

HTML

<input />
<button>Clear</button>

CSS

button {
 display: none;   
}

JavaScript

$("input").keyup(function () {
       if ($(this).val()) {
          $("button").show();
       }
       else {
          $("button").hide();
       }
    });
    $("button").click(function () {
       $("input").val('');
       $(this).hide();
    });