
<!-- Dropdown -->
<div x-data="{open: false}">
<button @click="open = !open"
class="inline-flex text-sm items-center py-2 px-4 bg-blue-600 hover:bg-opacity-85 text-white rounded-md shadow">
메뉴
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 ml-2 transition-all"
:class="{'rotate-90': open}" fill="none" viewBox="0 0 24 24" stroke="currentColor"
stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7" />
</svg>
</button>
<ul x-show="open" @click.outside="open = false" x-transition
class="absolute bg-white w-[160px] shadow-md py-1">
<li>
<a class="text-sm py-1 px-2 hover:bg-blue-200 flex items-center" href="#">
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-2" fill="none" viewBox="0 0 24 24"
stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round"
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
<path stroke-linecap="round" stroke-linejoin="round"
d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
</svg>
Open
</a>
</li>
<li>
<a class="text-sm py-1 px-2 hover:bg-gray-200 flex items-center" href="#">
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-2" fill="none" viewBox="0 0 24 24"
stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round"
d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
</svg>
Edit
</a>
</li>
<li>
<a class="text-sm py-1 px-2 hover:bg-gray-200 flex items-center" href="#">
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-2" fill="none" viewBox="0 0 24 24"
stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round"
d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
</svg>
Delete
</a>
</li>
</ul>
</div>반응형
'Laravel > Alpine.js' 카테고리의 다른 글
| Alpine.js - modal, 모달창 만들기 (0) | 2024.07.04 |
|---|---|
| [Alpine.js] - 화면넓이(or다크모드) 사용자 설정하기 with Global Data 활용 (0) | 2023.07.22 |
| Alpine.js 란? 기본기 (0) | 2022.11.30 |