JSFiddle - React, Tailwind, and code Playground
JavaScript
function isTouchDevice() {
return true == ("ontouchstart" in window || window.DocumentTouch && document instanceof DocumentTouch);
}
if (isTouchDevice() === true) {
alert('Touch Device'); //your logic for touch device here
} else {
alert('Not a Touch Device'); //your logic for non touch device here
}