snapdom
A high-performance library for capturing styled HTML elements as images.
Install
mkdir -p .claude/skills/snapdom && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/6254" && unzip -o skill.zip -d .claude/skills/snapdom && rm skill.zipInstalls to .claude/skills/snapdom
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
snapDOM is a fast, accurate DOM-to-image capture tool that converts HTML elements into scalable SVG images. Use for capturing HTML elements, converting DOM to images (SVG, PNG, JPG, WebP), preserving styles, fonts, and pseudo-elements.Key capabilities
- →Captures DOM nodes into SVG, PNG, JPG, or WebP
- →Handles CSS pseudo-elements and counters
- →Embeds fonts and icons directly into output
- →Calculates bounding boxes for selective element clipping
- →Proxies CORS-restricted assets
How it works
It iterates through element styles and child nodes to reconstruct the element on a virtual canvas for export.
Inputs & outputs
When to use snapdom
- →Converting UI components to images
- →Generating thumbnails from HTML
- →Capturing styled DOM elements
About this skill
SnapDOM Skill
Fast, dependency-free DOM-to-image capture library for converting HTML elements into scalable SVG or raster image formats.
When to Use This Skill
Use SnapDOM when you need to:
- Convert HTML elements to images (SVG, PNG, JPG, WebP)
- Capture styled DOM with pseudo-elements and shadows
- Export elements with embedded fonts and icons
- Create screenshots with custom dimensions or scaling
- Handle CORS-blocked resources using proxy fallback
- Implement custom rendering pipelines with plugins
- Optimize performance on large or complex elements
Key Features
Universal Export Options
- SVG - Scalable vector format, embeds all styles
- PNG, JPG, WebP - Raster formats with configurable quality
- Canvas - Get raw Canvas element for further processing
- Blob - Raw binary data for custom handling
Performance
- Ultra-fast capture (1.6ms for small elements, ~171ms for 4000×2000)
- No dependencies - Uses standard Web APIs only
- Outperforms html2canvas by 10-40x on complex elements
Style Support
- Embedded fonts (including icon fonts)
- CSS pseudo-elements (::before, ::after)
- CSS counters
- CSS line-clamp
- Transform and shadow effects
- Shadow DOM content
Advanced Capabilities
- Same-origin iframe support
- CORS proxy fallback for blocked assets
- Plugin system for custom transformations
- Straighten transforms (remove rotate/translate)
- Selective element exclusion
- Tight bounding box calculation
Installation
NPM/Yarn
npm install @zumer/snapdom
# or
yarn add @zumer/snapdom
CDN (ES Module)
<script type="module">
import { snapdom } from "https://unpkg.com/@zumer/snapdom/dist/snapdom.mjs";
</script>
CDN (UMD)
<script src="https://unpkg.com/@zumer/snapdom/dist/snapdom.umd.js"></script>
Quick Start Examples
Basic Reusable Capture
// Create reusable capture object
const result = await snapdom(document.querySelector('#target'));
// Export to different formats
const png = await result.toPng();
const jpg = await result.toJpg();
const svg = await result.toSvg();
const canvas = await result.toCanvas();
const blob = await result.toBlob();
// Use the result
document.body.appendChild(png);
One-Step Export
// Direct export without intermediate object
const png = await snapdom.toPng(document.querySelector('#target'));
const svg = await snapdom.toSvg(element);
Download Element
// Automatically download as file
await snapdom.download(element, 'screenshot.png');
await snapdom.download(element, 'image.svg');
With Options
const result = await snapdom(element, {
scale: 2, // 2x resolution
width: 800, // Custom width
height: 600, // Custom height
embedFonts: true, // Include @font-face
exclude: '.no-capture', // Hide elements
useProxy: true, // Enable CORS proxy
straighten: true, // Remove transforms
noShadows: false // Keep shadows
});
const png = await result.toPng({ quality: 0.95 });
Essential Options Reference
| Option | Type | Purpose |
|---|---|---|
scale | Number | Scale output (e.g., 2 for 2x resolution) |
width | Number | Custom output width in pixels |
height | Number | Custom output height in pixels |
embedFonts | Boolean | Include non-icon @font-face rules |
useProxy | String|Boolean | Enable CORS proxy (URL or true for default) |
exclude | String | CSS selector for elements to hide |
straighten | Boolean | Remove translate/rotate transforms |
noShadows | Boolean | Strip shadow effects |
Common Patterns
Responsive Screenshots
// Capture at different scales
const mobile = await snapdom.toPng(element, { scale: 1 });
const tablet = await snapdom.toPng(element, { scale: 1.5 });
const desktop = await snapdom.toPng(element, { scale: 2 });
Exclude Elements
// Hide specific elements from capture
const png = await snapdom.toPng(element, {
exclude: '.controls, .watermark, [data-no-capture]'
});
Fixed Dimensions
// Capture with specific size
const result = await snapdom(element, {
width: 1200,
height: 630 // Standard social media size
});
CORS Handling
// Fallback for CORS-blocked resources
const png = await snapdom.toPng(element, {
useProxy: 'https://cors.example.com/?' // Custom proxy
});
Plugin System (Beta)
// Extend with custom exporters
snapdom.plugins([pluginFactory, { colorOverlay: true }]);
// Hook into lifecycle
defineExports(context) {
return {
pdf: async (ctx, opts) => { /* generate PDF */ }
};
}
// Lifecycle hooks available:
// beforeSnap → beforeClone → afterClone →
// beforeRender → beforeExport → afterExport
Performance Comparison
SnapDOM significantly outperforms html2canvas:
| Scenario | SnapDOM | html2canvas | Improvement |
|---|---|---|---|
| Small (200×100) | 1.6ms | 68ms | 42x faster |
| Medium (800×600) | 12ms | 280ms | 23x faster |
| Large (4000×2000) | 171ms | 1,800ms | 10x faster |
Development
Setup
git clone https://github.com/zumerlab/snapdom.git
cd snapdom
npm install
Build
npm run compile
Testing
npm test
Browser Support
- Chrome/Edge 90+
- Firefox 88+
- Safari 14+
- Mobile browsers (iOS Safari 14+, Chrome Mobile)
Resources
Documentation
- Official Website: https://snapdom.dev/
- GitHub Repository: https://github.com/zumerlab/snapdom
- NPM Package: https://www.npmjs.com/package/@zumer/snapdom
- License: MIT
scripts/
Add helper scripts here for automation, e.g.:
batch-screenshot.js- Capture multiple elementspdf-export.js- Convert snapshots to PDFcompare-outputs.js- Compare SVG vs PNG quality
assets/
Add templates and examples:
- HTML templates for common capture scenarios
- CSS frameworks pre-configured with snapdom
- Boilerplate projects integrating snapdom
Related Tools
- html2canvas - Alternative DOM capture (slower but more compatible)
- Orbit CSS Toolkit - Companion toolkit by Zumerlab (https://github.com/zumerlab/orbit)
Tips & Best Practices
- Performance: Use
scaleinstead ofwidth/heightfor better performance - Fonts: Set
embedFonts: trueto ensure custom fonts appear correctly - CORS Issues: Use
useProxy: trueif images fail to load - Large Elements: Break into smaller chunks for complex pages
- Quality: For PNG/JPG, use
quality: 0.95for best quality - SVG Vectors: Prefer SVG export for charts and graphics
Troubleshooting
Elements Not Rendering
- Check if element has sufficient height/width
- Verify CSS is fully loaded before capture
- Try
straighten: falseif transforms are causing issues
Missing Fonts
- Set
embedFonts: true - Ensure fonts are loaded before calling snapdom
- Check browser console for font loading errors
CORS Issues
- Enable
useProxy: true - Use custom proxy URL if default fails
- Check if resources are from same origin
Performance Issues
- Reduce
scalevalue - Use
noShadows: trueto skip shadow rendering - Consider splitting large captures into smaller sections
When not to use it
- →Capturing server-side generated content without a DOM
- →Elements that strictly forbid script injection
Prerequisites
Limitations
- →May struggle with complex cross-domain iframe rendering
- →Large elements require memory overhead
How it compares
It eliminates third-party dependencies and performs significantly faster than standard html2canvas implementations.
Compared to similar skills
snapdom side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| snapdom (this skill) | 1 | 7mo | Review | Intermediate |
| scroll-experience | 101 | 6mo | No flags | Intermediate |
| anthropic-frontend-design | 12 | 6mo | No flags | Intermediate |
| threejs-postprocessing | 1 | 6mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by 2025Emma
View all by 2025Emma →You might also like
scroll-experience
davila7
Expert in building immersive scroll-driven experiences - parallax storytelling, scroll animations, interactive narratives, and cinematic web experiences. Like NY Times interactives, Apple product pages, and award-winning web experiences. Makes websites feel like experiences, not just pages. Use when: scroll animation, parallax, scroll storytelling, interactive story, cinematic website.
anthropic-frontend-design
chaibuilder
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.
threejs-postprocessing
CloudAI-X
Three.js post-processing - EffectComposer, bloom, DOF, screen effects. Use when adding visual effects, color grading, blur, glow, or creating custom screen-space shaders.
frontend-ui-engineering
charlieviettq
Build and refine web UI—component structure, responsive layout, design tokens, state, and accessibility. Use for feature UI work beyond WCAG checks alone.
dile-components
Polydile
Use when building or modifying UI with the Dile Components library (@dile/ui, @dile/crud, @dile/editor, @dile/utils, @dile/lib, @dile/iconlib, @dile/icons) — a framework-agnostic, Lit-based web component catalog. Trigger when installing/importing dile-* custom elements, using tags like <dile-input>,
threejs-shaders
CloudAI-X
Three.js shaders - GLSL, ShaderMaterial, uniforms, custom effects. Use when creating custom visual effects, modifying vertices, writing fragment shaders, or extending built-in materials.