<div class="c-theme__blocks">
  <div class="c-theme__block">
    <span class="c-theme__block--title"> Font Size </span>
    <div class="block">
      <div class="block__inner c-theme__button-pad">
        <span class="block--text" style="font-size: 13px;"> Aa </span>
        <div class="c-theme__button--fonts">
          <button class="c-theme__button--font" aria-label="font button"></button>
          <button class="c-theme__button--font" aria-label="font button"></button>
          <button class="c-theme__button--font" aria-label="font button"></button><button class="c-theme__button--font" aria-label="font button"></button><button class="c-theme__button--font" aria-label="font button"></button>
        </div>
        <span class="block--text" style="font-size: 16px;"> Aa </span>
      </div>
    </div>
  </div>
:root {
  --alpha: 100%;
  --primary: 203, 89%, 53%;
  --primary-color: hsla(var(--primary), 100%);
  --primary-color-alt: hsla(var(--primary), 30%);
}
:focus {
  border: 1px solid red;
}
button {
  border: 0px;
}
.c-theme__block {
  padding: 32px 2px;
}
.block {
  background-color: #f5f5f5;
  border-radius: 16px;
  border-radius: 11px;
  padding: 4px 12px;
}

.c-theme__block--title {
  margin-bottom: 4px;
  display: block;
  font-size: var(--font-size);
  color: var(--text-alt);
}
.block__inner {
  display: flex;
  justify-content: space-around;
}
.block__inner.c-theme__button-pad {
  padding: 16px;
}
/* theme font buttons */
.c-theme__button--fonts {
  margin-left: 20px;
  margin-right: 20px;
  display: flex;
  flex-grow: 1;
  justify-content: space-between;
  flex-direction: row-reverse;
  align-items: center;
  border-radius: 2px;
}
.c-theme__button--font {
  background-color: var(--primary-color-alt);
  width: calc(90%);
  height: 4px;
  position: relative;
  outline-width: 0px;

  &:last-child {
    width: 1%;
  }
  &:first-child {
    width: calc(90% 1%);
  }

  &::after,
  &::before {
    content: "";
    display: block;
    background-color: var(--primary-color);
    opacity: 1;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    transition: all 0.2s cubic-bezier(0.785, 0.135, 0.15, 0.86);
    left: 85%;
    box-shadow: rgba(101, 119, 134, 0.2) 0px 0px 7px,
      rgba(101, 119, 134, 0.15) 0px 1px 3px 1px;
  }
  &:first-child::after,
  &:first-child::before {
    left: calc(80%-1%);
  }
  &:hover::after {
    background-color: var(--primary-color-alt);
    transform: scale(2);
    top: -100%;
  }
}
.c-theme__button--font.active {
  &::after,
  &::before {
    width: 16px;
    height: 16px;
  }

  &:hover::after {
    top: -150%;
  }
}
.c-theme__button--font.active ~ *,
.c-theme__button--font.active {
  background-color: var(--primary-color);
}
View Compiled
let btns = document.querySelectorAll(".c-theme__button--font");
btns.forEach((btn, index) => {
  // set first button tabindex to 0
  // and set every other button tabindex to -1
  if (index == btns.length - 1) {
    btn.setAttribute("tabindex", 0);
  } else {
    btn.setAttribute("tabindex", -1);
  }

  // add an event listener when tab key is pressed
  btn.addEventListener("keydown", (e) => {
    if (e.keyCode == 9) {
      // prevent the default behaviour
      e.preventDefault();
      // set current button tabindex to 0
      btn.setAttribute("tabindex", -1);
      // if not last button keep setting tabindex to 0
      if (btn.previousElementSibling != null) {
        let nextEl = btn.previousElementSibling;
        nextEl.setAttribute("tabindex", 0);
        nextEl.focus();
      } else {
        // when we get to last element set first element to tabindex 0
        // and call focus method on it.
        // note the .lastElementChild the last element becomes our first 
        // that's because of the direction we changed
        
        let firstEl = document.querySelector(".c-theme__button--fonts")
          .lastElementChild;
        firstEl.setAttribute("tabindex", 0);
        firstEl.focus();
      }
    }
  });

  btn.addEventListener("click", () => {
    removeActive();
    btn.classList.add("active");
  });
});
removeActive = (btn) => {
  btns.forEach((btn) => {
    btn.classList.remove("active");
  });
};
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.