Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
D

details-dialog-element

> 编程语言
Open source

A modal dialog that's opened with <details>.

763 stars0 likes1 views
WebsiteGitHub

About

A modal dialog that's opened with <details>.

<details-dialog> element

A modal dialog opened with a <details> button.

DEPRECATION WARNING

This web component has been deprecated. There are a number of accessibility concerns with this approach and so we no longer recommend using this component.

Accessibility and Usability Concerns

  • Semantically, using a details-summary pattern for a dialog solution can be confusing for screen reader users.
  • If the user performs a "find in page" operation on a website using details-dialog elements, the content on those elements will appear when they shouldn't.
  • Opening the dialog does not disable scrolling on the underlying page.

GitHub are moving towards using a dialog Primer View Component which enforces certain aspects of the design (such as always having a close button and a title).

Installation

Available on npm as @github/details-dialog-element.

$ npm install --save @github/details-dialog-element

Usage

Script

Import as ES modules:

import '@github/details-dialog-element'

Include with a script tag:

Markup


  Open dialog
  
    Modal content
    Close
  

Deferred loading

Dialog content can be loaded from a server by embedding an [``][fragment] element.


  Robots
  
    Loading…
  

The src attribute value is copied to the the first time the button is toggled open, which starts the server fetch.

If the preload attribute is present, hovering over the `` element will trigger the server fetch.

Events

details-dialog-close

details-dialog-close event is fired from `` when a request to close the dialog is made from

  • pressing escape,
  • submitting a form[method="dialog"]
  • clicking on summary, form button[formmethod="dialog"], [data-close-dialog], or
  • dialog.toggle(false)

This event bubbles, and can be canceled to keep the dialog open.

document.addEventListener('details-dialog-close', function(event) {
  if (!confirm('Are you sure?')) {
    event.preventDefault()
  }
})

Browser support

Browsers without native custom element support require a polyfill.

  • Chrome
  • Firefox
  • Safari
  • Microsoft Edge

License

Distributed under the MIT license. See LICENSE for details.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScriptcustom-elementsweb-components

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言