JSFiddle - React, Tailwind, and code Playground

by Venkatesh Dematti

HTML

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Input Field Colors</title>
</head>
<body>
  <input type="text" placeholder="asdasd" required>
</body>
</html>

CSS

/* Initial state */
    input {
      border: 1px solid #ccc;
      padding: 10px;
      transition: background-color 0.3s ease;
    }

    /* On focus (click) */
    input:focus {
      background-color: yellow;
    }

    /* When input has text using placeholder-shown and not(:placeholder-shown) */
    input:not(:placeholder-shown) {
      background-color: red;
    }

    /* To support older browsers, add a dummy value to the placeholder attribute */
    input[placeholder] {
      background-color: lightgreen;
    }