<button class="button">Click me</button>
body {
  display: flex;
  min-height: 100vh;
  justify-content: center;
  align-items: center;
}

.button {
  font-size: 3em;
  font-family: inherit;
  border: none; 
  background-color: #33ae74;
  padding: 0.5em 0.75em;
  transition: background-color 0.5s ease-out;
}

.button.is-active {
  background-color: #1ce;
}
const button = document.querySelector('.button')

button.addEventListener('click', _ => button.classList.toggle('is-active'))

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.