Skip to content

Commit f2a453a

Browse files
committed
fix: <details> collapse animation. closes: #4128
1 parent 58add58 commit f2a453a

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

packages/daisyui/src/components/collapse.css

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,20 @@
165165

166166
.collapse:is(details) {
167167
width: 100%;
168-
168+
@media (prefers-reduced-motion: no-preference) {
169+
@supports (transition: content-visibility allow-discrete) and (interpolate-size: allow-keywords) {
170+
&::details-content {
171+
transition:
172+
content-visibility 0.2s allow-discrete,
173+
height 0.2s;
174+
height: 0;
175+
interpolate-size: allow-keywords;
176+
}
177+
&:where([open], .collapse-open)::details-content {
178+
height: auto;
179+
}
180+
}
181+
}
169182
& summary {
170183
position: relative;
171184
display: block;

packages/docs/src/routes/(routes)/components/collapse/+page.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,6 @@ classnames:
8888
</details>
8989
```
9090

91-
<div class="alert text-sm mt-4">
92-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="stroke-current shrink-0 w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
93-
<div>Using <code>&lt;details&gt;</code> tag, we can't have animations because <code>&lt;details&gt;</code> tag doesn't allow CSS transitions.</div>
94-
</div>
95-
9691
### ~Without border and background color
9792

9893
<div tabindex="0" class="collapse">

0 commit comments

Comments
 (0)