I've been attempting to adjust the positioning of the Tawk.to Sticky button on my Next js website using CSS, but it doesn't seem to be working.
Below is the script within the Next Js script tag:
<Script dangerouslySetInnerHTML={{ __html: `
var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date();
(function(){
var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0];
s1.async=true;
s1.src='https://embed.tawk.to/66706a619a809f19fb3eb4bb/1i0jhv3q8';
s1.charset='UTF-8';
s1.setAttribute('crossorigin','*');
s0.parentNode.insertBefore(s1,s0);
})();
`,
}}
/>
Attempted solution: I added a tawkWidget ID and tried styling with CSS, but unfortunately, it did not work as intended.
document.addEventListener('DOMContentLoaded', (event) => {
var tawkWidget = document.querySelector('iframe[title="chat widget"]');
if (tawkWidget) {
tawkWidget.id = 'tawk-to-widget';
}
});
CSS:
#tawk-to-widget {
bottom: 50px !important;
}