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

Stamp the capture with the time.

Adds a timestamp label. The clock or custom formatter runs for every capture.

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

Usage

import { snapdom } from '@zumer/snapdom';
import { timestampOverlay } from '@zumer/snapdom-plugins/timestamp-overlay';

const el = document.querySelector('#target');
const result = await snapdom(el, { plugins: [timestampOverlay({ position: 'top-right', format: 'date' })] });
const image = await result.toPng();
document.body.append(image);

Options

OptionTypeDefaultDescription
formatstring | function'datetime''datetime' | 'date' | 'time' | 'iso' | custom (Date) => string
positionstring'bottom-right''top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
backgroundstring'rgba(0,0,0,0.6)'Label background color
colorstring'#fff'Label text color
fontSizenumber11Font size in px
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.