Skip to content
SnapDOMGitHub★ 8K
@zumer/snapdom-plugins · MIT

Apply a CSS filter to the capture.

Applies CSS filter effects to the clone, overriding authored filters. preset takes precedence over filter; an unknown preset logs a warning and filter applies.

npm install @zumer/snapdom@latest @zumer/snapdom-plugins@latest

Usage

import { snapdom } from '@zumer/snapdom';
import { filter } from '@zumer/snapdom-plugins/filter';

const el = document.querySelector('#target');
const result = await snapdom(el, { plugins: [filter({ preset: 'grayscale' })] });
const image = await result.toPng();
document.body.append(image);

Options

OptionTypeDefaultDescription
presetstringnone'grayscale' | 'sepia' | 'blur' | 'invert' | 'vintage' | 'dramatic'
filterstring''Raw CSS filter string, e.g. 'blur(2px) contrast(1.2)'
Try it here

Live element

Component preview
Capture an editable component
1,284+12% vs last week

Editable text and an open shadow root can be captured together.

Result

Nothing captured yet

Edit the title, then run. This uses the real library from unpkg.