CollapsibleCard: add animations#76378
Conversation
|
Size Change: 0 B Total Size: 8.75 MB ℹ️ View Unchanged
|
|
Flaky tests detected in 0de2140. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23196476077
|
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
The animation likely needs refinements. Happy to apply any feedback myself, but also feel free to take over this PR (especially from @WordPress/gutenberg-design ) and apply changes directly. |
|
Nice work. I'd love @fcoveram input if he has capacity, he's been looking into adjacent behaviors for the command palette, seems like principles here could/should be the same. The main thing that I'm personally stuck on is: the animation here is a a little bit of flair applied to the contents, which move and fade in. In fact to be true to the materials, if we imagined this was a physical card that was somehow folded (I know, physical cards don't behave like this), then the contents inside would not be animated at all: that would be printed on the paper itself, immutable. The thing that would animate is the card itself. So in that vein, this feels a bit upside down to me, I'd expect the text that gets revealed to always be visible, to not animate, to not fade, but for the card itself to disclose it with animation. Can the card itself animate instead of the contents? |
It technically can, but since cards are often part of the document flow, animating the card itself would also animate the layout of the surrounding content. On long settings pages this could feel visually overwhelming, since a large portion of the page would be shifting at the same time. It may also be more expensive performance-wise compared to animating only the inner content. |
Valid and good point, though is there a way we can avoid that while still embracing the concept? Something like jump almost to the end of the animation and animate only the last 5% of the height? Perhaps even reserving the final height space already, so there's only a single jump in the content. The alternative breaks principles as far as what gets animated, IMO. Not a strong opinion and will definitely defer to others, but I'd almost prefer no animation in this case. |
This feels a bit difficult to implement / overengineered. Another alternative solution to evaluate could be to:
It's still a non-trivial animation to implement. Let's hear other folks' thoughts before moving forward. Happy also to implement a few variations (full height animations, or the most advanced behaviours discussed above) to get a better feeling for it |
|
I do agree that animating the root would be nice to try (like |
Agree with this approach.
I’m not sure about this solution. There will be a small portion of time where the white space is visible. In that vein, the base UI examples shared by Jay move the whole layout, and it doesn't feel distracting. I feel the outcome will be similar to the update in popover (#74082). |
5d5938f to
0b1592e
Compare
|
@fcoveram as shared before, given how often
Which is why I discouraged animating the height like in the Having said that, I went ahead and implemented it. Kapture.2026-03-13.at.18.30.43.mp4Happy to follow your guidance here on the next steps, including trying this animation and coming back to the drawing board if needed |
CollapsibleCard: add animations
e22c71f to
1c636e7
Compare
| &[hidden]:not([hidden="until-found"]) { | ||
| display: none; | ||
| } |
There was a problem hiding this comment.
The changes to DOM structure and styles actually now make adding hiddenUntilFound trivial (cc @mirka who suggested it in #76280 (review) )
1c636e7 to
9d0206a
Compare
|
@ciampo would it be worth adding a (maybe temporary) story with multiple stacked collapsible cards with varying content to test? |
I understand, but I also don't see a solution where the implementation doesn’t account for the layout and how the card is placed next to other content.
I follow your expertise here. The video shared above looks good to me. Nothing to add from the visual and interaction side. |
|
Added a storybook example. Here's a video Kapture.2026-03-16.at.17.02.42.mp4It doesn't look too bad, but also, Storybook is not as complex as a real app, and my machine is quite fast. Still, I believe we should ship this and keep an eye. Removing the animation wll be easy and non-breaking, anyway. |
9d0206a to
099b0ae
Compare
|
I think this is fine. Seeing a big stack of collapsible cards like that makes me a bit cold on the pattern in general; it's so easy to lose your place in the document when you begin expanding/collapsing, especially as scroll position can change. We might want to add some guidance about that (separately). That would help with any performance concerns too. |
Replace dual chevron icon swap (chevronUp/chevronDown) with a single chevronDown icon that rotates 180° via CSS when the panel is open. The rotation uses the `data-panel-open` attribute set by Base UI's Collapsible.Trigger. The CSS transition is gated behind `prefers-reduced-motion: no-preference` so the icon still flips instantly for users who prefer reduced motion. Made-with: Cursor
Animate the collapsible content panel with a subtle opacity fade and vertical translation (-4px) on open/close. Uses Base UI's `data-starting-style` and `data-ending-style` attributes on the Collapsible.Panel element. Height changes remain instant — only the content appearance is animated. The transition is gated behind `prefers-reduced-motion: no-preference`. Made-with: Cursor
Remove the exit (close) animation — with instant height changes, a fade-out has no visible effect. Keep only the enter (open) animation by defining the transition on `[data-open]` so it's absent when the panel closes and Base UI hides it immediately. Add a 50ms delay to the open transition so the container snaps open first, then the content fades in. Also move `data-starting-style` state outside the media query to match the Dialog component pattern — only the `transition` property is gated behind `prefers-reduced-motion`. Made-with: Cursor
099b0ae to
0de2140
Compare
What
Add open/close animations to the
CollapsibleCardcomponent in@wordpress/ui.Why
Add visual polish
How
Animations are disabled when reduced motion id preferred.
Testing Instructions
npm startScreen capture
Kapture.2026-03-13.at.18.30.43.mp4