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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-dialog-confirm

v1.0.3

Published

React Alert Modal Component Library, an open-source solution for displaying user alerts in a sleek and user-friendly manner.

Downloads

97

Readme

react-dialog-confirm

the simple modal react component

Build Status

react-dialog-confirm is a React component that provides a simple way to display confirmation dialogs in your application.

A flexible and customizable dialog/modal component for React. This component can be used to display various types of messages to users and allow them to confirm or cancel an action...

demo

Features

  • Easy to use and implement in React applications.
  • Supports two different button types for confirmation and cancellation.
  • Option to display an icon in the dialog box.
  • Ability to customize the icon color and size.
  • Callback function for handling confirmation actions.
  • Can be used to confirm actions before performing them.
  • Accessibility-friendly with keyboard navigation and screen reader support.
  • Compatible with both mobile and desktop devices.
  • Can be styled using CSS to match the overall look and feel of your application.

Installation

You can install react-dialog-confirm using npm:

npm install react-dialog-confirm

or

yarn add react-dialog-confirm

Usage

To use react-dialog-confirm, you need to import it into your React component:

import { DialogProvider } from 'react-dialog-confirm';

cover your App component

import {DialogProvider} from 'react-dialog-confirm';

export default function index() {
  return (
    <DialogProvider>
      <App />
    </DialogProvider>
  )
}

callback open modal function to open modal dialog.

import { DialogModal, useModal } from "react-dialog-confirm";
...
//in component
const { openModal } = useModal();

openModal(
  <DialogModal
    icon='success'
    title='Welcome'
    description={'welcome to react-dialog-confirm component'}
  />)
...

Props

Here are the available props for the DialogModal component:

| Prop | Type | Options | Default | Description | |------------|--------------|----------------------------------|-----------| ----------- | | icon | string | 'success','info,'warning','error | - | The icon to display in the dialog header. | | title | string | your message | - | The title of the confirmation dialog. | | titleStyle | style object | - | - | CSS styles to apply to the title | | description | string | - | - | The message to be displayed in the confirmation dialog.| | descriptionStyle | style object | - | - | CSS styles to apply to the description | | confirm | string | - | "OK" | The label for the confirm button. | | cancel | string | - | "Cancel" | The label for the cancel button. | | onConfirm | function | - | () => {} | The callback function that will be called when the user confirms the action. | | onCancel | function | - | () => {} | The callback function that will be called when the user cancels the action. | | hasCancel | boolean | - | false | Whether to display a cancel button |

Examples

Here are some examples of how you can use react-dialog-confirm in your React application:

_app.js

import {DialogProvider} from 'react-dialog-confirm';

export default function App({ Component, pageProps }) {
  return (
    <DialogProvider>
      <Component {...pageProps} />
    </DialogProvider>
  )
}

Mypage.js

import React from "react";
import { DialogModal, useModal } from "react-dialog-confirm";

const Mypage = () => {

    const openModal = useModal()?.openModal;

    const handleClick = () => {
        openModal(
        <DialogModal
        icon='success'
        title='Welcome'
        description={'welcome to react-dialog-confirm component'}
        />)
    }
    return(
        <div>
            <button onClick={handleClick}>Open modal</button>
        </div>
    )
}

export default Mypage;

License

This component is licensed under the MIT License.