Is it possible using CSS/PostCSS (magic) to show subsequent element only if the target input is focused and not empty?
I've achived half way to show it when input is focused, but can't figure out yet if it's a thing to combine focus and empty together?
input:not(:focus) + button {
opacity: 0;
pointer-events: none;
touch-action: none;
}
input:not(:focus):not(:empty) + .notEmptyCase {
opacity: 0;
pointer-events: none;
touch-action: none;
}
<p>Button gets visible when input is focused</p>
<input placeholder="Search">
<button>CLEAR</button>
<p>Button gets visible when input is focused and isn't empty</p>
<input placeholder="Search">
<button class='notEmptyCase'>CLEAR</button>