search results:

    • Standard
    • React
    Pricing Learn Community
    • + D
    • Light
    • Dark
    • System
    logo TW Elements
    • Getting started
      • Quick start
      • Tutorials
      • Design system
      • Local installation
      • Optimization
      • Dark mode
      • Theming
      • Changelog
      • Migrating to v2
      • Internationalization guide
      • Class customization
      • Icons Integration
    • CommercialNew
      • Pricing
      • License
      • Installation
      • Git & repository
      • Premium Support
    • Integrations
      • Angular
      • ASP.NET
      • Django
      • Express
      • Laravel
      • Next
      • Nuxt
      • Qwik
      • React
      • Remix
      • Solid
      • Svelte
      • SvelteKit
      • Vue
    • Content & styles
      • Animations
      • Animations Extended
      • Colors
      • Dividers
      • Figures
      • Headings
      • Hover effects
      • Icons
      • Images
      • Mask
      • Shadows
      • Typography
    • Navigation
      • Breadcrumbs
      • Footer
      • Headers
      • Mega menu
      • Navbar
      • Offcanvas
      • Pagination
      • Pills
      • Scrollspy
      • Sidenav
      • Tabs
    • Components
      • Accordion
      • Alerts
      • Avatar
      • Badges
      • Button group
      • Buttons
      • Cards
      • Carousel
      • Chips
      • Collapse
      • Dropdown
      • Gallery
      • Jumbotron
      • Lightbox
      • Link
      • List group
      • Modal
      • Notifications
      • Paragraphs
      • Placeholders
      • Popconfirm
      • Popover
      • Progress
      • Rating
      • Scroll back to top button
      • Social buttons
      • Spinners
      • Stepper
      • Testimonials
      • Timeline
      • Toast
      • Tooltip
      • Video
      • Video carousel
    • Forms
      • Autocomplete
      • Checkbox
      • Datepicker
      • Datetimepicker
      • File input
      • Form templates
      • Input Group
      • Inputs
      • Login form
      • Multi range slider
      • Radio
      • Range
      • Registration form
      • Search
      • Select
      • Switch
      • Textarea
      • Timepicker
      • Validation
    • Data
      • Charts
      • Charts advanced
      • Datatables
      • Tables
    • Methods
      • Clipboard
      • Infinite scroll
      • Lazy loading
      • Loading management
      • Ripple
      • Scrollbar
      • Smooth scroll
      • Sticky
      • Touch
    • Design Blocks
      • Admin Charts
      • Admin Complex
      • Admin Forms
      • Admin Maps
      • Admin Navigation
      • Admin tables
      • Banners
      • Contact
      • Content
      • CTA
      • FAQ
      • Features
      • Headers
      • Hero / Intro sections
      • Logo clouds
      • Mega menu
      • News
      • Newsletter
      • Pricing
      • Projects
      • Stats
      • Stats admin
      • Team
      • Testimonials
    • Tools
      • Button generator
      • Card generator
      • Flexbox generator
      • Footer generator
      • Form builder
      • Grid generator
      • Icon generator
      • Instagram Filters generator
      • Logo generator
      • Table generator
      • Typography generator
    • Coming Soon
      • Angular
      • Builder
      • Templates
      • Vue
    • Resources
      • Playground
      • YouTube Channel
      • Private FB Group
      • Newsletter
      • UI Design course New
      • UI / UX tips
    • Overview
    • API

    Popconfirm

    Tailwind CSS Popconfirm

    Responsive popconfirm built with the latest Tailwind CSS. Popconfirm is a compact dialog alert. Use it to confirm/cancel a decision or display extra content like an explanation.

    Required ES init: Popconfirm *
    * UMD autoinits are enabled by default. This means that you don't need to initialize the component manually. However if you are using TW Elements ES format then you should pass the required components to the initTWE method.

    Basic example

    Basic example of popconfirm usage

    • HTML
    • javascript
            
                
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="light"
            data-twe-toggle="popconfirm"
            data-twe-message="This is example"
            class="inline-block rounded bg-primary px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Default
          </button>
          
            
        
            
                
          // Initialization for ES Users
          import {
            Popconfirm,
            initTWE,
          } from "tw-elements";
          
          initTWE({ Popconfirm });
          
            
        

    Hey there 👋 we're excited about TW elements and want to see it grow! If you enjoy it, help the project grow by sharing it with your peers. Every share counts, thank you!

    Display mode

    You can choose between modal and inline to modify display mode.

    • HTML
    • javascript
            
                
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="light"
            data-twe-toggle="popconfirm"
            data-twe-popconfirm-mode="modal"
            class="inline-block rounded bg-primary px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Modal
          </button>
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="light"
            data-twe-toggle="popconfirm"
            data-twe-popconfirm-mode="inline"
            class="inline-block rounded bg-primary px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Inline
          </button>
          
            
        
            
                
            // Initialization for ES Users
            import {
              Popconfirm,
              initTWE,
            } from "tw-elements";
            
            initTWE({ Popconfirm });
            
            
        

    Icon example

    To apply icon to message you need to use popconfirmIconTemplate option.

    • HTML
    • javascript
    • umd
            
                
          <button
            type="button"
            id="icon-example"
            data-twe-ripple-init
            data-twe-ripple-color="light"
            data-twe-popconfirm-mode="inline"
            data-twe-message="Icon example"
            class="inline-block rounded bg-primary px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Icon
          </button>
          
            
        
            
                
          // Initialization for ES Users
          import { Popconfirm } from "tw-elements";
                
          const iconExample = document.getElementById("icon-example");
          new Popconfirm(iconExample, {
            popconfirmIconTemplate: `<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
              <path stroke-linecap="round" stroke-linejoin="round" d="M12 20.25c4.97 0 9-3.694 9-8.25s-4.03-8.25-9-8.25S3 7.444 3 12c0 2.104.859 4.023 2.273 5.48.432.447.74 1.04.586 1.641a4.483 4.483 0 01-.923 1.785A5.969 5.969 0 006 21c1.282 0 2.47-.402 3.445-1.087.81.22 1.668.337 2.555.337z" />
            </svg>
            `,
          });
          
            
        
            
                
          const iconExample = document.getElementById("icon-example");
          new twe.Popconfirm(iconExample, {
            popconfirmIconTemplate: `<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
              <path stroke-linecap="round" stroke-linejoin="round" d="M12 20.25c4.97 0 9-3.694 9-8.25s-4.03-8.25-9-8.25S3 7.444 3 12c0 2.104.859 4.023 2.273 5.48.432.447.74 1.04.586 1.641a4.483 4.483 0 01-.923 1.785A5.969 5.969 0 006 21c1.282 0 2.47-.402 3.445-1.087.81.22 1.668.337 2.555.337z" />
            </svg>
            `,
          });
          
            
        

    Inline positions

    You can choose between different positions.

    Available positions: top left; top; top right; right top; right; right bottom; bottom right; bottom; bottom left; left bottom; left; left top;

    • HTML
    • javascript
            
                
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="light"
            data-twe-toggle="popconfirm"
            data-twe-position="top left"
            class="inline-block rounded bg-primary px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Top left
          </button>
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="light"
            data-twe-toggle="popconfirm"
            data-twe-position="top"
            class="inline-block rounded bg-primary px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Top
          </button>
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="light"
            data-twe-toggle="popconfirm"
            data-twe-position="top right"
            class="inline-block rounded bg-primary px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Top right
          </button>
          
            
        
            
                
          // Initialization for ES Users
          import {
            Popconfirm,
            initTWE,
          } from "tw-elements";
          
          initTWE({ Popconfirm });    
          
            
        

    Related resources

    Buttons Popovers Icons Modal Alerts Tooltips

    If you are looking for more advanced options, try Bootstrap Popconfirm from MDBootstrap.

    • Basic example
    • Display mode
    • Icon example
    • Inline positions
    • Related resources

    Popconfirm - API


    Import

    Importing components depends on how your application works. If you intend to use the TW elements ES format, you must first import the component and then initialize it with the initTWE method. If you are going to use the UMD format, just import the tw-elements package.

    • javascript
    • umd
            
                
            import { Popconfirm, initTWE } from "tw-elements";
            initTWE({ Popconfirm });
            
            
        
            
                
            import "tw-elements";
            
            
        

    Usage

    Via data attributes

    • HTML
            
                
            <button
              type="button"
              data-twe-ripple-init
              data-twe-ripple-color="light"
              data-twe-toggle="popconfirm"
              class="inline-block rounded bg-primary px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-white shadow-[0_4px_9px_-4px_#3b71ca] transition duration-150 ease-in-out hover:bg-primary-600 hover:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:bg-primary-600 focus:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:outline-none focus:ring-0 active:bg-primary-700 active:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] dark:shadow-[0_4px_9px_-4px_rgba(59,113,202,0.5)] dark:hover:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)] dark:focus:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)] dark:active:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)]">
              Default
            </button>
            
            
        

    Via JavaScript

    • javascript
    • umd
            
                
            const myPopconfirm = new Popconfirm(document.getElementById('popconfirm'), options, classes);
            
            
        
            
                
            const myPopconfirm = new twe.Popconfirm(document.getElementById('popconfirm'), options, classes);
            
            
        

    Options

    Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-twe-, as in data-twe-cancel-label="".

    Name Type Default Description
    cancelLabel String 'Cancel' Text rendered under cancel button for screen readers.
    cancelText String 'Cancel' Text of cancel button, if empty string - button doesn't render.
    confirmLabel String 'Confirm' Text rendered under confirm button for screen readers.
    message String 'Are you sure?' Message rendered in popconfirm.
    okText String 'OK' Text of confirm button. If empty string, the default value of the button will be set to 'OK'.
    popconfirmIconTemplate String `` Template of the icon in the popconfirm.
    popconfirmMode String 'inline' Mode of display -> 'inline' or 'modal'
    position String 'bottom' Sets position of the popconfirm element. Available positions: top left; top; top right; right top; right; right bottom; bottom right; bottom; bottom left; left bottom; left; left top;

    Classes

    Custom classes can be passed via data attributes or JavaScript. For data attributes, append the class name to data-twe-class, as in data-twe-class-backdrop="".

    Name Default Description
    backdrop h-full w-full z-[1070] fixed top-0 left-0 bg-black/40 flex justify-center items-center Backdrop element classes.
    body p-4 bg-white rounded-lg opacity-0 dark:bg-surface-dark Popconfirm body element classes.
    btnCancel inline-block rounded bg-primary-100 px-4 pb-[5px] pt-1.5 text-xs font-medium uppercase leading-normal text-primary-700 transition duration-150 ease-in-out hover:bg-primary-accent-200 focus:bg-primary-accent-200 focus:outline-none focus:ring-0 active:bg-primary-accent-200 dark:bg-primary-300 dark:hover:bg-primary-400 dark:focus:bg-primary-400 dark:active:bg-primary-400 Cancel button element classes.
    btnConfirm inline-block rounded bg-primary me-1 px-4 pb-[5px] pt-1.5 text-xs font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong Confirm button element classes.
    btnsContainer flex justify-end space-x-2 rtl:space-x-reverse Container of buttons element classes.
    fade transition-opacity duration-[150ms] ease-linear Fade animation classes for popconfirm element.
    icon pe-2 Popconfirm icon element classes.
    message flex mb-3 Popconfirm message wrapper classes.
    messageText text-neutral-600 dark:text-white Popconfirm message text classes.
    modal absolute w-[300px] z-[1080] shadow-md rounded-lg Modal element classes for popconfirm.
    popover w-[300px] border-0 rounded-lg z-[1080] shadow-md Popover element classes for popconfirm.

    Methods

    Method Description Example
    getInstance Static method which allows you to get the popconfirm instance associated with a DOM element. Popconfirm.getInstance(myPopconfirmEl)
    getOrCreateInstance Static method which returns the popconfirm instance associated to a DOM element or create a new one in case it wasn't initialized. Popconfirm.getOrCreateInstance(myPopconfirmEl)
    dispose Destroys an element's popconfirm. myPopconfirm.dispose()
    • javascript
    • umd
            
                
            const myPopconfirmEl = document.getElementById('myPopconfirm');
            const myPopconfirm = new Popconfirm(myPopconfirmEl);
            myPopconfirm.dispose();
            
            
        
            
                
            const myPopconfirmEl = document.getElementById('myPopconfirm');
            const myPopconfirm = new twe.Popconfirm(myPopconfirmEl);
            myPopconfirm.dispose();
            
            
        

    Events

    Event type Description
    cancel.twe.popconfirm This event fires immediately when the popconfirm is closed without confirm button click.
    confirm.twe.popconfirm This event fires immediately when the popconfirm is closed using confirm button.
    • JavaScript
            
                
            const myPopconfirm = document.getElementById('popconfirm');
            myPopconfirm.addEventListener('cancel.twe.popconfirm', (e) => {
              // do something...
            });
            
            
        
    • Import
    • Usage
    • Options
    • Classes
    • Methods
    • Events
    Get useful tips & free resources directly to your inbox along with exclusive subscriber-only content.
    Join our mailing list now
    © 2024 Copyright: MDBootstrap.com

    Access restricted

    To view this section you must have an active PRO account

    Log in to your account or purchase an TWE subscription if you don't have one.

    Buy TWE PRO