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

@sarthakb009/context

v1.0.2

Published

Context

Readme

Context

A React component for displaying a list of context files or items with remove functionality, hover interactions, and customizable rendering. Perfect for file attachments, document lists, or context management UIs. Built with TypeScript.

Installation

npm install @sarthakb009/context

Peer Dependencies

Make sure you have these installed in your project:

npm install react react-dom lucide-react

Required versions:

  • react ^18.0.0
  • react-dom ^18.0.0
  • lucide-react ^0.294.0

Note: GSAP is optional. If you want GSAP animations, ensure GSAP is available globally.

Usage

Basic Example

import { Context } from '@sarthakb009/context';
import { FileText } from 'lucide-react';

function App() {
  const items = [
    {
      id: '1',
      name: 'document.pdf',
      type: 'PDF',
      size: '2.4 MB',
      icon: FileText,
    },
    {
      id: '2',
      name: 'spreadsheet.xlsx',
      type: 'XLSX',
      size: '1.2 MB',
    },
  ];

  return (
    <Context
      items={items}
      title="Context Files"
      onRemove={(index, item) => {
        console.log('Removed:', item);
      }}
    />
  );
}

Using files Prop (Alternative)

import { Context } from '@sarthakb009/context';

function App() {
  const files = [
    { name: 'file1.txt', type: 'TXT', size: '100 KB' },
    { name: 'file2.txt', type: 'TXT', size: '200 KB' },
  ];

  return (
    <Context
      files={files}
      title="Attached Files"
    />
  );
}

With Custom Renderers

import { Context } from '@sarthakb009/context';

function App() {
  const items = [
    { id: '1', name: 'Custom Item', type: 'CUSTOM', size: '1 MB' },
  ];

  return (
    <Context
      items={items}
      renderStep={(item, index) => (
        <div>Step {index + 1}</div>
      )}
      renderSection={(item, index) => (
        <div>
          <h3>{item.name}</h3>
          <p>Custom content for {item.type}</p>
        </div>
      )}
    />
  );
}

With Variants and Animations

import { Context } from '@sarthakb009/context';

function App() {
  return (
    <Context
      items={items}
      variant="bordered" // 'default' | 'flat' | 'bordered'
      animated="css" // 'gsap' | 'css' | false
      onToggle={(index, item) => {
        console.log('Toggled:', item);
      }}
    />
  );
}

Props

| Prop | Type | Default | Required | Description | |------|------|---------|----------|-------------| | items | ContextItem[] | undefined | No | List of files or items to display | | files | ContextItem[] | undefined | No | Alternate prop name for items (same as items) | | title | string | "Context Files" | No | Header title text | | variant | 'default' \| 'flat' \| 'bordered' | 'default' | No | Visual variant (affects borders/shadows) | | animated | 'gsap' \| 'css' \| false | 'css' | No | Animation type. GSAP requires global GSAP | | onRemove | (index: number, item: ContextItem) => void | undefined | No | Callback fired when remove button is clicked | | onToggle | (index: number, item: ContextItem) => void | undefined | No | Callback fired when item is clicked | | renderStep | (item: ContextItem, index: number) => React.ReactNode | undefined | No | Custom renderer for the icon/step area | | renderSection | (item: ContextItem, index: number) => React.ReactNode | undefined | No | Custom renderer for the content section | | classes | object | undefined | No | Custom CSS classes for root, header, item, iconBox, removeBtn | | className | string | "" | No | Additional CSS classes for container | | style | React.CSSProperties | undefined | No | Inline styles for container | | id | string | undefined | No | HTML id attribute |

ContextItem Type

interface ContextItem {
  id?: string;
  name: string;
  type: string;
  size: string;
  icon?: LucideIcon;
  [key: string]: any; // Allows additional properties
}

Features

  • File Display: Clean list of files with icons and metadata
  • Remove Functionality: Remove items with callback support
  • Custom Rendering: Full control over item rendering
  • Hover Interactions: Actions appear on hover
  • Animations: CSS or GSAP-powered entrance animations
  • Variants: Multiple visual styles
  • TypeScript: Full TypeScript support with exported types
  • Accessible: Proper ARIA labels and semantic HTML

TypeScript

The component is written in TypeScript and exports all types:

import { Context, ContextProps, ContextItem, AnimationType } from '@sarthakb009/context';

const item: ContextItem = {
  name: 'file.pdf',
  type: 'PDF',
  size: '1 MB',
};

const props: ContextProps = {
  items: [item],
  variant: 'default',
  animated: 'css' as AnimationType,
};

License

MIT