[{"data":1,"prerenderedAt":2474},["ShallowReactive",2],{"page-\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Fanimating-dialog-open-and-close\u002F":3,"content-all-pages":1909,"live-demo:dialog-open-close-recipe":2468},{"id":4,"title":5,"body":6,"description":1890,"extension":1891,"meta":1892,"navigation":401,"path":1905,"seo":1906,"stem":1907,"__hash__":1908},"content\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Fanimating-dialog-open-and-close\u002Findex.md","Animating \u003Cdialog> Open and Close: Both Directions, No Library",{"type":7,"value":8,"toc":1878},"minimark",[9,19,54,59,66,84,88,189,212,216,1384,1402,1406,1428,1434,1437,1507,1530,1545,1549,1565,1568,1578,1582,1589,1754,1757,1764,1768,1787,1791,1812,1826,1832,1841,1845,1875],[10,11,13,14,18],"h1",{"id":12},"animating-dialog-open-and-close-both-directions-no-library","Animating ",[15,16,17],"code",{},"\u003Cdialog>"," Open and Close: Both Directions, No Library",[20,21,22,23,25,26,29,30,33,34,37,38,42,43,48,49,53],"p",{},"The native ",[15,24,17],{}," element does the hard parts of a modal for free: it moves into the top layer above everything else, makes the rest of the page inert, traps focus, closes on Escape, and restores focus to the trigger on close. What it does not do is animate. It snaps into existence and vanishes just as abruptly, because opening and closing flip ",[15,27,28],{},"display"," between ",[15,31,32],{},"none"," and ",[15,35,36],{},"block"," — a discrete property that ordinary transitions skip. The narrow problem this page solves is a dialog that fades and scales in ",[39,40,41],"em",{},"and out",", using only CSS on top of the element's built-in behaviour. It belongs to ",[44,45,47],"a",{"href":46},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002F","Dialog & Popover Animations"," in the ",[44,50,52],{"href":51},"\u002Fcss-only-micro-interactions-animations\u002F","CSS-Only Micro-Interactions & Animations"," guide.",[55,56,58],"h2",{"id":57},"why-the-native-element-is-worth-animating","Why the native element is worth animating",[20,60,61,62,65],{},"Custom modals built from ",[15,63,64],{},"\u003Cdiv>"," elements animate easily because nothing about them is special — but they must reimplement focus trapping, inertness, Escape handling, scroll locking and focus return, and most implementations get at least one wrong. The native dialog gets all of them right and is exposed correctly to assistive technology as a modal dialog. Trading those guarantees for easier animation is a bad deal.",[20,67,68,69,72,73,76,77,79,80,83],{},"Until recently the trade was necessary. Three platform features removed it: ",[15,70,71],{},"@starting-style"," gives an element a \"before\" state to transition from on its first frame; ",[15,74,75],{},"transition-behavior: allow-discrete"," lets ",[15,78,28],{}," participate in a transition by flipping at the right moment rather than immediately; and the ",[15,81,82],{},"overlay"," property lets a closing element stay in the top layer until its exit transition finishes. Together they make both directions of a dialog animatable while the element keeps its native behaviour.",[55,85,87],{"id":86},"what-happens-when-a-dialog-opens-and-closes","What happens when a dialog opens and closes",[89,90,96,97,96,101,96,105,96,113,96,119,96,123,96,129,96,139,96,142,96,148,96,154,96,157,96,160,96,162,96,166,96,171,96,174,96,178,96,181,96,184],"svg",{"viewBox":91,"role":92,"ariaLabel":93,"xmlns":94,"style":95},"0 0 720 330","img","Timeline of a dialog opening and closing, showing when display, overlay and the visual properties change","http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg","width:100%;height:auto;max-width:720px;margin:2rem 0","\n  ",[98,99,100],"title",{},"The open and close timeline",[102,103,104],"desc",{},"On open, display and overlay switch on at the start while opacity and scale transition from the starting style to the open state. On close, opacity and scale transition back first, and display and overlay switch off only at the end, because allow-discrete delays them.",[106,107,112],"text",{"textAnchor":108,"x":109,"y":110,"style":111},"middle","360","26","text-anchor:middle;fill:currentColor;font:700 17px sans-serif","Discrete properties flip at opposite ends",[106,114,118],{"textAnchor":108,"x":115,"y":116,"style":117},"190","56","text-anchor:middle;fill:currentColor;font:600 13px sans-serif","showModal()",[106,120,122],{"textAnchor":108,"x":121,"y":116,"style":117},"530","close()",[106,124,28],{"textAnchor":125,"x":126,"y":127,"style":128},"start","30","92","text-anchor:start;fill:currentColor;font:12px ui-monospace,monospace",[130,131],"rect",{"x":132,"y":133,"width":134,"height":135,"rx":136,"fill":137,"opacity":138},"110","78","250","20","4","#7aa2ff","0.45",[130,140],{"x":141,"y":133,"width":134,"height":135,"rx":136,"fill":137,"opacity":138},"380",[106,143,147],{"textAnchor":125,"x":144,"y":145,"style":146},"120","122","text-anchor:start;fill:currentColor;font:11px sans-serif","on at 0%",[106,149,153],{"textAnchor":150,"x":151,"y":145,"style":152},"end","620","text-anchor:end;fill:currentColor;font:11px sans-serif","off at 100%",[106,155,82],{"textAnchor":125,"x":126,"y":156,"style":128},"152",[130,158],{"x":132,"y":159,"width":134,"height":135,"rx":136,"fill":137,"opacity":138},"138",[130,161],{"x":141,"y":159,"width":134,"height":135,"rx":136,"fill":137,"opacity":138},[106,163,165],{"textAnchor":125,"x":126,"y":164,"style":128},"212","opacity",[167,168],"path",{"d":169,"fill":32,"stroke":137,"strokeWidth":170},"M110 218 C170 190 240 180 360 178","3.5",[167,172],{"d":173,"fill":32,"stroke":137,"strokeWidth":170},"M380 178 C470 180 560 200 630 218",[106,175,177],{"textAnchor":125,"x":126,"y":176,"style":128},"262","scale",[167,179],{"d":180,"fill":32,"stroke":137,"strokeWidth":170},"M110 268 C170 245 240 240 360 238",[167,182],{"d":183,"fill":32,"stroke":137,"strokeWidth":170},"M380 238 C470 240 560 255 630 268",[106,185,188],{"textAnchor":108,"x":109,"y":186,"style":187},"306","text-anchor:middle;fill:currentColor;font:12px sans-serif","Without allow-discrete, display and overlay would drop at the start of close(), cutting the fade.",[20,190,191,192,195,196,198,199,202,203,206,207,33,209,211],{},"On open, the browser sets ",[15,193,194],{},"display: block"," and puts the dialog in the top layer immediately. Without help, the first frame would already be the final state, so there would be nothing to transition from — ",[15,197,71],{}," supplies that \"from\" state. On close, the browser sets ",[15,200,201],{},"display: none"," and removes the dialog from the top layer. With ",[15,204,205],{},"allow-discrete"," on both ",[15,208,28],{},[15,210,82],{},", those changes are deferred until the end of the transition, so the visual properties have time to animate out while the dialog is still rendered above the page.",[55,213,215],{"id":214},"the-complete-implementation","The complete implementation",[217,218,223],"pre",{"className":219,"code":220,"language":221,"meta":222,"style":222},"language-html shiki shiki-themes github-light-high-contrast github-dark-high-contrast","\u003C!doctype html>\n\u003Chtml lang=\"en\">\n\u003Chead>\n\u003Cmeta charset=\"utf-8\">\n\u003Cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\u003Ctitle>Animated dialog\u003C\u002Ftitle>\n\u003Cstyle>\n  body { font: 16px\u002F1.5 system-ui, sans-serif; margin: 2rem; }\n\n  dialog {\n    width: min(90vw, 28rem);\n    padding: 1.5rem;\n    border: 0;\n    border-radius: 14px;\n    box-shadow: 0 20px 50px rgb(15 23 42 \u002F 0.3);\n\n    \u002F* CLOSED values (and the exit transition, which runs INTO this state). *\u002F\n    opacity: 0;\n    scale: 0.96;\n    translate: 0 0.5rem;\n    transition:\n      opacity 160ms cubic-bezier(0.64, 0, 0.78, 0),\n      scale 160ms cubic-bezier(0.64, 0, 0.78, 0),\n      translate 160ms cubic-bezier(0.64, 0, 0.78, 0),\n      \u002F* Discrete: keep the dialog rendered and in the top layer until the\n         exit has finished, instead of dropping it on the first frame. *\u002F\n      display 160ms allow-discrete,\n      overlay 160ms allow-discrete;\n  }\n\n  \u002F* OPEN values, and the entry transition. *\u002F\n  dialog[open] {\n    opacity: 1;\n    scale: 1;\n    translate: 0 0;\n    transition:\n      opacity 240ms cubic-bezier(0.22, 1, 0.36, 1),\n      scale 240ms cubic-bezier(0.22, 1, 0.36, 1),\n      translate 240ms cubic-bezier(0.22, 1, 0.36, 1),\n      display 240ms allow-discrete,\n      overlay 240ms allow-discrete;\n  }\n\n  \u002F* The state to animate FROM on the first frame after opening.\n     Nested inside dialog[open], so it only applies at open time. *\u002F\n  @starting-style {\n    dialog[open] {\n      opacity: 0;\n      scale: 0.96;\n      translate: 0 0.5rem;\n    }\n  }\n\n  \u002F* Reduced motion: keep a brief fade, drop the movement. *\u002F\n  @media (prefers-reduced-motion: reduce) {\n    dialog, dialog[open] { scale: 1; translate: 0 0; }\n  }\n\n  dialog button:focus-visible,\n  .open:focus-visible { outline: 2px solid #4f46e5; outline-offset: 2px; }\n\u003C\u002Fstyle>\n\u003C\u002Fhead>\n\u003Cbody>\n  \u003Cbutton class=\"open\" type=\"button\" onclick=\"document.getElementById('confirm').showModal()\">Delete project…\u003C\u002Fbutton>\n\n  \u003Cdialog id=\"confirm\" aria-labelledby=\"confirm-title\">\n    \u003Ch2 id=\"confirm-title\">Delete this project?\u003C\u002Fh2>\n    \u003Cp>This removes all files and cannot be undone.\u003C\u002Fp>\n    \u003C!-- method=\"dialog\" closes the dialog on submit, no script needed. -->\n    \u003Cform method=\"dialog\">\n      \u003Cbutton value=\"cancel\" autofocus>Cancel\u003C\u002Fbutton>\n      \u003Cbutton value=\"delete\">Delete\u003C\u002Fbutton>\n    \u003C\u002Fform>\n  \u003C\u002Fdialog>\n\u003C\u002Fbody>\n\u003C\u002Fhtml>\n","html","",[15,224,225,245,265,275,293,318,332,342,396,403,412,442,457,470,485,527,532,539,551,564,581,590,626,656,686,692,698,711,725,731,736,742,756,768,779,793,800,832,861,890,901,913,918,923,929,935,943,955,967,979,995,1001,1006,1011,1017,1026,1062,1067,1072,1086,1122,1132,1141,1151,1210,1215,1240,1261,1275,1281,1299,1325,1346,1356,1366,1375],{"__ignoreMap":222},[226,227,230,234,238,242],"span",{"class":228,"line":229},"line",1,[226,231,233],{"class":232},"suds8","\u003C!",[226,235,237],{"class":236},"sne4z","doctype",[226,239,241],{"class":240},"s-5SL"," html",[226,243,244],{"class":232},">\n",[226,246,248,251,253,256,259,263],{"class":228,"line":247},2,[226,249,250],{"class":232},"\u003C",[226,252,221],{"class":236},[226,254,255],{"class":240}," lang",[226,257,258],{"class":232},"=",[226,260,262],{"class":261},"sT6z2","\"en\"",[226,264,244],{"class":232},[226,266,268,270,273],{"class":228,"line":267},3,[226,269,250],{"class":232},[226,271,272],{"class":236},"head",[226,274,244],{"class":232},[226,276,278,280,283,286,288,291],{"class":228,"line":277},4,[226,279,250],{"class":232},[226,281,282],{"class":236},"meta",[226,284,285],{"class":240}," charset",[226,287,258],{"class":232},[226,289,290],{"class":261},"\"utf-8\"",[226,292,244],{"class":232},[226,294,296,298,300,303,305,308,311,313,316],{"class":228,"line":295},5,[226,297,250],{"class":232},[226,299,282],{"class":236},[226,301,302],{"class":240}," name",[226,304,258],{"class":232},[226,306,307],{"class":261},"\"viewport\"",[226,309,310],{"class":240}," content",[226,312,258],{"class":232},[226,314,315],{"class":261},"\"width=device-width, initial-scale=1\"",[226,317,244],{"class":232},[226,319,321,323,325,328,330],{"class":228,"line":320},6,[226,322,250],{"class":232},[226,324,98],{"class":236},[226,326,327],{"class":232},">Animated dialog\u003C\u002F",[226,329,98],{"class":236},[226,331,244],{"class":232},[226,333,335,337,340],{"class":228,"line":334},7,[226,336,250],{"class":232},[226,338,339],{"class":236},"style",[226,341,244],{"class":232},[226,343,345,348,351,354,357,360,364,367,370,373,376,379,382,385,387,390,393],{"class":228,"line":344},8,[226,346,347],{"class":236},"  body",[226,349,350],{"class":232}," { ",[226,352,353],{"class":240},"font",[226,355,356],{"class":232},": ",[226,358,359],{"class":240},"16",[226,361,363],{"class":362},"sHUrx","px",[226,365,366],{"class":232},"\u002F",[226,368,369],{"class":240},"1.5",[226,371,372],{"class":240}," system-ui",[226,374,375],{"class":232},", ",[226,377,378],{"class":240},"sans-serif",[226,380,381],{"class":232},"; ",[226,383,384],{"class":240},"margin",[226,386,356],{"class":232},[226,388,389],{"class":240},"2",[226,391,392],{"class":362},"rem",[226,394,395],{"class":232},"; }\n",[226,397,399],{"class":228,"line":398},9,[226,400,402],{"emptyLinePlaceholder":401},true,"\n",[226,404,406,409],{"class":228,"line":405},10,[226,407,408],{"class":236},"  dialog",[226,410,411],{"class":232}," {\n",[226,413,415,418,420,423,426,429,432,434,437,439],{"class":228,"line":414},11,[226,416,417],{"class":240},"    width",[226,419,356],{"class":232},[226,421,422],{"class":240},"min",[226,424,425],{"class":232},"(",[226,427,428],{"class":240},"90",[226,430,431],{"class":362},"vw",[226,433,375],{"class":232},[226,435,436],{"class":240},"28",[226,438,392],{"class":362},[226,440,441],{"class":232},");\n",[226,443,445,448,450,452,454],{"class":228,"line":444},12,[226,446,447],{"class":240},"    padding",[226,449,356],{"class":232},[226,451,369],{"class":240},[226,453,392],{"class":362},[226,455,456],{"class":232},";\n",[226,458,460,463,465,468],{"class":228,"line":459},13,[226,461,462],{"class":240},"    border",[226,464,356],{"class":232},[226,466,467],{"class":240},"0",[226,469,456],{"class":232},[226,471,473,476,478,481,483],{"class":228,"line":472},14,[226,474,475],{"class":240},"    border-radius",[226,477,356],{"class":232},[226,479,480],{"class":240},"14",[226,482,363],{"class":362},[226,484,456],{"class":232},[226,486,488,491,493,495,498,500,503,505,508,510,513,516,519,522,525],{"class":228,"line":487},15,[226,489,490],{"class":240},"    box-shadow",[226,492,356],{"class":232},[226,494,467],{"class":240},[226,496,497],{"class":240}," 20",[226,499,363],{"class":362},[226,501,502],{"class":240}," 50",[226,504,363],{"class":362},[226,506,507],{"class":240}," rgb",[226,509,425],{"class":232},[226,511,512],{"class":240},"15",[226,514,515],{"class":240}," 23",[226,517,518],{"class":240}," 42",[226,520,521],{"class":232}," \u002F ",[226,523,524],{"class":240},"0.3",[226,526,441],{"class":232},[226,528,530],{"class":228,"line":529},16,[226,531,402],{"emptyLinePlaceholder":401},[226,533,535],{"class":228,"line":534},17,[226,536,538],{"class":537},"sLBg1","    \u002F* CLOSED values (and the exit transition, which runs INTO this state). *\u002F\n",[226,540,542,545,547,549],{"class":228,"line":541},18,[226,543,544],{"class":240},"    opacity",[226,546,356],{"class":232},[226,548,467],{"class":240},[226,550,456],{"class":232},[226,552,554,557,559,562],{"class":228,"line":553},19,[226,555,556],{"class":240},"    scale",[226,558,356],{"class":232},[226,560,561],{"class":240},"0.96",[226,563,456],{"class":232},[226,565,567,570,572,574,577,579],{"class":228,"line":566},20,[226,568,569],{"class":240},"    translate",[226,571,356],{"class":232},[226,573,467],{"class":240},[226,575,576],{"class":240}," 0.5",[226,578,392],{"class":362},[226,580,456],{"class":232},[226,582,584,587],{"class":228,"line":583},21,[226,585,586],{"class":240},"    transition",[226,588,589],{"class":232},":\n",[226,591,593,596,599,602,605,607,610,612,614,616,619,621,623],{"class":228,"line":592},22,[226,594,595],{"class":232},"      opacity ",[226,597,598],{"class":240},"160",[226,600,601],{"class":362},"ms",[226,603,604],{"class":240}," cubic-bezier",[226,606,425],{"class":232},[226,608,609],{"class":240},"0.64",[226,611,375],{"class":232},[226,613,467],{"class":240},[226,615,375],{"class":232},[226,617,618],{"class":240},"0.78",[226,620,375],{"class":232},[226,622,467],{"class":240},[226,624,625],{"class":232},"),\n",[226,627,629,632,634,636,638,640,642,644,646,648,650,652,654],{"class":228,"line":628},23,[226,630,631],{"class":232},"      scale ",[226,633,598],{"class":240},[226,635,601],{"class":362},[226,637,604],{"class":240},[226,639,425],{"class":232},[226,641,609],{"class":240},[226,643,375],{"class":232},[226,645,467],{"class":240},[226,647,375],{"class":232},[226,649,618],{"class":240},[226,651,375],{"class":232},[226,653,467],{"class":240},[226,655,625],{"class":232},[226,657,659,662,664,666,668,670,672,674,676,678,680,682,684],{"class":228,"line":658},24,[226,660,661],{"class":232},"      translate ",[226,663,598],{"class":240},[226,665,601],{"class":362},[226,667,604],{"class":240},[226,669,425],{"class":232},[226,671,609],{"class":240},[226,673,375],{"class":232},[226,675,467],{"class":240},[226,677,375],{"class":232},[226,679,618],{"class":240},[226,681,375],{"class":232},[226,683,467],{"class":240},[226,685,625],{"class":232},[226,687,689],{"class":228,"line":688},25,[226,690,691],{"class":537},"      \u002F* Discrete: keep the dialog rendered and in the top layer until the\n",[226,693,695],{"class":228,"line":694},26,[226,696,697],{"class":537},"         exit has finished, instead of dropping it on the first frame. *\u002F\n",[226,699,701,704,706,708],{"class":228,"line":700},27,[226,702,703],{"class":232},"      display ",[226,705,598],{"class":240},[226,707,601],{"class":362},[226,709,710],{"class":232}," allow-discrete,\n",[226,712,714,717,720,722],{"class":228,"line":713},28,[226,715,716],{"class":240},"      overlay",[226,718,719],{"class":240}," 160",[226,721,601],{"class":362},[226,723,724],{"class":232}," allow-discrete;\n",[226,726,728],{"class":228,"line":727},29,[226,729,730],{"class":232},"  }\n",[226,732,734],{"class":228,"line":733},30,[226,735,402],{"emptyLinePlaceholder":401},[226,737,739],{"class":228,"line":738},31,[226,740,741],{"class":537},"  \u002F* OPEN values, and the entry transition. *\u002F\n",[226,743,745,747,750,753],{"class":228,"line":744},32,[226,746,408],{"class":236},[226,748,749],{"class":232},"[",[226,751,752],{"class":240},"open",[226,754,755],{"class":232},"] {\n",[226,757,759,761,763,766],{"class":228,"line":758},33,[226,760,544],{"class":240},[226,762,356],{"class":232},[226,764,765],{"class":240},"1",[226,767,456],{"class":232},[226,769,771,773,775,777],{"class":228,"line":770},34,[226,772,556],{"class":240},[226,774,356],{"class":232},[226,776,765],{"class":240},[226,778,456],{"class":232},[226,780,782,784,786,788,791],{"class":228,"line":781},35,[226,783,569],{"class":240},[226,785,356],{"class":232},[226,787,467],{"class":240},[226,789,790],{"class":240}," 0",[226,792,456],{"class":232},[226,794,796,798],{"class":228,"line":795},36,[226,797,586],{"class":240},[226,799,589],{"class":232},[226,801,803,805,808,810,812,814,817,819,821,823,826,828,830],{"class":228,"line":802},37,[226,804,595],{"class":232},[226,806,807],{"class":240},"240",[226,809,601],{"class":362},[226,811,604],{"class":240},[226,813,425],{"class":232},[226,815,816],{"class":240},"0.22",[226,818,375],{"class":232},[226,820,765],{"class":240},[226,822,375],{"class":232},[226,824,825],{"class":240},"0.36",[226,827,375],{"class":232},[226,829,765],{"class":240},[226,831,625],{"class":232},[226,833,835,837,839,841,843,845,847,849,851,853,855,857,859],{"class":228,"line":834},38,[226,836,631],{"class":232},[226,838,807],{"class":240},[226,840,601],{"class":362},[226,842,604],{"class":240},[226,844,425],{"class":232},[226,846,816],{"class":240},[226,848,375],{"class":232},[226,850,765],{"class":240},[226,852,375],{"class":232},[226,854,825],{"class":240},[226,856,375],{"class":232},[226,858,765],{"class":240},[226,860,625],{"class":232},[226,862,864,866,868,870,872,874,876,878,880,882,884,886,888],{"class":228,"line":863},39,[226,865,661],{"class":232},[226,867,807],{"class":240},[226,869,601],{"class":362},[226,871,604],{"class":240},[226,873,425],{"class":232},[226,875,816],{"class":240},[226,877,375],{"class":232},[226,879,765],{"class":240},[226,881,375],{"class":232},[226,883,825],{"class":240},[226,885,375],{"class":232},[226,887,765],{"class":240},[226,889,625],{"class":232},[226,891,893,895,897,899],{"class":228,"line":892},40,[226,894,703],{"class":232},[226,896,807],{"class":240},[226,898,601],{"class":362},[226,900,710],{"class":232},[226,902,904,906,909,911],{"class":228,"line":903},41,[226,905,716],{"class":240},[226,907,908],{"class":240}," 240",[226,910,601],{"class":362},[226,912,724],{"class":232},[226,914,916],{"class":228,"line":915},42,[226,917,730],{"class":232},[226,919,921],{"class":228,"line":920},43,[226,922,402],{"emptyLinePlaceholder":401},[226,924,926],{"class":228,"line":925},44,[226,927,928],{"class":537},"  \u002F* The state to animate FROM on the first frame after opening.\n",[226,930,932],{"class":228,"line":931},45,[226,933,934],{"class":537},"     Nested inside dialog[open], so it only applies at open time. *\u002F\n",[226,936,938,941],{"class":228,"line":937},46,[226,939,940],{"class":362},"  @starting-style",[226,942,411],{"class":232},[226,944,946,949,951,953],{"class":228,"line":945},47,[226,947,948],{"class":236},"    dialog",[226,950,749],{"class":232},[226,952,752],{"class":240},[226,954,755],{"class":232},[226,956,958,961,963,965],{"class":228,"line":957},48,[226,959,960],{"class":240},"      opacity",[226,962,356],{"class":232},[226,964,467],{"class":240},[226,966,456],{"class":232},[226,968,970,973,975,977],{"class":228,"line":969},49,[226,971,972],{"class":240},"      scale",[226,974,356],{"class":232},[226,976,561],{"class":240},[226,978,456],{"class":232},[226,980,982,985,987,989,991,993],{"class":228,"line":981},50,[226,983,984],{"class":240},"      translate",[226,986,356],{"class":232},[226,988,467],{"class":240},[226,990,576],{"class":240},[226,992,392],{"class":362},[226,994,456],{"class":232},[226,996,998],{"class":228,"line":997},51,[226,999,1000],{"class":232},"    }\n",[226,1002,1004],{"class":228,"line":1003},52,[226,1005,730],{"class":232},[226,1007,1009],{"class":228,"line":1008},53,[226,1010,402],{"emptyLinePlaceholder":401},[226,1012,1014],{"class":228,"line":1013},54,[226,1015,1016],{"class":537},"  \u002F* Reduced motion: keep a brief fade, drop the movement. *\u002F\n",[226,1018,1020,1023],{"class":228,"line":1019},55,[226,1021,1022],{"class":362},"  @media",[226,1024,1025],{"class":232}," (prefers-reduced-motion: reduce) {\n",[226,1027,1029,1031,1033,1036,1038,1040,1043,1045,1047,1049,1051,1054,1056,1058,1060],{"class":228,"line":1028},56,[226,1030,948],{"class":236},[226,1032,375],{"class":232},[226,1034,1035],{"class":236},"dialog",[226,1037,749],{"class":232},[226,1039,752],{"class":240},[226,1041,1042],{"class":232},"] { ",[226,1044,177],{"class":240},[226,1046,356],{"class":232},[226,1048,765],{"class":240},[226,1050,381],{"class":232},[226,1052,1053],{"class":240},"translate",[226,1055,356],{"class":232},[226,1057,467],{"class":240},[226,1059,790],{"class":240},[226,1061,395],{"class":232},[226,1063,1065],{"class":228,"line":1064},57,[226,1066,730],{"class":232},[226,1068,1070],{"class":228,"line":1069},58,[226,1071,402],{"emptyLinePlaceholder":401},[226,1073,1075,1077,1080,1083],{"class":228,"line":1074},59,[226,1076,408],{"class":236},[226,1078,1079],{"class":236}," button",[226,1081,1082],{"class":240},":focus-visible",[226,1084,1085],{"class":232},",\n",[226,1087,1089,1092,1094,1097,1099,1101,1103,1106,1109,1111,1114,1116,1118,1120],{"class":228,"line":1088},60,[226,1090,1091],{"class":240},"  .open:focus-visible",[226,1093,350],{"class":232},[226,1095,1096],{"class":240},"outline",[226,1098,356],{"class":232},[226,1100,389],{"class":240},[226,1102,363],{"class":362},[226,1104,1105],{"class":240}," solid",[226,1107,1108],{"class":240}," #4f46e5",[226,1110,381],{"class":232},[226,1112,1113],{"class":240},"outline-offset",[226,1115,356],{"class":232},[226,1117,389],{"class":240},[226,1119,363],{"class":362},[226,1121,395],{"class":232},[226,1123,1125,1128,1130],{"class":228,"line":1124},61,[226,1126,1127],{"class":232},"\u003C\u002F",[226,1129,339],{"class":236},[226,1131,244],{"class":232},[226,1133,1135,1137,1139],{"class":228,"line":1134},62,[226,1136,1127],{"class":232},[226,1138,272],{"class":236},[226,1140,244],{"class":232},[226,1142,1144,1146,1149],{"class":228,"line":1143},63,[226,1145,250],{"class":232},[226,1147,1148],{"class":236},"body",[226,1150,244],{"class":232},[226,1152,1154,1157,1160,1163,1165,1168,1171,1173,1176,1179,1181,1184,1187,1190,1194,1197,1200,1203,1206,1208],{"class":228,"line":1153},64,[226,1155,1156],{"class":232},"  \u003C",[226,1158,1159],{"class":236},"button",[226,1161,1162],{"class":240}," class",[226,1164,258],{"class":232},[226,1166,1167],{"class":261},"\"open\"",[226,1169,1170],{"class":240}," type",[226,1172,258],{"class":232},[226,1174,1175],{"class":261},"\"button\"",[226,1177,1178],{"class":240}," onclick",[226,1180,258],{"class":232},[226,1182,1183],{"class":261},"\"",[226,1185,1186],{"class":232},"document",[226,1188,1189],{"class":261},".",[226,1191,1193],{"class":1192},"sKwhi","getElementById",[226,1195,1196],{"class":261},"('confirm').",[226,1198,1199],{"class":1192},"showModal",[226,1201,1202],{"class":261},"()\"",[226,1204,1205],{"class":232},">Delete project…\u003C\u002F",[226,1207,1159],{"class":236},[226,1209,244],{"class":232},[226,1211,1213],{"class":228,"line":1212},65,[226,1214,402],{"emptyLinePlaceholder":401},[226,1216,1218,1220,1222,1225,1227,1230,1233,1235,1238],{"class":228,"line":1217},66,[226,1219,1156],{"class":232},[226,1221,1035],{"class":236},[226,1223,1224],{"class":240}," id",[226,1226,258],{"class":232},[226,1228,1229],{"class":261},"\"confirm\"",[226,1231,1232],{"class":240}," aria-labelledby",[226,1234,258],{"class":232},[226,1236,1237],{"class":261},"\"confirm-title\"",[226,1239,244],{"class":232},[226,1241,1243,1246,1248,1250,1252,1254,1257,1259],{"class":228,"line":1242},67,[226,1244,1245],{"class":232},"    \u003C",[226,1247,55],{"class":236},[226,1249,1224],{"class":240},[226,1251,258],{"class":232},[226,1253,1237],{"class":261},[226,1255,1256],{"class":232},">Delete this project?\u003C\u002F",[226,1258,55],{"class":236},[226,1260,244],{"class":232},[226,1262,1264,1266,1268,1271,1273],{"class":228,"line":1263},68,[226,1265,1245],{"class":232},[226,1267,20],{"class":236},[226,1269,1270],{"class":232},">This removes all files and cannot be undone.\u003C\u002F",[226,1272,20],{"class":236},[226,1274,244],{"class":232},[226,1276,1278],{"class":228,"line":1277},69,[226,1279,1280],{"class":537},"    \u003C!-- method=\"dialog\" closes the dialog on submit, no script needed. -->\n",[226,1282,1284,1286,1289,1292,1294,1297],{"class":228,"line":1283},70,[226,1285,1245],{"class":232},[226,1287,1288],{"class":236},"form",[226,1290,1291],{"class":240}," method",[226,1293,258],{"class":232},[226,1295,1296],{"class":261},"\"dialog\"",[226,1298,244],{"class":232},[226,1300,1302,1305,1307,1310,1312,1315,1318,1321,1323],{"class":228,"line":1301},71,[226,1303,1304],{"class":232},"      \u003C",[226,1306,1159],{"class":236},[226,1308,1309],{"class":240}," value",[226,1311,258],{"class":232},[226,1313,1314],{"class":261},"\"cancel\"",[226,1316,1317],{"class":240}," autofocus",[226,1319,1320],{"class":232},">Cancel\u003C\u002F",[226,1322,1159],{"class":236},[226,1324,244],{"class":232},[226,1326,1328,1330,1332,1334,1336,1339,1342,1344],{"class":228,"line":1327},72,[226,1329,1304],{"class":232},[226,1331,1159],{"class":236},[226,1333,1309],{"class":240},[226,1335,258],{"class":232},[226,1337,1338],{"class":261},"\"delete\"",[226,1340,1341],{"class":232},">Delete\u003C\u002F",[226,1343,1159],{"class":236},[226,1345,244],{"class":232},[226,1347,1349,1352,1354],{"class":228,"line":1348},73,[226,1350,1351],{"class":232},"    \u003C\u002F",[226,1353,1288],{"class":236},[226,1355,244],{"class":232},[226,1357,1359,1362,1364],{"class":228,"line":1358},74,[226,1360,1361],{"class":232},"  \u003C\u002F",[226,1363,1035],{"class":236},[226,1365,244],{"class":232},[226,1367,1369,1371,1373],{"class":228,"line":1368},75,[226,1370,1127],{"class":232},[226,1372,1148],{"class":236},[226,1374,244],{"class":232},[226,1376,1378,1380,1382],{"class":228,"line":1377},76,[226,1379,1127],{"class":232},[226,1381,221],{"class":236},[226,1383,244],{"class":232},[20,1385,1386,1387,1390,1391,1394,1395,1398,1399,1401],{},"The live demo frames on this site run with scripting disabled, so the demo below applies the identical recipe to a popover — which opens from a ",[15,1388,1389],{},"popovertarget"," button without script — swapping ",[15,1392,1393],{},"[open]"," for ",[15,1396,1397],{},":popover-open",". Every transition, easing value and ",[15,1400,71],{}," block is the same as in the dialog code above, which shows how portable the pattern is across top-layer elements.",[1403,1404],"live-demo",{"name":1405},"dialog-open-close-recipe",[20,1407,1408,1409,1411,1412,1415,1416,1419,1420,1423,1424,1427],{},"In the dialog version, the single line of script, ",[15,1410,118],{},", is what makes the dialog modal — inert page, focus trap, top layer. Closing needs no script: a ",[15,1413,1414],{},"\u003Cform method=\"dialog\">"," closes the dialog when submitted, and the ",[15,1417,1418],{},"value"," of the button that submitted it becomes the dialog's ",[15,1421,1422],{},"returnValue",". The ",[15,1425,1426],{},"autofocus"," on Cancel puts initial focus on the safe choice, which is the right default for a destructive confirmation.",[55,1429,1431,1432],{"id":1430},"the-key-technique-two-discrete-properties-one-starting-style","The key technique: two discrete properties, one ",[15,1433,71],{},[20,1435,1436],{},"Three pieces must all be present, and missing any one produces a characteristic failure.",[89,1438,96,1441,96,1444,96,1447,96,1450,96,1457,96,1462,96,1466,96,1470,96,1473,96,1475,96,1478,96,1481,96,1485,96,1488,96,1491,96,1495,96,1497,96,1500,96,1503],{"viewBox":1439,"role":92,"ariaLabel":1440,"xmlns":94,"style":95},"0 0 720 280","Three failure modes: no starting-style means no entry animation, no allow-discrete on display means instant close, no overlay means the closing dialog drops behind the page",[98,1442,1443],{},"What breaks when each piece is missing",[102,1445,1446],{},"Missing starting-style: the dialog appears instantly with no entry. Missing display with allow-discrete: the dialog vanishes instantly on close. Missing overlay: the closing dialog fades out but falls behind other content and loses its backdrop for the duration.",[106,1448,1449],{"textAnchor":108,"x":109,"y":110,"style":111},"Each missing piece has its own symptom",[130,1451],{"x":135,"y":1452,"width":1453,"height":1454,"rx":1455,"fill":137,"opacity":1456},"50","220","170","10","0.16",[106,1458,1461],{"textAnchor":108,"x":1459,"y":133,"style":1460},"130","text-anchor:middle;fill:currentColor;font:700 13px sans-serif","no @starting-style",[106,1463,1465],{"textAnchor":108,"x":1459,"y":1464,"style":187},"112","open: pops in",[106,1467,1469],{"textAnchor":108,"x":1459,"y":1468,"style":187},"132","instantly",[106,1471,1472],{"textAnchor":108,"x":1459,"y":1454,"style":187},"close: animates",[130,1474],{"x":134,"y":1452,"width":1453,"height":1454,"rx":1455,"fill":137,"opacity":1456},[106,1476,1477],{"textAnchor":108,"x":109,"y":133,"style":1460},"no display discrete",[106,1479,1480],{"textAnchor":108,"x":109,"y":1464,"style":187},"open: animates",[106,1482,1484],{"textAnchor":108,"x":109,"y":1483,"style":187},"150","close: vanishes",[106,1486,1487],{"textAnchor":108,"x":109,"y":1454,"style":187},"on the first frame",[130,1489],{"x":1490,"y":1452,"width":1453,"height":1454,"rx":1455,"fill":137,"opacity":1456},"480",[106,1492,1494],{"textAnchor":108,"x":1493,"y":133,"style":1460},"590","no overlay discrete",[106,1496,1480],{"textAnchor":108,"x":1493,"y":1464,"style":187},[106,1498,1499],{"textAnchor":108,"x":1493,"y":1483,"style":187},"close: fades behind",[106,1501,1502],{"textAnchor":108,"x":1493,"y":1454,"style":187},"page content",[106,1504,1506],{"textAnchor":108,"x":109,"y":1505,"style":187},"256","All three together: symmetric, top-layer-safe open and close.",[20,1508,1509,1510,1512,1513,1515,1516,1519,1520,1523,1524,1526,1527,1529],{},"The ",[15,1511,82],{}," failure is the subtle one. A dialog removed from the top layer at the start of its exit is still visible for the transition, thanks to the deferred ",[15,1514,28],{},", but it now renders in normal document order — so any positioned content with a higher ",[15,1517,1518],{},"z-index"," appears on top of it, and the ",[15,1521,1522],{},"::backdrop",", which only exists for top-layer elements, disappears immediately. Deferring ",[15,1525,82],{}," keeps both the stacking and the backdrop intact until the fade completes. Where ",[15,1528,82],{}," is unsupported, the declaration is ignored and the exit still works, just with that stacking glitch.",[20,1531,1532,1533,1537,1538,1541,1542,1544],{},"The per-state transitions follow the rule described in ",[44,1534,1536],{"href":1535},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Fentry-vs-exit-easing\u002F","Entry vs Exit Easing",": the ",[15,1539,1540],{},"dialog[open]"," rule controls opening, so it has the longer ease-out; the base ",[15,1543,1035],{}," rule controls closing, so it has the shorter ease-in.",[55,1546,1548],{"id":1547},"closing-paths-and-interrupted-animations","Closing paths and interrupted animations",[20,1550,1551,1552,1554,1555,1557,1558,1561,1562,1564],{},"A dialog can close in several ways, and each one should play the same exit. ",[15,1553,122],{}," from script, a ",[15,1556,1414],{}," submission, the Escape key and — for dialogs opened with ",[15,1559,1560],{},"closedby=\"any\""," where supported — a click on the backdrop all remove the ",[15,1563,752],{}," attribute, so all of them trigger the base-state transition. There is nothing extra to wire up, which is one of the quiet advantages of animating with transitions rather than with class-toggling scripts that only run on the paths someone remembered.",[20,1566,1567],{},"Interruptions are handled for free too. If a user opens the dialog and presses Escape 100 milliseconds later, the entry transition is cut short and the exit transition starts from the current, partly faded state, using the exit's curve and duration. Keyframe-based versions cannot do this: a running entry animation would be removed abruptly and the exit animation would start from its own first keyframe, producing a visible jump.",[20,1569,1570,1571,1574,1575,1577],{},"One path does need care: removing the dialog element from the DOM while it is open, as some frameworks do when unmounting a component. A removed element cannot finish a transition, so the dialog disappears instantly. Close the dialog first, wait for the ",[15,1572,1573],{},"transitionend"," event on ",[15,1576,165],{},", and only then unmount.",[55,1579,1581],{"id":1580},"variation-growing-from-the-trigger","Variation: growing from the trigger",[20,1583,1584,1585,1588],{},"A dialog that appears to grow out of the button that opened it gives users a strong sense of where it came from. Setting ",[15,1586,1587],{},"transform-origin"," toward the trigger is enough for a convincing effect, and the trigger's position can be passed in a custom property.",[217,1590,1594],{"className":1591,"code":1592,"language":1593,"meta":222,"style":222},"language-css shiki shiki-themes github-light-high-contrast github-dark-high-contrast","dialog {\n  \u002F* Set from the opener: el.style.setProperty('--origin-x', x + 'px') etc.\n     Fallback is the centre of the dialog. *\u002F\n  transform-origin: var(--origin-x, 50%) var(--origin-y, 50%);\n}\n\n@starting-style {\n  dialog[open] {\n    opacity: 0;\n    scale: 0.6;              \u002F* larger scale change reads as growing *\u002F\n  }\n}\n\n@media (prefers-reduced-motion: reduce) {\n  @starting-style {\n    dialog[open] { scale: 1; }\n  }\n}\n","css",[15,1595,1596,1602,1607,1612,1653,1658,1662,1668,1678,1688,1703,1707,1711,1715,1722,1728,1746,1750],{"__ignoreMap":222},[226,1597,1598,1600],{"class":228,"line":229},[226,1599,1035],{"class":236},[226,1601,411],{"class":232},[226,1603,1604],{"class":228,"line":247},[226,1605,1606],{"class":537},"  \u002F* Set from the opener: el.style.setProperty('--origin-x', x + 'px') etc.\n",[226,1608,1609],{"class":228,"line":267},[226,1610,1611],{"class":537},"     Fallback is the centre of the dialog. *\u002F\n",[226,1613,1614,1617,1619,1622,1624,1628,1630,1632,1635,1638,1640,1642,1645,1647,1649,1651],{"class":228,"line":277},[226,1615,1616],{"class":240},"  transform-origin",[226,1618,356],{"class":232},[226,1620,1621],{"class":240},"var",[226,1623,425],{"class":232},[226,1625,1627],{"class":1626},"soyes","--origin-x",[226,1629,375],{"class":232},[226,1631,1452],{"class":240},[226,1633,1634],{"class":362},"%",[226,1636,1637],{"class":232},") ",[226,1639,1621],{"class":240},[226,1641,425],{"class":232},[226,1643,1644],{"class":1626},"--origin-y",[226,1646,375],{"class":232},[226,1648,1452],{"class":240},[226,1650,1634],{"class":362},[226,1652,441],{"class":232},[226,1654,1655],{"class":228,"line":295},[226,1656,1657],{"class":232},"}\n",[226,1659,1660],{"class":228,"line":320},[226,1661,402],{"emptyLinePlaceholder":401},[226,1663,1664,1666],{"class":228,"line":334},[226,1665,71],{"class":362},[226,1667,411],{"class":232},[226,1669,1670,1672,1674,1676],{"class":228,"line":344},[226,1671,408],{"class":236},[226,1673,749],{"class":232},[226,1675,752],{"class":240},[226,1677,755],{"class":232},[226,1679,1680,1682,1684,1686],{"class":228,"line":398},[226,1681,544],{"class":240},[226,1683,356],{"class":232},[226,1685,467],{"class":240},[226,1687,456],{"class":232},[226,1689,1690,1692,1694,1697,1700],{"class":228,"line":405},[226,1691,556],{"class":240},[226,1693,356],{"class":232},[226,1695,1696],{"class":240},"0.6",[226,1698,1699],{"class":232},";              ",[226,1701,1702],{"class":537},"\u002F* larger scale change reads as growing *\u002F\n",[226,1704,1705],{"class":228,"line":414},[226,1706,730],{"class":232},[226,1708,1709],{"class":228,"line":444},[226,1710,1657],{"class":232},[226,1712,1713],{"class":228,"line":459},[226,1714,402],{"emptyLinePlaceholder":401},[226,1716,1717,1720],{"class":228,"line":472},[226,1718,1719],{"class":362},"@media",[226,1721,1025],{"class":232},[226,1723,1724,1726],{"class":228,"line":487},[226,1725,940],{"class":362},[226,1727,411],{"class":232},[226,1729,1730,1732,1734,1736,1738,1740,1742,1744],{"class":228,"line":529},[226,1731,948],{"class":236},[226,1733,749],{"class":232},[226,1735,752],{"class":240},[226,1737,1042],{"class":232},[226,1739,177],{"class":240},[226,1741,356],{"class":232},[226,1743,765],{"class":240},[226,1745,395],{"class":232},[226,1747,1748],{"class":228,"line":534},[226,1749,730],{"class":232},[226,1751,1752],{"class":228,"line":541},[226,1753,1657],{"class":232},[20,1755,1756],{},"The origin must be expressed relative to the dialog's own box, so the opener computes the trigger's centre minus the dialog's final position. A cheaper approximation is to set the origin to the top of the dialog for triggers above it and the bottom for triggers below, which captures most of the effect. Keep the growth modest: a scale from 0.6 is a large, fast-moving change, and it is exactly the kind of motion reduced-motion users should not receive.",[20,1758,1759,1760,1189],{},"The backdrop can be animated alongside the dialog with the same technique, as shown in ",[44,1761,1763],{"href":1762},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Fbackdrop-animations\u002F","Backdrop Animations for Dialogs and Popovers",[55,1765,1767],{"id":1766},"browser-support","Browser support",[20,1769,1770,1772,1773,1775,1776,1778,1779,1781,1782,33,1784,1786],{},[15,1771,71],{}," is supported in Chrome and Edge 117+, Firefox 129+ and Safari 17.5+. ",[15,1774,75],{}," is supported in Chrome and Edge 117+, Firefox 129+ and Safari 17.4+. The ",[15,1777,82],{}," property is currently Chromium-only; elsewhere it is ignored and the exit animation still runs, with the stacking caveat described above. In engines without ",[15,1780,71],{},", the dialog appears without an entry animation but remains fully functional. The standalone ",[15,1783,177],{},[15,1785,1053],{}," properties are supported in current versions of all engines.",[55,1788,1790],{"id":1789},"faq","FAQ",[20,1792,1793,1797,1798,1800,1801,1803,1804,33,1806,1808,1809,1811],{},[1794,1795,1796],"strong",{},"Why does my dialog close instantly even though it animates open?","\nClosing sets ",[15,1799,28],{}," to ",[15,1802,32],{}," and removes the dialog from the top layer immediately. To animate the close, both ",[15,1805,28],{},[15,1807,82],{}," must be listed in the transition with ",[15,1810,75],{},", so the browser keeps the dialog rendered and in the top layer until the fade finishes.",[20,1813,1814,1820,1822,1823,1825],{},[1794,1815,1816,1817,1819],{},"What does the ",[15,1818,82],{}," property do?",[15,1821,82],{}," reports whether an element is in the top layer. The browser sets it, not the author, but listing it in a transition with ",[15,1824,205],{}," delays the element's removal from the top layer, which keeps a closing dialog above the page and its backdrop visible during the exit animation.",[20,1827,1828,1831],{},[1794,1829,1830],{},"Should I animate the dialog with transitions or keyframes?","\nTransitions are the better fit because they reverse cleanly when a dialog is closed mid-opening. Keyframe animations work for entry but need a separate exit animation and cannot be interrupted smoothly, so they suit one-way effects better than open-and-close pairs.",[20,1833,1834,1837,1838,1840],{},[1794,1835,1836],{},"Does animating a dialog affect focus or accessibility?","\nIt should not. The browser moves focus into the dialog and makes the rest of the page inert as soon as ",[15,1839,118],{}," runs, regardless of the visual animation. Keep the entry short so the dialog is readable quickly, and disable movement for reduced-motion users.",[55,1842,1844],{"id":1843},"related","Related",[1846,1847,1848,1854,1861,1868],"ul",{},[1849,1850,1851,1853],"li",{},[44,1852,47],{"href":46}," — the parent guide to top-layer motion.",[1849,1855,1856,1860],{},[44,1857,1859],{"href":1858},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Ftransitioning-display-with-allow-discrete\u002F","Transitioning display With allow-discrete"," — the discrete-transition mechanism in general.",[1849,1862,1863,1867],{},[44,1864,1866],{"href":1865},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Fstarting-style-entry-animations\u002F","@starting-style Entry Animations"," — first-frame styles for any element.",[1849,1869,1870,1874],{},[44,1871,1873],{"href":1872},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fcentering-in-css-every-method\u002F","Centering in CSS: Every Method"," — how the modal dialog positions itself.",[339,1876,1877],{},"html pre.shiki code .suds8, html code.shiki .suds8{--shiki-default:#0E1116;--shiki-dark:#F0F3F6}html pre.shiki code .sne4z, html code.shiki .sne4z{--shiki-default:#024C1A;--shiki-dark:#72F088}html pre.shiki code .s-5SL, html code.shiki .s-5SL{--shiki-default:#023B95;--shiki-dark:#91CBFF}html pre.shiki code .sT6z2, html code.shiki .sT6z2{--shiki-default:#032563;--shiki-dark:#ADDCFF}html pre.shiki code .sHUrx, html code.shiki .sHUrx{--shiki-default:#A0111F;--shiki-dark:#FF9492}html pre.shiki code .sLBg1, html code.shiki .sLBg1{--shiki-default:#66707B;--shiki-dark:#BDC4CC}html pre.shiki code .sKwhi, html code.shiki .sKwhi{--shiki-default:#622CBC;--shiki-dark:#DBB7FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .soyes, html code.shiki .soyes{--shiki-default:#702C00;--shiki-dark:#FFB757}",{"title":222,"searchDepth":247,"depth":247,"links":1879},[1880,1881,1882,1883,1885,1886,1887,1888,1889],{"id":57,"depth":247,"text":58},{"id":86,"depth":247,"text":87},{"id":214,"depth":247,"text":215},{"id":1430,"depth":247,"text":1884},"The key technique: two discrete properties, one @starting-style",{"id":1547,"depth":247,"text":1548},{"id":1580,"depth":247,"text":1581},{"id":1766,"depth":247,"text":1767},{"id":1789,"depth":247,"text":1790},{"id":1843,"depth":247,"text":1844},"Animate the native dialog element both ways with @starting-style, allow-discrete and the overlay property, keeping focus, Escape and the top layer intact.","md",{"pageTitle":1893,"datePublished":1894,"dateModified":1894,"faq":1895},"Animating dialog Open and Close in CSS","2026-09-18",[1896,1898,1901,1903],{"q":1796,"a":1897},"Closing sets display to none and removes the dialog from the top layer immediately. To animate the close, both display and overlay must be listed in the transition with transition-behavior: allow-discrete, so the browser keeps the dialog rendered and in the top layer until the fade finishes.",{"q":1899,"a":1900},"What does the overlay property do?","overlay reports whether an element is in the top layer. The browser sets it, not the author, but listing it in a transition with allow-discrete delays the element's removal from the top layer, which keeps a closing dialog above the page and its backdrop visible during the exit animation.",{"q":1830,"a":1902},"Transitions are the better fit because they reverse cleanly when a dialog is closed mid-opening. Keyframe animations work for entry but need a separate exit animation and cannot be interrupted smoothly, so they suit one-way effects better than open-and-close pairs.",{"q":1836,"a":1904},"It should not. The browser moves focus into the dialog and makes the rest of the page inert as soon as showModal() runs, regardless of the visual animation. Keep the entry short so the dialog is readable quickly, and disable movement for reduced-motion users.","\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Fanimating-dialog-open-and-close",{"title":5,"description":1890},"css-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Fanimating-dialog-open-and-close\u002Findex","z8azYGwKvl9nEh8pV35WSFNEhciH_zVzxN_bbrfVr4Y",[1910,1913,1916,1919,1922,1925,1928,1931,1934,1937,1940,1943,1946,1949,1952,1955,1958,1961,1964,1967,1970,1973,1976,1979,1982,1985,1988,1991,1994,1997,2000,2003,2006,2009,2012,2015,2018,2021,2024,2027,2030,2033,2036,2039,2040,2043,2046,2049,2052,2055,2058,2061,2064,2067,2070,2073,2076,2079,2082,2085,2088,2091,2094,2097,2100,2103,2106,2109,2112,2115,2118,2121,2124,2127,2130,2133,2136,2139,2142,2145,2148,2151,2154,2157,2160,2163,2166,2169,2172,2175,2178,2181,2184,2187,2189,2192,2195,2198,2201,2204,2207,2210,2213,2216,2219,2222,2225,2228,2231,2234,2237,2240,2243,2246,2249,2252,2255,2258,2261,2264,2267,2270,2273,2276,2279,2282,2285,2288,2291,2294,2297,2300,2303,2306,2309,2312,2315,2318,2321,2324,2327,2330,2333,2336,2339,2342,2345,2348,2351,2354,2357,2360,2363,2366,2369,2372,2375,2378,2381,2384,2387,2390,2393,2396,2399,2402,2405,2408,2411,2414,2417,2420,2423,2426,2429,2432,2435,2438,2441,2444,2447,2450,2453,2456,2459,2462,2465],{"path":1911,"title":1912},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fcreating-accessible-focus-indicators","Creating Accessible Focus Indicators: Building a Ring That Survives Any Background",{"path":1914,"title":1915},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fflashing-content-and-seizure-thresholds","Flashing Content and Seizure Thresholds",{"path":1917,"title":1918},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fforced-colors-mode-and-animations","Forced Colors Mode and Animations",{"path":1920,"title":1921},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations","Accessibility in CSS Animations: Patterns, Specs & Best Practices",{"path":1923,"title":1924},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fpause-controls-for-looping-animations","Pause Controls for Looping CSS Animations: Meeting WCAG 2.2.2",{"path":1926,"title":1927},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fprefers-reduced-motion-recipes","prefers-reduced-motion Recipes: A Reduction for Every Common Effect",{"path":1929,"title":1930},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Freducing-motion-preferences-in-css","Reducing Motion Preferences in CSS: How the Setting Becomes a Media Feature",{"path":1932,"title":1933},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Ftarget-size-and-pointer-accessibility","Target Size and Pointer Accessibility: Meeting 2.5.8 Without Redesigning",{"path":1935,"title":1936},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fvestibular-safe-animation-patterns","Vestibular-Safe Animation Patterns: Why Some Motion Makes People Sick",{"path":1938,"title":1939},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fwcag-motion-success-criteria","WCAG Motion Success Criteria: What Each One Actually Requires",{"path":1941,"title":1942},"\u002Fcss-only-micro-interactions-animations\u002Fclip-path-and-mask-animations\u002Fanimated-gradient-borders-with-property","Animated Gradient Borders With @property: A Spinning Highlight Without Extra Elements",{"path":1944,"title":1945},"\u002Fcss-only-micro-interactions-animations\u002Fclip-path-and-mask-animations\u002Fclip-path-reveal-animations","Clip-Path Reveal Animations: Wipes, Irises and Corners Without Extra Markup",{"path":1947,"title":1948},"\u002Fcss-only-micro-interactions-animations\u002Fclip-path-and-mask-animations","Clip-Path & Mask Animations: Animating Visibility Instead of Position",{"path":1950,"title":1951},"\u002Fcss-only-micro-interactions-animations\u002Fclip-path-and-mask-animations\u002Fmask-image-fade-edges","Fading Edges With mask-image: Soft Boundaries That Work on Any Background",{"path":1953,"title":1954},"\u002Fcss-only-micro-interactions-animations\u002Fclip-path-and-mask-animations\u002Fmorphing-shapes-with-clip-path-polygon","Morphing Shapes With clip-path: polygon(): Point-Matched Transitions",{"path":1956,"title":1957},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions\u002Fanimating-gradients","Animating CSS Gradients: Smooth Colour Motion Without Jumps",{"path":1959,"title":1960},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions\u002Fcolor-mix-hover-states","Hover and Active States With color-mix(): One Token, Every Shade",{"path":1962,"title":1963},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions","Color & Theme Transitions: Colour as Part of the Motion System",{"path":1965,"title":1966},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions\u002Flight-dark-function-for-themes","Light and Dark Themes With light-dark(): One Declaration per Colour",{"path":1968,"title":1969},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions\u002Fsmooth-theme-switching-transitions","Smooth Theme Switching: Crossfades, Circular Reveals and No Flash",{"path":1971,"title":1972},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Fcontainer-query-hover-affordances","Container Query Hover Affordances: When Narrow Means Persistent, Not Hidden",{"path":1974,"title":1975},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion","Container-Aware Motion: Animation Sized by the Space a Component Actually Has",{"path":1977,"title":1978},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Flayout-change-animations-at-container-breakpoints","Animating Changes at Container Breakpoints",{"path":1980,"title":1981},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Fmotion-driven-by-container-style-queries","Motion Driven by Container Style Queries",{"path":1983,"title":1984},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Fmotion-that-scales-with-container-size","Motion That Scales with Container Size: cqi, cqb, and Derived Durations",{"path":1986,"title":1987},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Fsuppressing-motion-in-small-containers","Suppressing Motion in Small Containers: Deliberately Animating Nothing",{"path":1989,"title":1990},"\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api\u002Fcontrolling-css-animations-from-javascript","Controlling CSS Animations From JavaScript",{"path":1992,"title":1993},"\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api","CSS Animation vs the Web Animations API: A Decision Guide",{"path":1995,"title":1996},"\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api\u002Fwaapi-vs-css-for-interruptible-ui","Interruptible UI: CSS Transitions vs WAAPI",{"path":1998,"title":1999},"\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api\u002Fwhen-to-use-javascript-animation","When to Use JavaScript Instead of CSS for Animation",{"path":2001,"title":2002},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Fanimating-custom-properties-with-at-property","Animating Custom Properties with @property: Typed Variables That Interpolate",{"path":2004,"title":2005},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Fcustom-property-fallbacks-and-invalid-values","Custom Property Fallbacks and Invalid Values",{"path":2007,"title":2008},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Ffluid-spacing-tokens-driving-transition-durations","Fluid Spacing Tokens That Drive Transition Durations",{"path":2010,"title":2011},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture","CSS Custom Properties Architecture: Scalable Design Systems & Dynamic UI",{"path":2013,"title":2014},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Fregistered-properties-and-type-safety","Registered Properties and Type Safety: @property as a Contract for Design Tokens",{"path":2016,"title":2017},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Fscoping-custom-properties-to-components","Scoping Custom Properties to Components",{"path":2019,"title":2020},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Fcss-transition-timing-functions","CSS Transition Timing Functions: ease, cubic-bezier(), steps() and linear()",{"path":2022,"title":2023},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals","CSS Transition Fundamentals: Architecture, Performance & Patterns",{"path":2025,"title":2026},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Finterrupted-and-reversing-transitions","Interrupted and Reversing Transitions: What Happens Mid-Flight",{"path":2028,"title":2029},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Fstarting-style-entry-animations","@starting-style: Animating an Element's Very First Style Change",{"path":2031,"title":2032},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Ftransition-delay-choreography","Choreographing Motion With transition-delay",{"path":2034,"title":2035},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Ftransition-shorthand-and-multiple-properties","The transition Shorthand and Multiple Properties",{"path":2037,"title":2038},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Ftransitioning-display-with-allow-discrete","Transitioning display with transition-behavior: allow-discrete and @starting-style",{"path":1905,"title":5},{"path":2041,"title":2042},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Fbackdrop-animations","Animating ::backdrop: Fades and Blurs Behind Dialogs and Popovers",{"path":2044,"title":2045},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations","Dialog & Popover Animations: Motion for the Top Layer",{"path":2047,"title":2048},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Finterpolate-size-for-height-auto-animation","Animating to height: auto With interpolate-size and calc-size()",{"path":2050,"title":2051},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Fpopover-entry-and-exit-transitions","Popover Menus That Animate From Their Anchor",{"path":2053,"title":2054},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Fchoosing-animation-durations","Choosing Animation Durations: How Long Motion Should Last",{"path":2056,"title":2057},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Fcubic-bezier-overshoot-and-anticipation","Overshoot and Anticipation With cubic-bezier(): Motion With Character",{"path":2059,"title":2060},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Fentry-vs-exit-easing","Entry vs Exit Easing: Different Curves for Arriving and Leaving",{"path":2062,"title":2063},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design","Easing & Motion Design: Making CSS Motion Feel Intentional",{"path":2065,"title":2066},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Flinear-easing-function-for-springs","Spring and Bounce Easing With linear(): Physical Motion Without JavaScript",{"path":2068,"title":2069},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Fsteps-easing-for-sprite-animations","steps() Easing: Sprite Sheets, Typewriters and Other Frame-by-Frame Effects",{"path":2071,"title":2072},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Faccessible-css-only-tooltips","Accessible CSS-Only Tooltips and Hover Cards With  and ",{"path":2074,"title":2075},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Fbutton-press-and-active-states","Button Press and  States",{"path":2077,"title":2078},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Ffocus-visible-vs-focus-polyfill-alternatives"," vs :focus: Why It Replaced the Focus-Ring Polyfill",{"path":2080,"title":2081},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Ffocus-within-form-patterns"," Form Patterns: Styling a Group From the Field Inside It",{"path":2083,"title":2084},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Fhover-intent-delays-with-transition-delay","Hover Intent Delays With transition-delay: Menus That Don't Flicker",{"path":2086,"title":2087},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design","Hover & Focus State Design: Spec-Compliant Patterns for Modern UIs",{"path":2089,"title":2090},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Fpointer-and-hover-media-queries","Pointer and Hover Media Queries: Gating Affordances by Input Capability",{"path":2092,"title":2093},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Fsmooth-hover-effects-without-javascript","Smooth Hover Effects Without JavaScript: CSS-Only Patterns for Modern UI",{"path":2095,"title":2096},"\u002Fcss-only-micro-interactions-animations","CSS-Only Micro-Interactions & Animations: Architecture, Performance & Implementation",{"path":2098,"title":2099},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fanimation-composition-and-stacking","Stacking Animations With animation-composition",{"path":2101,"title":2102},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fanimation-fill-mode-explained","animation-fill-mode: What an Animation Applies Before and After It Runs",{"path":2104,"title":2105},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fcontainer-query-triggered-keyframe-animations","Container-Query-Triggered Keyframe Animations: Animate Differently per Available Space",{"path":2107,"title":2108},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fcss-only-accordions-and-disclosure","CSS-Only Accordions and Disclosure Widgets with details and summary",{"path":2110,"title":2111},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fcss-only-loading-spinners-and-skeletons","CSS-Only Loading Spinners and Skeleton Shimmer Screens with @keyframes",{"path":2113,"title":2114},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fcss-only-toggle-switches-and-checkboxes","CSS-Only Toggle Switches and Checkboxes That Keep the Native Input",{"path":2116,"title":2117},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns","Keyframe Animation Patterns: Spec-Compliant Architectures for Modern UIs",{"path":2119,"title":2120},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fmulti-step-keyframes-and-per-keyframe-easing","Multi-Step Keyframes and Per-Keyframe Easing",{"path":2122,"title":2123},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fstaggered-list-animations-with-custom-properties","Staggered List Animations Using --i Index Custom Properties",{"path":2125,"title":2126},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fanimating-box-shadow-and-filters-cheaply","Animating box-shadow and Filters Cheaply",{"path":2128,"title":2129},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fcontain-property-for-animation-performance","The contain Property for Animation Performance",{"path":2131,"title":2132},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fcss-triggers-layout-paint-composite","Layout, Paint and Composite: What Triggers What",{"path":2134,"title":2135},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration","Performance & GPU Acceleration in CSS: A Developer’s Blueprint",{"path":2137,"title":2138},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Foptimizing-css-animations-for-60fps","Optimizing CSS Animations for 60fps: Budgeting the Frame",{"path":2140,"title":2141},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fprofiling-animations-in-devtools","Profiling CSS Animations in DevTools: Finding the Frame That Costs Too Much",{"path":2143,"title":2144},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fwill-change-and-the-compositor-thread","will-change and the Compositor Thread: Layer Promotion Without the Footguns",{"path":2146,"title":2147},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations","Scroll-Driven Animations: Binding Motion to Scroll Position in Pure CSS",{"path":2149,"title":2150},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-driven-animation-fallbacks","Shipping Scroll-Driven Animations Without Breaking Anything",{"path":2152,"title":2153},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-driven-parallax-effects","Scroll-Driven Parallax Effects in CSS",{"path":2155,"title":2156},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-progress-bar-without-javascript","A Reading Progress Bar Driven by scroll(root)",{"path":2158,"title":2159},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-triggered-reveal-animations","Reveal-on-Scroll with view() and animation-range",{"path":2161,"title":2162},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Ftimeline-scope-for-cross-element-animations","timeline-scope for Cross-Element Animations",{"path":2164,"title":2165},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fview-timeline-and-animation-range","View Timelines and animation-range",{"path":2167,"title":2168},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fcross-document-view-transitions","Cross-Document View Transitions",{"path":2170,"title":2171},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers","View Transitions for CSS Developers: the Pseudo-Element Tree, Snapshots, and Named Elements",{"path":2173,"title":2174},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fsame-document-view-transitions","Writing a Same-Document View Transition: the CSS You Actually Author",{"path":2176,"title":2177},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fview-transition-names-shared-elements","view-transition-name and Shared Elements: Morphing a Thumbnail into a Hero",{"path":2179,"title":2180},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fview-transition-types-and-classes","View Transition Types and Classes",{"path":2182,"title":2183},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fview-transitions-for-list-reordering","View Transitions for List Reordering",{"path":2185,"title":2186},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fview-transitions-with-reduced-motion","Honouring prefers-reduced-motion in View Transitions",{"path":366,"title":2188},"Modern CSS Layouts & Micro-Interactions",{"path":2190,"title":2191},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fanchor-positioned-tooltips","Anchor-Positioned Tooltips: Tethering, Flipping, and Getting the Semantics Right",{"path":2193,"title":2194},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fanchor-positioning-fallbacks","Anchor Positioning Fallbacks: A Graceful Floor for Older Browser Versions",{"path":2196,"title":2197},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fanchor-size-for-matching-widths","anchor-size(): Overlays That Match Their Trigger's Size",{"path":2199,"title":2200},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays","CSS Anchor Positioning and Overlays: Tethering Elements Without JavaScript",{"path":2202,"title":2203},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fpopover-attribute-and-css-styling","The popover Attribute: Top-Layer Overlays With No JavaScript",{"path":2205,"title":2206},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fpopover-light-dismiss-and-stacking","Popover Light Dismiss, Nesting and Stacking",{"path":2208,"title":2209},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fposition-area-grid-explained","position-area: The Anchor Placement Grid",{"path":2211,"title":2212},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Fcontainer-query-polyfill-tradeoffs","Container Query Polyfills: What They Cost and When to Skip Them",{"path":2214,"title":2215},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Ffeature-detection-with-supports","Feature Detection with @supports: Syntax, Semantics, and the Traps",{"path":2217,"title":2218},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Fhandling-container-query-fallbacks-for-older-browsers","Handling Container Query Fallbacks for Older Browsers",{"path":2220,"title":2221},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks","Container Query Fallbacks: Spec-Compliant CSS Strategies for Legacy Browsers",{"path":2223,"title":2224},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Fintrinsic-layout-fallbacks-without-queries","Intrinsic Layout Fallbacks: Baselines That Adapt Without Any Query",{"path":2226,"title":2227},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Ftesting-fallbacks-without-old-browsers","Testing CSS Fallbacks Without an Old Browser",{"path":2229,"title":2230},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-queries-inside-css-nesting","Container Queries Inside CSS Nesting: Keeping Responses Next to the Styles They Change",{"path":2232,"title":2233},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-query-range-and-logic-operators","Container Query Range Syntax and Logic Operators",{"path":2235,"title":2236},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-query-units-cqi-cqb-explained","Container Query Units Explained: cqi, cqb, cqw, cqh, cqmin and cqmax",{"path":2238,"title":2239},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-type-size-vs-inline-size","Choosing container-type: inline-size, size, or normal",{"path":2241,"title":2242},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-vs-media-queries-comparison","Container vs Media Queries: Choosing the Right Reference Box",{"path":2244,"title":2245},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fdebugging-container-queries-in-devtools","Debugging Container Queries in DevTools: Why a Rule Doesn't Match",{"path":2247,"title":2248},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fhow-to-use-container-queries-in-production","How to Use Container Queries in Production Without a Rewrite",{"path":2250,"title":2251},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics","Container Query Syntax Basics",{"path":2253,"title":2254},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fnesting-and-naming-container-queries","Nesting and Naming Container Queries: Targeting the Right Ancestor",{"path":2256,"title":2257},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fauto-fit-minmax-responsive-grids","Responsive Grids with repeat(auto-fit, minmax())",{"path":2259,"title":2260},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fbuilding-a-dashboard-with-subgrid","Building a Responsive Dashboard Where Cards Align with Subgrid",{"path":2262,"title":2263},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fgrid-auto-flow-dense-packing","grid-auto-flow: dense for Packed Layouts",{"path":2265,"title":2266},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fgrid-template-areas-responsive-layouts","Responsive Layouts With grid-template-areas: Rearranging Regions by Name",{"path":2268,"title":2269},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fholy-grail-layout-with-grid","The Holy-Grail Layout with CSS Grid and Container Queries",{"path":2271,"title":2272},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts","CSS Grid and Subgrid Layouts for Responsive Interfaces",{"path":2274,"title":2275},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fmasonry-style-layouts-with-grid","Masonry-Style Layouts With the CSS That Ships Today",{"path":2277,"title":2278},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Foverlapping-elements-with-grid-stacking","Overlapping Elements With Grid Stacking: Layers Without position: absolute",{"path":2280,"title":2281},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fsubgrid-vs-nested-grid","Subgrid vs an Independently Nested Grid",{"path":2283,"title":2284},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fcentering-in-css-every-method","Centering in CSS: Every Modern Method and When Each One Breaks",{"path":2286,"title":2287},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fflex-basis-vs-width","flex-basis vs width: Which Size a Flex Item Actually Starts From",{"path":2289,"title":2290},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fflex-grow-and-flex-shrink-explained","flex-grow and flex-shrink Explained",{"path":2292,"title":2293},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fflex-wrap-intrinsic-responsive-rows","Breakpoint-Free Responsive Rows With flex-wrap and flex-basis",{"path":2295,"title":2296},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fflexbox-gap-and-spacing","Flexbox gap vs Margins: Spacing Items Without Edge Hacks",{"path":2298,"title":2299},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns","Flexbox Layout Patterns: One-Dimensional Layout for Real Components",{"path":2301,"title":2302},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fsticky-footer-with-flexbox-and-grid","Sticky Footer With Flexbox or Grid: Pinning the Footer on Short Pages",{"path":2304,"title":2305},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Fclamp-vs-media-query-typography","clamp() Fluid Type vs Media-Query Step Typography: Tradeoffs and Anatomy",{"path":2307,"title":2308},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Fdebugging-clamp-values","Debugging clamp(): Values That Are Ignored, Stuck or Never Fluid",{"path":2310,"title":2311},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Ffluid-line-height-and-measure","Fluid Line Height and Measure: Keeping Text Readable as It Scales",{"path":2313,"title":2314},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Ffluid-space-scale-with-clamp","Building a Fluid Spacing Scale with clamp() and Container Units",{"path":2316,"title":2317},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Ffluid-type-accessibility-and-zoom","Fluid Type, Accessibility and Zoom: The vw-Only Trap",{"path":2319,"title":2320},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Ffluid-typography-without-javascript","Fluid Typography Without JavaScript: A Precision CSS Reference",{"path":2322,"title":2323},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp","Fluid Typography with clamp(): A Practical Guide for Modern CSS",{"path":2325,"title":2326},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Ftext-wrap-balance-and-pretty","text-wrap: balance and pretty: Better Line Breaks Without Manual Breaks",{"path":2328,"title":2329},"\u002Fmastering-container-queries-responsive-layouts","Mastering Container Queries & Responsive Layouts",{"path":2331,"title":2332},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Faspect-ratio-for-responsive-media","Using aspect-ratio for Responsive Media and Preventing Layout Shift",{"path":2334,"title":2335},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fcontent-visibility-and-contain-intrinsic-size","content-visibility and contain-intrinsic-size: Rendering Only What Is Near the Screen",{"path":2337,"title":2338},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques","Intrinsic Sizing Techniques: Modern CSS Layouts for Responsive UI",{"path":2340,"title":2341},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Flayout-widths-with-min-max-clamp","Layout Widths With min(), max() and clamp(): Sizing Without Breakpoints",{"path":2343,"title":2344},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fmin-max-fit-content-explained","min-content, max-content, and fit-content() Explained",{"path":2346,"title":2347},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fobject-fit-and-object-position","object-fit and object-position: Images That Fit Any Box",{"path":2349,"title":2350},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fpreventing-flex-and-grid-overflow","The min-width: auto Trap in Flex and Grid Layouts",{"path":2352,"title":2353},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fcascade-layers-for-reset-and-tokens","Cascade Layers for Reset and Design Tokens",{"path":2355,"title":2356},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fcascade-layers-vs-specificity-hacks","Cascade Layers vs Specificity Hacks: Ordering Instead of Escalating",{"path":2358,"title":2359},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fcss-scope-for-component-styles","@scope for Component Styles: Short Selectors That Cannot Leak",{"path":2361,"title":2362},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies","Modern CSS Reset Strategies: A Spec-Compliant Foundation",{"path":2364,"title":2365},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Frevert-layer-and-revert-keywords","initial, inherit, unset, revert and revert-layer: Undoing Styles Correctly",{"path":2367,"title":2368},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fwriting-a-minimal-modern-reset","Writing a Minimal Modern CSS Reset: Every Line Justified",{"path":2370,"title":2371},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fcontent-aware-card-layouts-with-has","Content-Aware Card Layouts With :has(): One Component, Many Shapes",{"path":2373,"title":2374},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fempty-and-loading-states-with-has","Empty and Loading States With ()",{"path":2376,"title":2377},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fform-validation-layouts-with-has","Form Validation Layouts With :has(): Styling Groups From Field State",{"path":2379,"title":2380},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fhas-selector-performance",":has() Selector Performance: What Is Cheap, What Is Not, and How to Measure",{"path":2382,"title":2383},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fhas-vs-container-style-queries",":has() vs Container Style Queries: Discovered State and Published State",{"path":2385,"title":2386},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has","Parent-Aware Layouts With :has(): Letting Containers React to Their Contents",{"path":2388,"title":2389},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fquantity-queries-with-has","Quantity Queries With :has(): Layouts That Respond to How Many Items There Are",{"path":2391,"title":2392},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fbuilding-responsive-cards-with-container-queries","Building Responsive Cards with Container Queries: A Production-Ready Guide",{"path":2394,"title":2395},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fcontainer-query-data-tables","Container Query Data Tables: Reflowing Tables to Cards",{"path":2397,"title":2398},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fcontainer-query-sidebar-layouts","Container Query Sidebar Layouts That Travel Between Contexts",{"path":2400,"title":2401},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns","Responsive Component Patterns: Architecture & Implementation",{"path":2403,"title":2404},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-forms-with-container-queries","Responsive Forms with Container Queries: Reflow Without Losing the Wiring",{"path":2406,"title":2407},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-hero-sections-with-container-queries","Responsive Hero Sections With Container Queries",{"path":2409,"title":2410},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-navigation-without-media-queries","Responsive Navigation Without Media Queries Using Container Queries",{"path":2412,"title":2413},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-pricing-tables","Responsive Pricing Tables: Aligned Features, a Clear Recommendation, Any Width",{"path":2415,"title":2416},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Ftabs-that-become-accordions","Tabs That Become an Accordion: One Component, Two Layouts",{"path":2418,"title":2419},"\u002Fmastering-container-queries-responsive-layouts\u002Fscroll-snap-and-overflow-layouts\u002Fcss-only-carousel-with-scroll-snap","A CSS-Only Carousel With Scroll Snap",{"path":2421,"title":2422},"\u002Fmastering-container-queries-responsive-layouts\u002Fscroll-snap-and-overflow-layouts\u002Fhorizontal-scrolling-card-rows","Horizontal Scrolling Card Rows: Swipeable Lists That Stay in Their Lane",{"path":2424,"title":2425},"\u002Fmastering-container-queries-responsive-layouts\u002Fscroll-snap-and-overflow-layouts","Scroll Snap & Overflow Layouts: Designing Components That Scroll on Purpose",{"path":2427,"title":2428},"\u002Fmastering-container-queries-responsive-layouts\u002Fscroll-snap-and-overflow-layouts\u002Foverscroll-behavior-for-nested-scrolling","overscroll-behavior: Taming Nested Scrolling, Pull-to-Refresh and Back-Swipe",{"path":2430,"title":2431},"\u002Fmastering-container-queries-responsive-layouts\u002Fscroll-snap-and-overflow-layouts\u002Fscroll-margin-and-scroll-padding-for-sticky-headers","scroll-margin and scroll-padding: Keeping Targets Clear of Sticky Headers",{"path":2433,"title":2434},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state\u002Fcombining-size-and-style-queries","Combining Size and Style Container Queries",{"path":2436,"title":2437},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state\u002Fcontainer-style-query-theming","Container Style Query Theming: One Token Instead of a Variant Class Matrix",{"path":2439,"title":2440},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state","Style Queries and Container State: Token-Driven Component Variants",{"path":2442,"title":2443},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state\u002Fstyle-queries-with-custom-properties","Style Queries With Custom Properties: Declaring, Inheriting, and Matching Tokens",{"path":2445,"title":2446},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state\u002Fstyle-query-component-variants","Component Variants With Style Queries: One Token, Many Looks",{"path":2448,"title":2449},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state\u002Fstyle-query-fallbacks-and-support","Style Query Fallbacks and Support: Designing for Older Browser Versions",{"path":2451,"title":2452},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout\u002Fdvh-svh-lvh-mobile-viewport-units","dvh, svh and lvh: Choosing the Right Mobile Viewport Unit",{"path":2454,"title":2455},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout\u002Ffull-bleed-sections-in-constrained-layouts","Full-Bleed Sections in a Constrained Layout: Breaking Out Without Breaking the Page",{"path":2457,"title":2458},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout","Viewport Units & Mobile Layout: Designing for the Screen You Actually Get",{"path":2460,"title":2461},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout\u002Fsafe-area-insets-for-notched-screens","Safe Area Insets: Designing Around Notches, Corners and Home Indicators",{"path":2463,"title":2464},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout\u002Fviewport-units-vs-container-units","Viewport Units vs Container Units: Choosing the Right Reference Box",{"path":2466,"title":2467},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout\u002Fvirtual-keyboard-and-interactive-widget","Layouts That Survive the Virtual Keyboard",{"title":2469,"caption":2470,"height":2471,"html":2472,"css":2473},"The dialog recipe applied to a script-free popover","Click the button to open, then click outside or press Escape: the panel fades and scales in over 240ms and out over 160ms.",300,"\n\u003Cbutton class=\"open\" type=\"button\" popovertarget=\"confirm\">Delete project…\u003C\u002Fbutton>\n\u003Cdiv id=\"confirm\" popover aria-labelledby=\"confirm-title\">\n  \u003Ch2 id=\"confirm-title\">Delete this project?\u003C\u002Fh2>\n  \u003Cp>This removes all files and cannot be undone.\u003C\u002Fp>\n  \u003Cbutton type=\"button\" popovertarget=\"confirm\" popovertargetaction=\"hide\">Cancel\u003C\u002Fbutton>\n\u003C\u002Fdiv>","\n.open, [popover] button { font: inherit; padding: 0.45rem 0.9rem; border-radius: 8px; border: 1px solid var(--demo-border); background: var(--demo-surface); color: inherit; }\n[popover] {\n  width: min(90vw, 22rem);\n  padding: 1.25rem;\n  border: 0;\n  border-radius: 14px;\n  background: var(--demo-bg);\n  color: var(--demo-fg);\n  box-shadow: 0 20px 50px rgb(15 23 42 \u002F 0.3);\n  opacity: 0;\n  scale: 0.96;\n  translate: 0 0.5rem;\n  transition:\n    opacity 160ms cubic-bezier(0.64, 0, 0.78, 0),\n    scale 160ms cubic-bezier(0.64, 0, 0.78, 0),\n    translate 160ms cubic-bezier(0.64, 0, 0.78, 0),\n    display 160ms allow-discrete,\n    overlay 160ms allow-discrete;\n}\n[popover] h2 { margin: 0 0 0.4rem; font-size: 1.1rem; }\n[popover] p { margin: 0 0 1rem; }\n[popover]:popover-open {\n  opacity: 1;\n  scale: 1;\n  translate: 0 0;\n  transition:\n    opacity 240ms cubic-bezier(0.22, 1, 0.36, 1),\n    scale 240ms cubic-bezier(0.22, 1, 0.36, 1),\n    translate 240ms cubic-bezier(0.22, 1, 0.36, 1),\n    display 240ms allow-discrete,\n    overlay 240ms allow-discrete;\n}\n@starting-style {\n  [popover]:popover-open { opacity: 0; scale: 0.96; translate: 0 0.5rem; }\n}\n@media (prefers-reduced-motion: reduce) {\n  [popover], [popover]:popover-open { scale: 1; translate: 0 0; }\n}\nbutton:focus-visible { outline: 2px solid var(--demo-accent); outline-offset: 2px; }",1789717746815]