This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// npm install --save html2canvas | |
import html2canvas from 'html2canvas'; | |
download = () => { | |
html2canvas(document.querySelector("#container")).then(canvas => { | |
const img = canvas.toDataURL('image/png') | |
let link = document.createElement('a'); | |
link.href = img; | |
link.download = 'image.png'; | |
document.body.appendChild(link); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background: #fff; | |
color: #222; | |
} | |
@media (prefers-color-scheme: dark) { | |
body { | |
background: #222; | |
color: #efefef; | |
} | |
} |