Reduced motion, focus handling, keyboard support and what screen readers see.
When prefers-reduced-motion: reduce matches, or reducedMotion: true is set, nothing moves. No transforms, no clip-path animation, no background scale. The transition becomes two fades:
The surface fades before the content on open, and after it on close, so the text of the list and the text of the sheet never show through each other. The scrim still fades.
The browser test for this records every animation created during an open and a close and fails if any of them has a transform or clip-path keyframe.
On open, focus moves into the sheet with preventScroll: true:
data-morph-focus, if there is one;tabindex="-1".On close, focus returns to what opened the sheet: the focused element inside the card, or the card's data-morph-focus element, or its first focusable element. It uses preventScroll: true too, so returning focus does not undo the restored scroll position. If focus has moved somewhere else outside the sheet in the meantime, it is left alone.
Escape closes the most recently opened sheet. Repeated Escape during its close does not dismiss a sheet underneath. Set closeOnEscape: false to handle it yourself; the event is left alone if something else called preventDefault(). Enter or Space on a card's button opens it, since opening is up to your click handler.
While the sheet is open the supplied background has inert, so its content cannot receive focus and screen readers do not read it. This is not a general focus trap: other page regions outside that background remain reachable. For a modal, your dialog layer must contain keyboard focus and make all underlying page regions inert.
Give a dialog sheet role="dialog" and a label. Add aria-modal="true" only when the surrounding dialog layer enforces modal focus and interaction. The temporary copy of the card inside the sheet has aria-hidden="true" and inert, and exists only while the surface moves.
data-morph-close.data-morph-focus, or is the first focusable element.[hidden] { display: none !important } is in your CSS, so the closed sheet is not reachable.Made by Lucas Piera