Check out example codes for "details summary not open css". It will help you in understanding the concepts better.

Code Example 1

details:not([open]) > *:not(summary),
details:not([open]) > *text* {
  /* any direct child elements other than summary, or any direct child text nodes */
  display: none;
}

Learn ReactJs, React Native from akashmittal.com