надо чтобы при исчезновении button был transition на 0,3 секунд
<div class="item4">
<div class="button1">
<div class="icon"><i class="fab fa-steam-symbol"></i></div>
<span>Steam</span>
</div>
</div>
<div class="item4">
<div class="button">
<div class="icon"><i class="fab fa-google"></i></div>
<span>Google</span>
</div>
</div>
.item4 .button {
display: inline-block;
width: 40px;
height: 38px;
margin: 15px 5px;
overflow: hidden;
background: #fff;
border-radius: 50px;
cursor: pointer;
box-shadow: 0px 10px 10px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease-out;
}
.item4 .button:hover {
width: 120px;
}
.item4 .button .icon {
display: inline-block;
height: 20px;
width: 20px;
text-align: center;
border-radius: 50px;
box-sizing: border-box;
line-height: 45px;
}
.item4 .button .icon i {
font-size: 24px;
line-height: 20px;
padding-left: 8px;
}
.item4 .button span {
font-size: 24px;
font-weight: 50px;
line-height: 40px;
margin-left: 15px;
}
.item4 .button1 {
display: inline-block;
width: 40px;
height: 38px;
margin: 15px 5px;
overflow: hidden;
background: #fff;
border-radius: 50px;
cursor: pointer;
box-shadow: 0px 10px 10px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease-out;
}
.item4 .button1:hover {
width: 120px;
}
.item4 .button1:hover>.button {
visibility: hidden;
}
.item4 .button1 .icon {
display: inline-block;
height: 20px;
width: 20px;
text-align: center;
border-radius: 50px;
box-sizing: border-box;
line-height: 45px;
}
.item4 .button1 .icon i {
font-size: 24px;
line-height: 20px;
padding-left: 10px;
}
.item4 .button1 span {
font-size: 24px;
font-weight: 50px;
line-height: 40px;
margin-left: 15px;
}
.active {
visibility: hidden;
}
const buttonOne = document.querySelector(".button1");
const buttonTwo = document.querySelector(".button");
const bttnClassAdd = () => {
buttonTwo.classList.add("active");
};
const bttnClassRemove = () => {
buttonTwo.classList.remove("active");
};
buttonOne.addEventListener("mouseover", bttnClassAdd);
buttonOne.addEventListener("mouseout", bttnClassRemove);