Skip to content

Commit 3a7919a

Browse files
authored
fix: menu animation for 1st level menu in menu-horizontal (#4278)
* fix: menu animation for 1st level menu in menu-horizontal - animation is similar to the one in dropdown - also revert the changes done to 1st level menu if menu-vertical is used example: https://play.tailwindcss.com/rihKTE49dm?file=css ref #4273 * chore: reorder classes order after changes
1 parent 9b20759 commit 3a7919a

File tree

1 file changed

+37
-9
lines changed

1 file changed

+37
-9
lines changed

packages/daisyui/src/components/menu.css

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,32 @@
158158
@layer daisyui.l1.l2 {
159159
@apply inline-flex flex-row;
160160

161-
& > li:not(.menu-title) > details > ul {
162-
@apply absolute ms-0 mt-4 py-2 pe-2;
161+
& > li:not(.menu-title) > details {
162+
& > ul {
163+
@apply bg-base-100 rounded-box absolute ms-0 mt-4 origin-top py-2 pe-2 opacity-0;
164+
scale: 95%;
165+
box-shadow:
166+
0 1px 3px 0 oklch(0% 0 0/0.1),
167+
0 1px 2px -1px oklch(0% 0 0/0.1);
168+
169+
@media (prefers-reduced-motion: no-preference) {
170+
@starting-style {
171+
scale: 95%;
172+
opacity: 0;
173+
}
174+
175+
animation: menu 0.2s;
176+
transition-property: opacity, scale, display;
177+
transition-behavior: allow-discrete;
178+
transition-duration: 0.2s;
179+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
180+
}
181+
}
182+
183+
&[open] > ul {
184+
@apply opacity-100;
185+
scale: 100%;
186+
}
163187
}
164188

165189
& > li > details > ul {
@@ -168,13 +192,6 @@
168192
content: var(--tw-content);
169193
}
170194
}
171-
172-
:where(& > li:not(.menu-title) > details > ul) {
173-
@apply bg-base-100 rounded-box;
174-
box-shadow:
175-
0 1px 3px 0 oklch(0% 0 0/0.1),
176-
0 1px 2px -1px oklch(0% 0 0/0.1);
177-
}
178195
}
179196
}
180197

@@ -184,6 +201,11 @@
184201

185202
& > li:not(.menu-title) > details > ul {
186203
@apply relative ms-4 mt-0 py-0 pe-0;
204+
background-color: revert-layer;
205+
border-radius: revert-layer;
206+
animation: revert-layer;
207+
transition: revert-layer;
208+
box-shadow: revert-layer;
187209
}
188210
}
189211
}
@@ -268,3 +290,9 @@
268290
background-image: none, var(--fx-noise);
269291
}
270292
}
293+
294+
@keyframes menu {
295+
0% {
296+
opacity: 0;
297+
}
298+
}

0 commit comments

Comments
 (0)