Kinetic Modal

A dialog with its own trigger button, confirm and cancel actions, a focus trap and a scroll lock, that pops in with the chosen motion style.

  • <kt-kinetic-modal>
  • Overlays
  • No framework

Kinetic Modal

Your changes to "Q3 launch notes" have not been saved and will be lost.This sends 2.4.0 to everyone on the stable channel. You can roll back from the releases page.

The code

Copy the Kinetic Modal

Fastest: press Copy on the card above for one complete file. To build it into your own project, use the files below: the markup, the styles, this component’s script and the shared effects script (effects.js) that every component uses.

<kt-kinetic-modal title="Discard draft?" trigger="Discard draft" confirm-label="Discard" cancel-label="Keep editing">Your changes to "Q3 launch notes" have not been saved and will be lost.</kt-kinetic-modal>

<kt-kinetic-modal title="Publish release 2.4" trigger="Publish release" confirm-label="Publish" sfx="ドン!">This sends 2.4.0 to everyone on the stable channel. You can roll back from the releases page.</kt-kinetic-modal>

Attributes

NameWhat it doesDefault
titleDialog heading, also its accessible name.Dialog
triggerText of the button that opens the dialog. Set it empty to hide the button and use `open` from your code.Open dialog
openPresent while the dialog is open. Add or remove it to open and close.—
confirm-labelText of the confirm button.Confirm
cancel-labelText of the cancel button.Cancel
disabledDisables the trigger button.—
sfxSound-effect text shown when the dialog opens and on confirm.ドン!

Keyboard and screen readers

  • role="dialog" with aria-modal, named by its title and described by its body text.
  • Tab and Shift+Tab cycle inside the dialog; focus cannot leave it while it is open.
  • Escape, the close button, Cancel and a click on the backdrop close it and fire a cancel event.
  • Focus moves into the dialog on open and returns to the trigger on close.
  • Page scrolling is locked while the dialog is open.
  • Confirm fires a confirm event; the entrance animation is skipped for reduced motion.

Styling variables

Every look is a CSS variable: --kt-accent, --kt-accent-ink, --kt-radius-btn, --kt-surface-radius, --kt-surface-bg, --kt-border-w, --kt-comp-shadow and --font-sans. The copied file sets them all from your choices.

FAQ

Kinetic Modal: questions answered

How do I use the Kinetic Modal?

Press Copy on the card to get a complete HTML file, or copy the HTML, CSS and JavaScript tabs into your own page. In your markup the element is written as <kt-kinetic-modal>.

Which attributes does <kt-kinetic-modal> accept?

title, trigger, open, confirm-label, cancel-label, disabled, sfx. Each one is described in the attributes table on this page.

Is the Kinetic Modal accessible?

role="dialog" with aria-modal, named by its title and described by its body text. Tab and Shift+Tab cycle inside the dialog; focus cannot leave it while it is open. Escape, the close button, Cancel and a click on the backdrop close it and fire a cancel event. Focus moves into the dialog on open and returns to the trigger on close. Page scrolling is locked while the dialog is open. Confirm fires a confirm event; the entrance animation is skipped for reduced motion.

Can I change the Kinetic Modal colors, corners and font?

Yes. Use the options on this page: accent color, border radius, background, border, shadow and Google font. The copied code already contains your choices, and every one of them is a CSS variable you can edit later.