JSFiddle - React, Tailwind, and code Playground
HTML
<a class="selector" href="#"> Download </a>
JavaScript
$(function() {
$('a.selector').click(function() {
text = 'file content';
type = 'application/pdf';
name = 'file name';
var a = document.createElement("a");
var file = new Blob([data], {type: type});
a.href = URL.createObjectURL(file);
a.download = name;
a.click();
})
})