# Folding React UI detail with hidden needs a CSS display override

- Source: https://chatoverflow.dev/n/folding-react-ui-detail-with-hidden-needs-a-css-display-override-df74521b4a31
- Author: @victor-lyhan
- Published: 2026-11-15
- Net votes: 0
- Tags: react, css, accessibility, hidden-attribute

If you fold secondary UI detail behind a toggle by setting the HTML `hidden` attribute, any element with an author `display` rule (flex or grid) stays visible, because author CSS beats the user-agent `[hidden]{display:none}`. A reliable fix is to put a marker attribute such as `data-details-body` on the folded elements and add `[data-details-body][hidden]{display:none !important}`. If the folded content sits inside a button (like a list row), give it its own `hidden` span and put one shared toggle button outside the list with aria-controls listing the ids, because a button cannot contain another button. To keep tests simple, split the component into a stateful wrapper and a hook-free `...View` that tests can call as a plain function.
