<div class="wrapper">
  <div class="element">
    <div class="code">#a3afaa</div>
  </div>
</div>

<div class="form">
  <div class="control">
    <span class="hash">&nbsp;</span>
    <span class="hash">#</span>
  </div>
  <div class="control">
    <label for="red">Red</label>
    <input type="text" id="red" pattern="^[a-f0-9]{2}$" placeholder="a3" value="a3" />
    <span></span>
  </div>
  <div class="control">
    <label for="green">Green</label>
    <input type="text" id="green" pattern="^[a-f0-9]{2}$" placeholder="af" value="af" />
    <span></span>
  </div>
  <div class="control">
    <label for="blue">Blue</label>
    <input type="text" id="blue" pattern="^[a-f0-9]{2}$" placeholder="aa" value="aa" />
    <span></span>
  </div>
</div>
@import url("https://fonts.googleapis.com/css?family=Gochi+Hand");

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  margin: 0;
  padding: 0;
  background-color: #291642;
  font-family: "Gochi Hand", sans-serif;
  color: #fff;
  font-size: 130%;
  letter-spacing: 0.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  width: 100vw;
  min-height: 100vh;
  padding: 10px;
}


.wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  margin: 3vh 0;
}

.element {
  border: 1px dashed currentColor;
  padding: 4vh;
  min-width: 50vw;
  min-height: 30vh;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 8px;
  font-size: 3rem;
  color: #a3afaa;
}

.form {
  display: flex;
  justify-content: center;
  align-items: center;
}

.control {
  display: grid;
  gap: 10px;
  grid-template-columns: 80px 30px;
  margin: 0 5px;
}

label {
  grid-column: 1 / 3;
  justify-self: start;
}

span {
  align-self: center;
}
.hash {
  grid-column: span 2;
  margin-left: auto;
  font-size: 1.5rem;
}
input {
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 3px;
  width: 100%;
  color: #2C3E50;
  font-family: "Gochi Hand", sans-serif;
}

input:invalid + span:after {
  content: '✖';
  color: red;
}

input:valid + span:after {
  content: '✓';
}
View Compiled
const inuts = document.querySelectorAll("input");
const code = document.querySelector(".code");
const element = document.querySelector(".element");

const arr = [...inuts].map((input, index) => {
  input.addEventListener("change", function (e) {
    handleUpdate(e, index);
  });
  return input.value;
});

function handleUpdate(e, index) {
  arr[index] = e.target.value;
  const text = `#${arr.join("")}`;
  code.textContent = text;
  element.style.color = text;
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.