Socket
Book a DemoInstallSign in
Socket

element-shot-components

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

element-shot-components

A lightweight component library for capturing HTML elements as screenshots

0.1.7
latest
npmnpm
Version published
Maintainers
1
Created
Source

element-shot

npm version License: MIT

A lightweight component library for capturing HTML elements as screenshots. Supports React and Vue.js.

日本語版 README はこちら

Shows a camera button on the bottom-right of target elements.

Capture result

Features

  • 📸 Capture any HTML element as a screenshot
  • 🎯 Simple and intuitive API
  • 🚀 Lightweight with minimal dependencies
  • ⚛️ React component support
  • 💚 Vue.js component support
  • 🎨 Customizable UI and behavior
  • 📱 Responsive and mobile-friendly
  • 🔧 TypeScript support

Installation

npm install element-shot-components
# or
yarn add element-shot-components
# or
pnpm add element-shot-components

Usage

React

import { ElementShot } from "element-shot-components/react";

function App() {
  return (
    <ElementShot
      action="download"
      title="Screenshot Title"
      caption="This will be included in the screenshot"
      align="center"
    >
      <div>
        <h1>Content to capture</h1>
        <p>This content will be captured when clicking the camera button</p>
      </div>
    </ElementShot>
  );
}

Vue.js

<template>
  <ElementShot
    action="download"
    title="Screenshot Title"
    caption="This will be included in the screenshot"
    align="center"
  >
    <div>
      <h1>Content to capture</h1>
      <p>This content will be captured when clicking the camera button</p>
    </div>
  </ElementShot>
</template>

<script setup>
  import { ElementShot } from "element-shot-components/vue";
</script>

Props

PropTypeDefaultDescription
action'download' | 'copy' | 'share' | 'preview''download'Action to perform with the screenshot
targetstring-CSS selector for preview target (required for 'preview' action)
titlestring-Title displayed above the content (included in screenshot)
captionstring-Caption displayed below the content (included in screenshot)
align'left' | 'center''left'Alignment of title and caption
basenamestring'element-shot-components'Base filename for downloaded images
defaultStylebooleantrueApply default styling to title and caption
cameraPosition'top-left' | 'top-right' | 'bottom-left' | 'bottom-right''top-right'Position of the camera button
cameraView'always' | 'hover' | 'none''hover'When to show the camera button
scalenumber1Scale factor for the screenshot
classNamestring-Additional CSS class for the container
styleobject-Additional inline styles for the container

React-specific Props

PropTypeDescription
onBeforeCapture() => voidCallback before capture starts
onAfterCapture(blob: Blob) => voidCallback after capture completes
onError(error: Error) => voidCallback when an error occurs

Vue.js-specific Events

EventPayloadDescription
beforeCapture-Emitted before capture starts
afterCaptureBlobEmitted after capture completes
errorErrorEmitted when an error occurs

Actions

  • download: Downloads the screenshot as a PNG file
  • copy: Copies the screenshot to clipboard (requires HTTPS)
  • share: Opens the native share dialog (requires HTTPS and browser support)
  • preview: Displays the screenshot in a specified <img> element

Examples

Download with Custom Filename

<ElementShot action="download" basename="my-screenshot">
  <div>Content</div>
</ElementShot>

Copy to Clipboard

<ElementShot action="copy" cameraView="always">
  <div>Content</div>
</ElementShot>

Preview in Image Element

<>
  <ElementShot action="preview" target="#preview-image">
    <div>Content</div>
  </ElementShot>

  <img id="preview-image" alt="Screenshot preview" />
</>

Custom Styling

<ElementShot
  className="my-custom-class"
  style={{ maxWidth: "600px" }}
  defaultStyle={false}
>
  <div>Content</div>
</ElementShot>

Browser Support

  • Chrome/Edge (latest)
  • Firefox (latest)
  • Safari (latest)
  • Mobile browsers with HTML5 Canvas support

Development

# Install dependencies
npm install

# Run development build
npm run dev

# Run tests
npm test

# Run React example
npm run example:react

# Run Vue example
npm run example:vue

# Build library
npm run build

License

MIT License - see LICENSE file for details

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  • Fork the repository
  • Create your feature branch (git checkout -b feature/amazing-feature)
  • Commit your changes (git commit -m 'Add some amazing feature')
  • Push to the branch (git push origin feature/amazing-feature)
  • Open a Pull Request

Acknowledgments

Keywords

screenshot

FAQs

Package last updated on 17 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.