Download Button
Trigger file downloads from browser
Preview
{ window.Prism.highlightElement($refs.codeEl) }) }"
class="w-full flex items-center justify-between px-6 py-4 text-left bg-gray-50 dark:bg-gray-900 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors cursor-pointer">
View Code
<button @click="
const content = 'Sample file content';
const blob = new Blob([content], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'sample.txt';
a.click();
URL.revokeObjectURL(url);
" class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700">
Download File
</button>