JSFiddle - React, Tailwind, and code Playground
HTML
<a href="#" id="showWidget">show</a>
<div id="widget"></div>
<div id="widget2">xxx</div>
CSS
#widget {
width: 200px;
height: 80px;
background: black;
position: absolute;
transition: transform 500ms;
transform: translateX(-200px);
display: none;
}
#widget.visible {
transform: translateX(200px);
}
#widget2 { position: absolute; right: 0 }
JavaScript
document.getElementById('showWidget').addEventListener('click', function(e) {
e.preventDefault();
var widget = document.getElementById('widget');
widget.style.display = 'block';
//document.getElementById('widget2').clientWidth; //comment this line out and it wont work
window.setTimeout(function(){
widget.className = 'visible';
},0);
});