npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-attachment-kit

v0.1.3

Published

A complete React component kit for handling file attachments with specialized viewers for images, videos, PDFs, and documents.

Readme

react-attachment-kit

A complete React component kit for handling file attachments. react-attachment-kit provides both a clean, collapsible card layout to display your file list and a powerful, interactive modal to preview them.

Check out the live demo here.

It features specialized viewers for different file types:

  • Interactive Image Viewer: Zoom up to 200%, pan, and drag to explore high-resolution images
  • Advanced Video Player: Custom controls with seek, playback speed, and YouTube-style ambient mode blur effect
  • Integrated PDF Viewer: Navigate through multi-page documents with built-in page controls
  • Graceful Fallback: Clean unsupported file screen for documents and other file types

Installation

Install the package along with its peer dependencies:

npm install react-attachment-kit react-pdf media-chrome

Requirements:

  • React 18.3.1 or higher
  • No Tailwind CSS installation required (styles are included)

Usage

Import the component and its styles:

import Attachments from 'react-attachment-kit';
import 'react-attachment-kit/dist/style.css';

function App() {
  const files = [
    {
      id: '1',
      name: 'vacation-photo.jpg',
      type: 'image/jpeg',
      url: 'https://example.com/photo.jpg',
    },
    {
      id: '2',
      name: 'presentation.pdf',
      type: 'application/pdf',
      url: 'https://example.com/presentation.pdf',
    },
  ];

  return <Attachments files={files} collapsible />;
}

Important: Make sure to import the CSS file ('react-attachment-kit/dist/style.css') for the component to display correctly.

Props

files (required)

Array of file objects to display. Each file must have:

  • id (string): Unique identifier
  • name (string): Display name of the file
  • type (string): MIME type (e.g., 'image/png', 'video/mp4', 'application/pdf')
  • url (string): URL to access the file

collapsible (optional)

Boolean to enable collapsible attachment section. Defaults to false.

handleDownload (optional)

Custom download handler function. If not provided, files download directly from their URL.

const customDownload = (file) => {
  // Your custom download logic
  console.log('Downloading:', file.name);
};

<Attachments files={files} handleDownload={customDownload} />;

Features

Image Preview

  • Click to open full-screen modal
  • Click again to zoom in (up to 200%)
  • Drag to pan when zoomed
  • Zoom controls in bottom-left corner
  • Blurred background for visual depth

Video Preview

  • Auto-play on open
  • Custom media controls
  • Seek forward/backward 10 seconds
  • Playback speed adjustment
  • Volume control
  • Real-time canvas blur effect synced with video

PDF Preview

  • Scrollable multi-page view with thumbnail sidebar
  • Click thumbnails to jump to specific pages
  • Password-protected PDF support with built-in prompt
  • Loading states for large documents

Navigation

  • Arrow buttons to move between files
  • ESC to close (via dialog)

Download

  • Hover over file cards to reveal download button
  • Download button in preview modal header
  • Custom download handlers supported

Supported File Types

  • Images: JPEG, PNG, GIF, WebP, and other browser-supported formats
  • Videos: MP4, WebM, and other HTML5 video formats
  • Audio: MP3, WAV, and other HTML5 audio formats (with waveform visualizer)
  • PDFs: Full PDF viewing support
  • Documents: Word (.doc, .docx), Excel (.xls, .xlsx), CSV, HTML, ZIP, JSON (shows file icon and download option)

Styling

Built with Tailwind CSS and Radix UI. All styles are self-contained and scoped to avoid conflicts with your application's styles.

Key Features:

  • ✅ No Tailwind CSS installation required in your project
  • ✅ All CSS variables are prefixed with rak- to prevent conflicts
  • ✅ Styles are scoped to .attachment-preview class
  • ✅ Works with any CSS framework or styling solution
  • ✅ Dark theme by default (light theme support coming soon)

Customization: If you need to customize the appearance, you can override the CSS variables:

.attachment-preview {
  --rak-radius: 0.5rem; /* Border radius */
  --rak-background: #000; /* Background color */
  --rak-foreground: #fff; /* Text color */
  --rak-primary: #fff; /* Primary color */
  /* ... and more */
}

License

MIT