-
Notifications
You must be signed in to change notification settings - Fork 3
/
dropdown-animation.html
43 lines (40 loc) · 2.2 KB
/
dropdown-animation.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Click Dropdown Animation</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="//unpkg.com/alpinejs" defer></script>
</head>
<style>
[x-cloak] { display: none !important;}
</style>
<body>
<div class="bg-gray-200 flex min-h-screen items-center justify-center ">
<div x-cloak class="inline-block relative" x-data="{open: false}">
<button @click="open = !open" @click.away="open = false"
class="focus:outline-none shadow cursor-pointer inline-block text-gray-700 hover:text-gray-900 flex border border-gray-200 rounded p-2 pl-3 pr-1 bg-gray-100"
:class="{ 'shadow-none border-gray-300': open}">
Click dropdown
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" :class="{'-rotate-180': open}"
class="ml-1 transform duration-200 inline-block fill-current text-gray-500 w-6 h-6">
<path fill-rule="evenodd" d="M15.3 10.3a1 1 0 011.4 1.4l-4 4a1 1 0 01-1.4 0l-4-4a1 1 0 011.4-1.4l3.3 3.29 3.3-3.3z" />
</svg>
</button>
<ul x-show="open" class="bg-white absolute left-0 shadow w-full rounded text-gray-600 origin-top shadow-lg"
x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="opacity-0 transform scale-y-50"
x-transition:enter-end="opacity-100 transform scale-y-100"
x-transition:leave="transition ease-in duration-200"
x-transition:leave-end="opacity-0 transform scale-y-50">
<li><a href="#" class="py-1 px-3 border-b block hover:bg-gray-200">Tailwind</a></li>
<li><a href="#" class="py-1 px-3 block hover:bg-gray-200">Alpine</a></li>
<li><a href="#" class="py-1 px-3 block hover:bg-gray-200">Laravel</a></li>
<li><a href="#" class="py-1 px-3 block hover:bg-gray-200">Livewire</a></li>
</ul>
</div>
</div>
</body>
</html>