ネイティブ ポップオーバー API を使用した CSS のみの Tailwind CSS ポップオーバー。ツールチップとドロップダウンのフローティング コンテンツ パネル。 WCAG AA にアクセス可能で、Django、HTMX、Laravel、React、およびあらゆるスタックで動作します。
ポップオーバー コンポーネントは、永続的な画面スペースを占有することなく、トリガー要素に隣接してコンテキスト コンテンツを表示します。ネイティブ HTML ポップオーバー API 上に構築された Frutjam ポップオーバー システムは、クリックとホバー トリガー、カスタマイズ可能な位置決め、スムーズなアニメーションをサポートします。ドロップダウン メニュー、コンテキスト メニュー、ユーザー プロファイル メニュー、およびページ ナビゲーションのない追加オプションに最適です。
CSS のみ、JavaScript は不要 — 純粋な HTML と Tailwind CSS を使用して、アクセス可能なドロップダウン メニューとコンテキスト オーバーレイを構築します。 WCAG AA にアクセス可能で、フレームワークに依存しない - Django、HTMX、Laravel、React、およびあらゆるスタックで動作します。
| クラス | タイプ | 説明 |
|---|---|---|
| popover | ベース | トリガーとコンテンツを一緒に固定するラッパー |
| popover-content | 修飾子 | ポップオーバーが開いているときに表示されるフローティング パネル |
| popover-toggle | 修飾子 | ポップオーバーを開閉するトリガー要素 |
| popover-hover | 修飾子 | クリックではなくホバーで開きます |
| popover-top-start | 修飾子 | 上に配置され、先頭に揃えられます |
| popover-top-center | 修飾子 | 上、中央に配置 |
| popover-top-end | 修飾子 | 上に配置され、最後に揃えられます |
| popover-bottom-start | 修飾子 | 下に配置され、先頭に揃えられます |
| popover-bottom-center | 修飾子 | 下に中央に配置 |
| popover-bottom-end | 修飾子 | 下に配置され、最後に揃えられます |
| popover-start-top | 修飾子 | 左に配置され、上に揃えられます |
| popover-start-center | 修飾子 | 左側に配置され、垂直方向の中央に配置されます |
| popover-start-bottom | 修飾子 | 左に配置され、下に揃えられます |
| popover-end-top | 修飾子 | 右に配置され、上に揃えられます |
| popover-end-center | 修飾子 | 右に配置され、垂直方向の中央に配置されます |
| popover-end-bottom | 修飾子 | 右に配置され、下に揃えられます |
基本的な使い方
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <div class="popover"> <button popovertarget="defaultClickPopover" type="button" class="popover-toggle btn">Click here</button> <div tabindex="0" class="popover-content" popover id="defaultClickPopover"> <ul class="menu"> <li> <a class="menu-item">About Us</a> </li> <li> <a class="menu-item">Contact Us</a> </li> <li> <a class="menu-item">Career</a> </li> <li> <a class="menu-item">Terms and conditions</a> </li> </ul> </div> </div> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <div className="popover"> <button popovertarget="defaultClickPopover" type="button" className="popover-toggle btn">Click here</button> <div tabIndex="0" className="popover-content" popover id="defaultClickPopover"> <ul className="menu"> <li> <a className="menu-item">About Us</a> </li> <li> <a className="menu-item">Contact Us</a> </li> <li> <a className="menu-item">Career</a> </li> <li> <a className="menu-item">Terms and conditions</a> </li> </ul> </div> </div> |
ドロップダウンメニュー
Popover コンポーネントを使用して、ドロップダウン メニュー (ナビゲーション ドロップダウン、ユーザー プロファイル メニュー、およびアクション メニュー) を構築します。これらはすべて CSS のみで、JavaScript は必要ありません。
ナビゲーションバーのドロップダウン
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <div class="popover"> <button popovertarget="navDropdown" type="button" class="popover-toggle btn btn-ghost"> Products <svg xmlns="http://www.w3.org/2000/svg" class="size-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" /></svg> </button> <div tabindex="0" class="popover-content" popover id="navDropdown"> <ul class="menu"> <li><a class="menu-item">Components</a></li> <li><a class="menu-item">Blocks</a></li> <li><a class="menu-item">Templates</a></li> <li><a class="menu-item">Plugins</a></li> </ul> </div> </div> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <div className="popover"> <button popovertarget="navDropdown" type="button" className="popover-toggle btn btn-ghost"> Products <svg xmlns="http://www.w3.org/2000/svg" className="size-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M19 9l-7 7-7-7" /></svg> </button> <div tabIndex="0" className="popover-content" popover id="navDropdown"> <ul className="menu"> <li><a className="menu-item">Components</a></li> <li><a className="menu-item">Blocks</a></li> <li><a className="menu-item">Templates</a></li> <li><a className="menu-item">Plugins</a></li> </ul> </div> </div> |
ユーザープロファイルのドロップダウン
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <div class="popover popover-bottom-end"> <button popovertarget="profileDropdown" type="button" class="popover-toggle btn btn-ghost p-0"> <div class="avatar avatar-primary avatar-sm">JD</div> </button> <div tabindex="0" class="popover-content" popover id="profileDropdown"> <ul class="menu"> <li class="menu-title">John Doe</li> <li><a class="menu-item">Profile</a></li> <li><a class="menu-item">Settings</a></li> <li><a class="menu-item">Billing</a></li> <li><div class="divider my-0"></div></li> <li><a class="menu-item text-error">Sign out</a></li> </ul> </div> </div> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <div className="popover popover-bottom-end"> <button popovertarget="profileDropdown" type="button" className="popover-toggle btn btn-ghost p-0"> <div className="avatar avatar-primary avatar-sm">JD</div> </button> <div tabIndex="0" className="popover-content" popover id="profileDropdown"> <ul className="menu"> <li className="menu-title">John Doe</li> <li><a className="menu-item">Profile</a></li> <li><a className="menu-item">Settings</a></li> <li><a className="menu-item">Billing</a></li> <li><div className="divider my-0"></div></li> <li><a className="menu-item text-error">Sign out</a></li> </ul> </div> </div> |
アイコン付きドロップダウン
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 | <div class="popover"> <button popovertarget="iconDropdown" type="button" class="popover-toggle btn"> Actions <svg xmlns="http://www.w3.org/2000/svg" class="size-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" /></svg> </button> <div tabindex="0" class="popover-content" popover id="iconDropdown"> <ul class="menu"> <li> <a class="menu-item"> <svg xmlns="http://www.w3.org/2000/svg" class="size-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" 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="menu-item"> <svg xmlns="http://www.w3.org/2000/svg" class="size-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" /></svg> Duplicate </a> </li> <li><div class="divider my-0"></div></li> <li> <a class="menu-item text-error"> <svg xmlns="http://www.w3.org/2000/svg" class="size-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" 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> </div> |
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 | <div className="popover"> <button popovertarget="iconDropdown" type="button" className="popover-toggle btn"> Actions <svg xmlns="http://www.w3.org/2000/svg" className="size-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M19 9l-7 7-7-7" /></svg> </button> <div tabIndex="0" className="popover-content" popover id="iconDropdown"> <ul className="menu"> <li> <a className="menu-item"> <svg xmlns="http://www.w3.org/2000/svg" className="size-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" 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 className="menu-item"> <svg xmlns="http://www.w3.org/2000/svg" className="size-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" /></svg> Duplicate </a> </li> <li><div className="divider my-0"></div></li> <li> <a className="menu-item text-error"> <svg xmlns="http://www.w3.org/2000/svg" className="size-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" 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> </div> |
ポップオーバーのインタラクション動作
デフォルトでは、ポップオーバー コンポーネントを開いたり閉じたりするためにクリック インタラクションが使用されます。たとえば、メガメニューの場合、popover-hover クラスを追加し、popovertarget 属性と popover 属性を削除することで、ホバーベースのインタラクションを有効にできます。これにより、ネイティブのクリック動作ではなく、ホバー ロジックを介してポップオーバーを完全に制御できるようになります。
ネイティブクリックトリガー
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <div class="popover"> <button popovertarget="nativeClickTrigger" type="button" class="popover-toggle btn">Click here</button> <div tabindex="0" class="popover-content" popover id="nativeClickTrigger"> <ul class="menu"> <li> <a class="menu-item">About Us</a> </li> <li> <a class="menu-item">Contact Us</a> </li> <li> <a class="menu-item">Career</a> </li> <li> <a class="menu-item">Terms and conditions</a> </li> </ul> </div> </div> |
ホバーインタラクションロジック
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <div class="popover popover-hover"> <button type="button" class="popover-toggle btn">Hover me</button> <div class="popover-content"> <ul class="menu"> <li> <a class="menu-item">About Us</a> </li> <li> <a class="menu-item">Contact Us</a> </li> <li> <a class="menu-item">Career</a> </li> <li> <a class="menu-item">Terms and conditions</a> </li> </ul> </div> </div> |
ポップオーバーの位置オプション (上、下、開始、終了)
柔軟な配置ロジックを使用して、トリガー要素を基準にしてポップオーバーを配置します。ポップオーバーの配置は、垂直方向 (上、中央、下) と水平方向 (開始、中央、終了) の配置オプションを組み合わせて作成されます。
トップスタートのポップオーバー位置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <div class="popover popover-top-start"> <button popovertarget="popoverTopStart" type="button" class="popover-toggle btn">Click here</button> <div tabindex="0" class="popover-content" popover id="popoverTopStart"> <ul class="menu"> <li> <a class="menu-item">About Us</a> </li> <li> <a class="menu-item">Contact Us</a> </li> <li> <a class="menu-item">Career</a> </li> <li> <a class="menu-item">Terms and conditions</a> </li> </ul> </div> </div> |
上部中央のポップオーバー位置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <div class="popover popover-top-center"> <button popovertarget="popoverTopCenter" type="button" class="popover-toggle btn">Click here</button> <div tabindex="0" class="popover-content" popover id="popoverTopCenter"> <ul class="menu"> <li> <a class="menu-item">About Us</a> </li> <li> <a class="menu-item">Contact Us</a> </li> <li> <a class="menu-item">Career</a> </li> <li> <a class="menu-item">Terms and conditions</a> </li> </ul> </div> </div> |
トップエンドのポップオーバー位置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <div class="popover popover-top-end"> <button popovertarget="popoverTopEnd" type="button" class="popover-toggle btn">Click here</button> <div tabindex="0" class="popover-content" popover id="popoverTopEnd"> <ul class="menu"> <li> <a class="menu-item">About Us</a> </li> <li> <a class="menu-item">Contact Us</a> </li> <li> <a class="menu-item">Career</a> </li> <li> <a class="menu-item">Terms and conditions</a> </li> </ul> </div> </div> |
エンドトップのポップオーバー位置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <div class="popover popover-end-top"> <button popovertarget="popoverEndTop" type="button" class="popover-toggle btn">Click here</button> <div tabindex="0" class="popover-content" popover id="popoverEndTop"> <ul class="menu"> <li> <a class="menu-item">About Us</a> </li> <li> <a class="menu-item">Contact Us</a> </li> <li> <a class="menu-item">Career</a> </li> <li> <a class="menu-item">Terms and conditions</a> </li> </ul> </div> </div> |
エンドセンターのポップオーバー位置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <div class="popover popover-end-center"> <button popovertarget="popoverEndCenter" type="button" class="popover-toggle btn">Click here</button> <div tabindex="0" class="popover-content" popover id="popoverEndCenter"> <ul class="menu"> <li> <a class="menu-item">About Us</a> </li> <li> <a class="menu-item">Contact Us</a> </li> <li> <a class="menu-item">Career</a> </li> <li> <a class="menu-item">Terms and conditions</a> </li> </ul> </div> </div> |
端と下のポップオーバー位置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <div class="popover popover-end-bottom"> <button popovertarget="popoverEndBottom" type="button" class="popover-toggle btn">Click here</button> <div tabindex="0" class="popover-content" popover id="popoverEndBottom"> <ul class="menu"> <li> <a class="menu-item">About Us</a> </li> <li> <a class="menu-item">Contact Us</a> </li> <li> <a class="menu-item">Career</a> </li> <li> <a class="menu-item">Terms and conditions</a> </li> </ul> </div> </div> |
ボトムスタートのポップオーバー位置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <div class="popover popover-bottom-start"> <button popovertarget="popoverBottomStart" type="button" class="popover-toggle btn">Click here</button> <div tabindex="0" class="popover-content" popover id="popoverBottomStart"> <ul class="menu"> <li> <a class="menu-item">About Us</a> </li> <li> <a class="menu-item">Contact Us</a> </li> <li> <a class="menu-item">Career</a> </li> <li> <a class="menu-item">Terms and conditions</a> </li> </ul> </div> </div> |
中央下部のポップオーバー位置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <div class="popover popover-bottom-center"> <button popovertarget="popoverBottomCenter" type="button" class="popover-toggle btn">Click here</button> <div tabindex="0" class="popover-content" popover id="popoverBottomCenter"> <ul class="menu"> <li> <a class="menu-item">About Us</a> </li> <li> <a class="menu-item">Contact Us</a> </li> <li> <a class="menu-item">Career</a> </li> <li> <a class="menu-item">Terms and conditions</a> </li> </ul> </div> </div> |
ボトムエンドのポップオーバー位置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <div class="popover popover-bottom-end"> <button popovertarget="popoverBottomEnd" type="button" class="popover-toggle btn">Click here</button> <div tabindex="0" class="popover-content" popover id="popoverBottomEnd"> <ul class="menu"> <li> <a class="menu-item">About Us</a> </li> <li> <a class="menu-item">Contact Us</a> </li> <li> <a class="menu-item">Career</a> </li> <li> <a class="menu-item">Terms and conditions</a> </li> </ul> </div> </div> |
スタートトップのポップオーバー位置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <div class="popover popover-start-top"> <button popovertarget="popoverStartTop" type="button" class="popover-toggle btn">Click here</button> <div tabindex="0" class="popover-content" popover id="popoverStartTop"> <ul class="menu"> <li> <a class="menu-item">About Us</a> </li> <li> <a class="menu-item">Contact Us</a> </li> <li> <a class="menu-item">Career</a> </li> <li> <a class="menu-item">Terms and conditions</a> </li> </ul> </div> </div> |
開始中央のポップオーバー位置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <div class="popover popover-start-center"> <button popovertarget="popoverStartCenter" type="button" class="popover-toggle btn">Click here</button> <div tabindex="0" class="popover-content" popover id="popoverStartCenter"> <ul class="menu"> <li> <a class="menu-item">About Us</a> </li> <li> <a class="menu-item">Contact Us</a> </li> <li> <a class="menu-item">Career</a> </li> <li> <a class="menu-item">Terms and conditions</a> </li> </ul> </div> </div> |
開始下位のポップオーバー位置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <div class="popover popover-start-bottom"> <button popovertarget="popoverStartBottom" type="button" class="popover-toggle btn">Click here</button> <div tabindex="0" class="popover-content" popover id="popoverStartBottom"> <ul class="menu"> <li> <a class="menu-item">About Us</a> </li> <li> <a class="menu-item">Contact Us</a> </li> <li> <a class="menu-item">Career</a> </li> <li> <a class="menu-item">Terms and conditions</a> </li> </ul> </div> </div> |
データテーブル内でのポップオーバーの使用 (アクションメニューと確認)
| Project | Category | Primary Tech | ||
|---|---|---|---|---|
|
E-commerce Dashboard
Internal Tool
|
Full Stack Admin Panel | Next.js |
|
|
|
CI Pipeline
Infrastructure
|
DevOps Automation | GitHub Actions |
|
|
| Project | Category | Primary Tech |
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | <div class="overflow-x-auto w-full"> <table class="table"> <!-- head --> <thead> <tr> <th> <label> <input type="checkbox" class="checkbox"> </label> </th> <th>Project</th> <th>Category</th> <th>Primary Tech</th> <th></th> </tr> </thead> <tbody> <tr> <th> <label> <input type="checkbox" class="checkbox"> </label> </th> <td> <div> <div class="font-bold">E-commerce Dashboard</div> <div class="text-sm opacity-50">Internal Tool</div> </div> </td> <td> Full Stack <span class="badge badge-soft badge-sm">Admin Panel</span> </td> <td>Next.js</td> <th> <div class="popover popover-bottom-start"> <button popovertarget="popoverOnTable" type="button" class="popover-toggle btn btn-xs btn-error">Delete</button> <div tabindex="0" class="popover-content" popover id="popoverOnTable"> <ul class="menu menu-horizontal"> <li class="menu-title">Are you sure? delete this record!</li> <li> <button class="btn btn-xs">No</button> </li> <li> <button class="btn btn-xs btn-error">Delete</button> </li> </ul> </div> </div> </th> </tr> <tr> <th> <label> <input type="checkbox" class="checkbox"> </label> </th> <td> <div> <div class="font-bold">CI Pipeline</div> <div class="text-sm opacity-50">Infrastructure</div> </div> </td> <td> DevOps <span class="badge badge-soft badge-sm">Automation</span> </td> <td>GitHub Actions</td> <th> <div class="popover popover-bottom-start"> <button popovertarget="popoverOnTable2" type="button" class="popover-toggle btn btn-xs btn-error">Delete</button> <div tabindex="0" class="popover-content" popover id="popoverOnTable2"> <ul class="menu menu-horizontal"> <li> <button class="menu-item btn btn-xs">No</button> </li> <li> <button class="menu-item btn btn-xs btn-error">Delete</button> </li> </ul> </div> </div> </th> </tr> </tbody> <!-- foot --> <tfoot> <tr> <th></th> <th>Project</th> <th>Category</th> <th>Primary Tech</th> <th></th> </tr> </tfoot> </table> </div> |
Claude コード、Cursor、または別の AI エディターを使用していますか?
Cherry MCP は、AI エディタに正確な ポップオーバー クラス名と構造をオンデマンドで提供します。もう幻覚のような授業はありません。