Every now and then, we need a disclosure component. That is, an element that contains additional information, hidden by default, and revealed when interacted with. In html there is a native element, called details, which is exactly that. So why the need for a custom component? The main reason is for animating the transition between states. Animating the details tag properly is not trivial. The reason being, that details does not render its content (except for the summary) until it is opened.
For that reason, many implementations avoid using a details tag at all, with the consequence of losing the semantic meaning of the element, and browser behavior such as allowing the user to search for the content of the details tag and automatically opening it if necessary (chromium-based browser, hopefully others soon).
Play around with these details, you can also set the animation speed by using the buttons at the bottom of this card
details component click on this summary to expand or collapse itThis is the content of the details component. It can be any content, including images, videos, and other detailscomponents.
detailsAnd the nested content that goes with it, you can nest as much details as you need. If you use Chrome, Edge, Brave, or any other chromium-based browser, try closing both details and use your browser search feature (cmd/ctrl+f) and search for baNaNa. Both details will open back with your search result.
details within the first nested detailsAnd the nested content that goes with it, you can nest as much details as you need. If you use Chrome, try closing all details and use your browser search feature (cmd/ctrl+f) and search for baNaNa. All details will open back with your search result.
details tagdetails should be animateddetails again, the new animation duration should match with the previous animationdetails tag should open the detailstag