Inline Confirmation Button Component In Pure JavaScript

Category: Javascript | March 27, 2019
Views Total:1,736 views
Official Page:Go to website
Last Update:March 27, 2019


Inline Confirmation Button Component In Pure JavaScript


A pure JavaScript component which applies an inline confirmation experience to an action button you specify.

Clicking the action button to ask your users to confirm before performing an action.

See also:

How to use it:

Download and import the component:

<script type="module">
  import './mod.js';

The basic HTML markup.

  <span slot="confirm">Are you sure to delete it?</span>
  <button type="button" slot="content">Delete Me</button>

Enable the inline confirmation button.

let confirm = document.querySelector('inline-confirmation');
let btn = document.querySelector('button');
btn.addEventListener('click', () => { = true;

Do something as your users confirm or cancel the action.

confirm.addEventListener('confirm', () => {
  // do something
confirm.addEventListener('cancel', () => {
  // do something

You Might Be Interested In:

Leave a Reply