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/confirmation

v1.0.7

Published

Confirmation

Readme

Confirmation

A flexible, accessible React modal component for confirmation dialogs with multiple variants, custom styling, and async action support. Built with TypeScript and no external dependencies (except React and Lucide icons).

Installation

npm install @sarthakb009/confirmation

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

Usage

Basic Example

import { ConfirmationModal } from '@sarthakb009/confirmation';
import { useState } from 'react';

function App() {
  const [isOpen, setIsOpen] = useState(false);

  return (
    <>
      <button onClick={() => setIsOpen(true)}>Open Modal</button>
      
      <ConfirmationModal
        isOpen={isOpen}
        onClose={() => setIsOpen(false)}
        onConfirm={() => {
          console.log('Confirmed!');
          setIsOpen(false);
        }}
        title="Are you sure?"
        description="This action cannot be undone."
      />
    </>
  );
}

With Variants

import { ConfirmationModal } from '@sarthakb009/confirmation';

function App() {
  return (
    <ConfirmationModal
      isOpen={true}
      onClose={() => {}}
      onConfirm={async () => {
        // Async operation
        await deleteItem();
      }}
      variant="danger" // 'danger' | 'primary' | 'success' | 'neutral'
      title="Delete Item"
      description="This will permanently delete the item."
      confirmText="Delete"
      cancelText="Cancel"
    />
  );
}

With Loading State

import { ConfirmationModal } from '@sarthakb009/confirmation';
import { useState } from 'react';

function App() {
  const [isLoading, setIsLoading] = useState(false);

  const handleConfirm = async () => {
    setIsLoading(true);
    try {
      await performAction();
    } finally {
      setIsLoading(false);
    }
  };

  return (
    <ConfirmationModal
      isOpen={true}
      onClose={() => {}}
      onConfirm={handleConfirm}
      isLoading={isLoading}
      variant="primary"
    />
  );
}

Custom Styling

import { ConfirmationModal } from '@sarthakb009/confirmation';

function App() {
  return (
    <ConfirmationModal
      isOpen={true}
      onClose={() => {}}
      onConfirm={() => {}}
      width="500px"
      borderRadius="16px"
      primaryColor="#ff6b6b"
      backgroundColor="#ffffff"
      textColor="#333333"
    />
  );
}

Custom Icon

import { ConfirmationModal } from '@sarthakb009/confirmation';
import { AlertTriangle } from 'lucide-react';

function App() {
  return (
    <ConfirmationModal
      isOpen={true}
      onClose={() => {}}
      onConfirm={() => {}}
      icon={<AlertTriangle size={24} color="#ef4444" />}
    />
  );
}

Props

| Prop | Type | Default | Required | Description | |------|------|---------|----------|-------------| | isOpen | boolean | - | Yes | Controls modal visibility | | onClose | () => void | - | Yes | Callback fired when modal is closed (X button, overlay, or Escape key) | | onConfirm | () => void \| Promise<void> | - | Yes | Callback fired when confirm button is clicked. Can be async | | title | string | "Are you sure?" | No | Modal title text | | description | string | "This action cannot be undone." | No | Modal description text | | confirmText | string | "Confirm" | No | Text for confirm button | | cancelText | string | "Cancel" | No | Text for cancel button | | variant | 'danger' \| 'primary' \| 'success' \| 'neutral' | 'primary' | No | Visual variant (affects colors and icon) | | isLoading | boolean | false | No | Shows loading state on confirm button | | width | string | "400px" | No | Modal width | | borderRadius | string | "12px" | No | Border radius of modal | | fontFamily | string | "system-ui, -apple-system, sans-serif" | No | Font family | | primaryColor | string | undefined | No | Override primary/confirm button color | | cancelColor | string | "#374151" | No | Cancel button text color | | backgroundColor | string | "#ffffff" | No | Modal background color | | textColor | string | "#111827" | No | Text color | | icon | React.ReactNode | undefined | No | Custom icon (overrides variant icon) |

Features

  • Multiple Variants: Danger, primary, success, and neutral styles
  • Async Support: Handles async confirm actions
  • Loading States: Built-in loading indicator
  • Keyboard Support: Escape key to close
  • Click Outside: Click overlay to close
  • Customizable: Full control over colors, sizes, and icons
  • TypeScript: Full TypeScript support with exported types
  • Accessible: Proper ARIA labels and focus management
  • Body Scroll Lock: Prevents background scrolling when open

TypeScript

The component is written in TypeScript and exports all types:

import { ConfirmationModal, ConfirmationModalProps } from '@sarthakb009/confirmation';

const props: ConfirmationModalProps = {
  isOpen: true,
  onClose: () => {},
  onConfirm: async () => {},
  variant: "danger",
};

License

MIT