<div class="container">
  <input id="main-input" placeholder="add item..."></input>
  <div id="item-list">
    <p class="item">Javascript</p>
    <p class="item">Node.js</p>
    <p class="item">React</p>
  </div>
</div>
* {
  padding: 0px;
  margin: 0px;
  box-sizing: border-box;
}

body {
  padding: 10px 10%;
}

#main-input {
  width: 100%;
  display: block;
  padding: 5px 10px;
  background-color: #F2F3F4;
  border: 1px solid black;
  outline: none;
}

#item-list {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  padding-top: 5px;
}

.item {
  padding: 5px 10px;
  background-color: #F2F3F4;
  transition: 0.2s padding ease-in, 0.2s background-color ease-in, 0.2s color ease-in;
}

.item:hover {
  padding: 8px 10px;
  background-color: #52BE80;
  color: white;
}
const mainInput = document.getElementById('main-input')
const itemList = document.getElementById('item-list')

mainInput.addEventListener('keydown', (ev) => {
  if (ev.key === "Enter") {
    ev.preventDefault()
    if (mainInput.value !== "") {
      const newItem = document.createElement('p')
      newItem.classList.add('item')
      itemList.appendChild(newItem)
      newItem.innerText = mainInput.value
      mainInput.value = ""
    }
  }
})

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.