lara-light-indigo

ConfirmPopup

ConfirmPopup displays a confirmation overlay displayed relatively to its target.

Basic
Using ConfirmPopup tag
Import via Module

import { ConfirmPopup } from 'primereact/confirmpopup'; // To use <ConfirmPopup> tag
import { confirmPopup } from 'primereact/confirmpopup'; // To use confirmPopup method
 
Import via CDN

<script src="https://unpkg.com/primereact/core/core.min.js"></script>
<script src="https://unpkg.com/primereact/confirmpopup/confirmpopup.min.js"></script>
 
Getting Started

There are two ways to display confirm popup. One of them is to use the confirmPopup method and the other is to use the <ConfirmPopup> tag. These independently create popup element. It supports the same properties in both. target property is mandatory to align the popup to its caller.

1. confirmPopup method

const confirm = (event) => {
    confirmPopup({
        target: event.currentTarget,
        message: 'Are you sure you want to proceed?',
        icon: 'pi pi-exclamation-triangle',
        accept: () => acceptFunc(),
        reject: () => rejectFunc()
    });
}

<Button onClick={confirm} icon="pi pi-check" label="Confirm"></Button>
 

The confirmPopup method returns an object incudes hide and show methods. The component can be shown or hidden by using this object at any time.


const confirm = (event) => {
    const myConfirm = confirmPopup({
        target: event.currentTarget,
        message: 'Are you sure you want to proceed?',
        icon: 'pi pi-exclamation-triangle',
        accept: () => acceptFunc(),
        reject: () => rejectFunc()
    });

    setTimeout(() => {
        myConfirm.hide();

        setTimeout(() => {
            myConfirm.show();
        }, 1000);
    }, 500);
}

<Button onClick={confirm} icon="pi pi-check" label="Confirm"></Button>
<ConfirmPopup /> <!--required empty popup tag -->
 
2. <ConfirmPopup> tag

ConfirmPopup is used as a container and visibility is managed with visible property where onHide event is required to update the visibility state.


<ConfirmPopup target={document.getElementById('button')} visible={visible} onHide={() => setVisible(false)} message="Are you sure you want to proceed?"
    icon="pi pi-exclamation-triangle" accept={accept} reject={reject} />

<Button id="button onClick={() => setVisible(true)} icon="pi pi-check" label="Confirm" />
 
Properties
NameTypeDefaultDescription
targetDomElementnullElement to align the overlay. (Required)
visiblebooleanfalseSpecifies the visibility of the confirm popup.
messagestringnullMessage of the confirmation.
iconstringnullIcon to display next to the message.
acceptLabelstringYesLabel of the accept button.
rejectLabelstringNoLabel of the reject button.
acceptIconstringnullIcon of the accept button.
rejectIconstringnullIcon of the reject button.
acceptClassNamestringnullStyle class of the accept button.
rejectClassNamestringnullStyle class of the reject button.
dismissablebooleantrueEnables to hide the popup when outside is clicked.
footeranynullFooter content of the confirm popup.
appendToDOM element | stringdocument.bodyDOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located.
stylestringnullInline style of the element.
classNamestringnullStyle class of the element.
transitionOptionsobjectnullThe properties of CSSTransition can be customized, except for "nodeRef" and "in" properties.
Events
NameParametersDescription
acceptnullCallback to execute when action is confirmed.
rejectnullCallback to execute when action is rejected.
onHideresult: Indicates with which selection the popup was closed.
Valid values are 'accept', 'reject' and undefined (outside click).
Callback to invoke when confirm popup is hidden.
onShow-Callback to invoke when overlay panel becomes visible.
Styling

Following is the list of structural style classes, for theming classes visit theming page.

NameElement
p-confirm-popupContainer element.
p-confirm-contentContent element.
p-confirm-popup-iconMessage icon.
p-confirm-popup-messageMessage text.
p-confirm-popup-footerFooter element for buttons.
Accessibility

This section is under development. After the necessary tests and improvements are made, it will be shared with the users as soon as possible.

Dependencies

None.

Component Scale

Input Style

Ripple Effect

Free Themes

Built-in component themes created by the PrimeReact Theme Designer.

Bootstrap
Blue
Purple
Blue
Purple
Material Design
Indigo
Deep Purple
Indigo
Deep Purple
Material Design Compact
Indigo
Deep Purple
Indigo
Deep Purple
Tailwind
Tailwind Light
Fluent UI
Blue
PrimeOne Design - 2022 NEW
Lara Indigo
Lara Blue
Lara Purple
Lara Teal
Lara Indigo
Lara Blue
Lara Purple
Lara Teal
PrimeOne Design - 2021
Saga Blue
Saga Green
Saga Orange
Saga Purple
Vela Blue
Vela Green
Vela Orange
Vela Purple
Arya Blue
Arya Green
Arya Orange
Arya Purple
Premium Themes

Premium themes are only available exclusively for PrimeReact Theme Designer subscribers and therefore not included in PrimeReact core.

Soho Light
Soho Dark
Viva Light
Viva Dark
Mira
Nano

Legacy Free Themes

Nova
Nova Alt
Nova Accent
Luna Blue
Luna Green
Luna Amber
Luna Pink
Rhea

Premium Create-React-App Templates

Beautifully crafted premium create-react-app application templates by the PrimeTek design team.

Sakai
Atlantis
Freya
Ultima
Diamond
Sapphire
Serenity
Babylon
Avalon
Apollo
Roma