Convert DOM nodes to SVG
mainUse dom-to-svg to convert an entire HTML document or a specific DOM element into an accessible SVG representation. This is useful for creating high-quality SVG 'screenshots' that work in design tools like Figma or Illustrator because the library avoids using <foreignObject>.
import { documentToSVG, elementToSVG } from 'dom-to-svg'
// Capture the whole document
const svgDocument = documentToSVG(document)
// Capture a specific element
const svgElement = elementToSVG(document.querySelector('#my-element'))