Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

material-ui-confirm

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

material-ui-confirm

Higher order component for straightforward use of @material-ui/core confirmation dialogs.

  • 2.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
47K
decreased by-0.73%
Maintainers
1
Weekly downloads
 
Created
Source

Material-UI confirm GitHub license npm version Build Status Coverage Status

Confirming user choice is a good thing to do, it should also be easy to do.

This package provides simple confirmation dialogs built on top of @material-ui/core and straightforward to use thanks to React Hooks.

Installation

npm install --save material-ui-confirm

Demo

Edit material-ui-confirm demo

Usage

Wrap your app inside the ConfirmProvider component.
Note: If you're using Material UI ThemeProvider, make sure ConfirmProvider is a child of it.

import React from 'react';
import { ConfirmProvider } from 'material-ui-confirm';

const App = () => {
  return (
    <ConfirmProvider>
      {/* ... */}
    </ConfirmProvider>
  );
};

export default App;

Call the useConfirm hook wherever you need the confirm function.

import React from 'react';
import Button from '@material-ui/core/Button';
import { useConfirm } from 'material-ui-confirm';

const Item = () => {
  const confirm = useConfirm();

  const handleClick = () => {
    confirm({ description: 'This action is permanent!' })
      .then(() => { /* ... */ });
  };

  return (
    <Button onClick={handleClick}>
      Click
    </Button>
  );
};

export default Item;

API

ConfirmProvider

This component is required in order to render a dialog in the component tree.

Props:
NameTypeDefaultDescription
defaultOptionsobject{}Overrides the default options used by confirm.
useConfirm() => confirm

This hook returns the confirm function.

confirm([options]) => Promise

Thi function opens a confirmation dialog and returns a promise representing the user choice (resolved on confirmation and rejected otherwise).

Options:
NameTypeDefaultDescription
titlestring'Are you sure?'Dialog title.
descriptionstring''Dialog content.
confirmationTextstring'Ok'Confirmation button caption.
cancellationTextstring'Cancel'Cancellation button caption.
dialogPropsobject{}Material-UI Dialog props.
confirmationButtonPropsobject{}Material-UI Button props for the confirmation button.
cancellationButtonPropsobject{}Material-UI Button props for the cancellation button.

Keywords

FAQs

Package last updated on 30 Jan 2020

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc