CSS ::backdrop playground

Explore ::backdrop with a native modal dialog. Change only the backdrop background color and copy the generated command/commandfor HTML and CSS.

Ask AI

CSS ::backdrop playground

Response generated with openai/gpt-5.4-nano. AI can make mistakes. Always review the result.
HTML
<div class="backdrop-demo">
  <button type="button" commandfor="baseline-backdrop-dialog" command="show-modal">
    Open modal
  </button>

  <dialog id="baseline-backdrop-dialog" closedby="none">
    <h2>Modal with backdrop</h2>
    <p>This dialog is opened and closed with command and commandfor.</p>
    <button type="button" commandfor="baseline-backdrop-dialog" command="close">
      Close
    </button>
  </dialog>
</div>
CSS
.backdrop-demo dialog::backdrop {
  background-color: #111827;
}

.backdrop-demo dialog {
  padding: 1.25rem;
  border: 0;
  border-radius: 1rem;
  background: Canvas;
  color: CanvasText;
}