lara-light-indigo

ConfirmDialog

ConfirmDialog uses a Dialog UI with confirmDialog method or <ConfirmDialog> tag.

Basic
Position
Using ConfirmDialog tag
Import via Module

import { ConfirmDialog } from 'primereact/confirmdialog'; // To use <ConfirmDialog> tag
import { confirmDialog } from 'primereact/confirmdialog'; // To use confirmDialog method
 
Import via CDN

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

There are two ways to display confirm dialog. One of them is to use the confirmDialog method and the other is to use the <ConfirmDialog> tag. These independently create dialog element. It supports the same properties in both.

1. confirmDialog method

const confirm = () => {
    confirmDialog({
        message: 'Are you sure you want to proceed?',
        header: 'Confirmation',
        icon: 'pi pi-exclamation-triangle',
        accept: () => acceptFunc(),
        reject: () => rejectFunc()
    });
}

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

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


<ConfirmDialog visible={visible} onHide={() => setVisible(false)} message="Are you sure you want to proceed?"
    header="Confirmation" icon="pi pi-exclamation-triangle" accept={accept} reject={reject} />

<Button onClick={() => setVisible(true)} icon="pi pi-check" label="Confirm" />
 
Responsive

ConfirmDialog width can be adjusted per screen size with the breakpoints option. In example below, default width is set to 50vw and below 961px, width would be 75vw and finally below 641px width becomes 100%. The value of breakpoints should be an object literal whose keys are the maximum screen sizes and values are the widths per screen.


<ConfirmDialog breakpoints={{'960px': '75vw', '640px': '100vw'}} style={{width: '50vw'}} ... />
 
Properties

These properties are extended from Dialog properties.

NameTypeDefaultDescription
visiblebooleanfalseSpecifies the visibility of the confirm dialog.
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.
footeranynullFooter content of the confirm dialog.
stylestringnullInline style of the element.
classNamestringnullStyle class of the element.
Events
NameParametersDescription
acceptnullCallback to execute when action is confirmed.
rejectnullCallback to execute when action is rejected.
onHideresult: Indicates with which selection the dialog was closed.
Valid values are 'accept', 'reject' and undefined (using close icon).
Callback to invoke when confirm dialog is hidden.
Styling

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

NameElement
p-confirm-dialogContainer element.
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