探索Headless组件与Tailwind CSS的魔力——前端开发的新选择
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Headless UI with Tailwind CSS</title>
<script src="https://unpkg.com/solid-js" crossorigin></script>
<script src="https://unpkg.com/@headlessui/react" crossorigin></script>
<link rel="stylesheet" href="https://unpkg.com/tailwindcss@latest/dist/tailwind.min.css">
</head>
<body>
<div class="flex items-center justify-center h-screen">
<div class="flex flex-col">
<div class="inline-block relative">
<button type="button" class="relative w-full rounded-md bg-white py-2 px-3 border border-gray-300 shadow-sm text-sm leading-5 font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
Open menu
<span class="sr-only">Open options menu</span>
<!-- Heroicon name: solid/chevron-down -->
<svg class="h-5 w-5 text-gray-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
</svg>
</button>
<HeadlessMenu as="div" class="origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5">
<div class="py-1" role="menu" aria-orientation="vertical" aria-labelledby="options-menu">
<HeadlessMenuItem as="button" class="block w-full text-left px-4 py-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 focus:outline-none focus:bg-gray-100" role="menuitem">Option 1</HeadlessMenuItem>
<HeadlessMenuItem as="button" class="block w-full text-left px-4 py-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 focus:outline-none focus:bg-gray-100" role="menuitem">Option 2</HeadlessMenuItem>
<HeadlessMenuItem as="button" class="block w-full text-left px-4 py-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 focus:outline-none focus:bg-gray-100" role="menuitem">Option 3</HeadlessMenuItem>
</div>
</Head
评论已关闭