News for hackers. Stuff that matters.
Re:Just Use a Button by Joker_vD on Friday October 31, 2025 @02:05PM (#45774882)
Well, have you been on, I don't know, TV Tropes? They have those long lists, that are separated into "folders" on a single page. You can click on those "folders" to expand/collapse them, and it's implemented as a <div> with "onclick" property and <ul> inside it (well, used to IIRC; nowadays this <ul> is a child of a sibling <div>).
Re:Just Use a Button by 1-more on Friday October 31, 2025 @03:17PM (#45775658)
what's annoying about that example is that all of those <div>s could be buttons with no other changes. The only content inside the button <div> is the title and folder icon, not the list of examples associated with that title. That's just fine for a button!

The other thing I'd do is add `aria-controls=folder0` to the button that toggles visibility of the list with `id=folder0`

Re:Just Use a Button by no_wizard on Friday October 31, 2025 @04:40PM (#45776461)
I'll do you one better and argue they could `<details>` elements. This is a perfect use case for that.
Re:Just Use a Button by 1-more on Friday October 31, 2025 @05:45PM (#45777052)
I use them EXTENSIVELY but some don't like them for being annoying to control en-masse with the "toggle all folders" button at the top. But yeah I 100% agree with you. I've snuck them into a webapp where I just needed that much local state rather than have the whole page's state care about the collapse/open state of that one thing.
Re:Just Use a Button by zahlman on Friday October 31, 2025 @07:09PM (#45777722)
> You can click on those "folders" to expand/collapse them, and it's implemented as a <div> with

... Isn't that what <details> and <summary> are for?