JSFiddle - React, Tailwind, and code Playground

by Sean

HTML

<div class="dashboard">
<div class="item">
    <div class="dashboard-item-top child">
      Classes
    </div>
    <div class="dashboard-item-bottom child">
      <span class="info-block-item">0</span>
    </div>
</div>
</div>

CSS

.dashboard {
    display: flex;
}

.dashboard .item {
    border-radius: .25rem;
    border: 1px solid rgba(0,0,0,.125);
    background: white;
    text-align: center;
    flex-grow: 1;
    margin-right: 20px;
    width: 20%;
}

.dashboard .item:hover {
    cursor: pointer;
    border: 1px solid #A7A7A7;
}

.dashboard-item-top {
    border-bottom: 1px solid #dfdfdf;
    padding: 2px;
    font-size: 20px;
    transition: background-color 0.5s ease;

    /*this background color should change to #F2F3F3 when 
    .item div is hovered*/
}

.info-block-item {
    font-size: 20px;
}

JavaScript

var oldBackground;
var parentNode = document.getElementByClassName('item');
var childNodes = document.getElementsByClassName('child');

parentNode.onmouseenter = e => {
    var c = e.target.childNodes[0]
    c && ((oldBackground = c.style.background) &c.style.background="blue")
};

parentNode.onmouseout = e => {
    var c = e.target.childNodes[0]
    c && oldBackground && (c.style.background=oldBackground)
};