Animating the <details> Marker Triangle

Moritz Gießmann has published a small CodePen demo that animates the triangle on a <details> element. That triangle is the affordance signaling that the element can be opened; animating it adds a second signal, telling the user the element is opening right now.

The technique rests on three steps:

  1. The default marker has to go, since it cannot be animated: details summary::-webkit-details-marker { display:none; }.
  2. A replacement triangle is drawn with the CSS border trick inside a pseudo element.
  3. When the element is open, the new triangle is rotated with details[open] > summary::before { transform: rotate(90deg); }.

This covers the triangle only — the content inside the element still snaps open. For a smoother reveal, the same article points to Louis Hoebregts' "How to Animate the Details Element Using WAAPI". A fork combining both approaches is also mentioned.

One detail worth noting: Moritz places cursor: pointer; on the summary, matching Greg Gibson's suggestion.

CSS-Tricks star logo