JSFiddle - React, Tailwind, and code Playground

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Events: Task 3</title>
    <style>
      p {
        color: purple;
        margin: 0.5em 0;
      }

      * {
        box-sizing: border-box;
      }

      button {
        display: block;
        margin: 20px 0 20px 20px;
      }

      .button-bar {
        padding: 20px 0;
      }
    </style>
    <link rel="stylesheet" href="../styles.css" />
  </head>

  <body>
    <section class="preview"></section>

    <div data-color="orange" class="button-bar">
      <button data-color="red">Red</button>
      <button data-color="yellow">Yellow</button>
      <button data-color="green">Green</button>
      <button data-color="purple">Purple</button>
    </div>

    <script>
      const buttonBar = document.querySelector(".button-bar");
      const handleClick = (event) => {
        if (event.target === event.currentTarget) {
          return null;
        }
        event.target.style.backgroundColor =
          event.target.getAttribute("data-color");
      };
      buttonBar.addEventListener("click", handleClick);

      // Add your code here
    </script>
  </body>
</html>