ポップ確認 (Popconfirm)
アクションに対するバブル確認ボックスをポップアップします。
いつ使うか
- シンプルでコンパクトなダイアログは、ユーザーに確認を求めるために使用されます。
- 確認モーダルダイアログとの違いは、静的にポップされるフルスクリーンの確認モーダルよりも軽量であることです。
基本
基本的な例。
astro
---
import Popconfirm from '@/components/feedback/Popconfirm.astro';
import Button from '@/components/general/Button.astro';
---
<Popconfirm title="Are you absolutely sure?" description="This action cannot be undone.">
<Button variant="danger">Delete Account</Button>
</Popconfirm>
<script>
document.addEventListener('popconfirm:confirm', (e) => {
console.log('Confirmed!', e.detail.id);
});
</script> 配置
4つの配置オプションが利用可能です。
astro
---
import Popconfirm from '@/components/feedback/Popconfirm.astro';
import Button from '@/components/general/Button.astro';
---
<Popconfirm title="Are you sure delete this task?" position="top">
<Button variant="outline">Top</Button>
</Popconfirm>
<Popconfirm title="Are you sure delete this task?" position="left">
<Button variant="outline">Left</Button>
</Popconfirm>
<Popconfirm title="Are you sure delete this task?" position="right">
<Button variant="outline">Right</Button>
</Popconfirm>
<Popconfirm title="Are you sure delete this task?" position="bottom">
<Button variant="outline">Bottom</Button>
</Popconfirm> ロケールテキスト
confirmText と cancelText プロパティを設定して、ボタンのラベルをカスタマイズします。
astro
---
import Popconfirm from '@/components/feedback/Popconfirm.astro';
import Button from '@/components/general/Button.astro';
---
<Popconfirm title="Are you sure?" confirmText="Yes" cancelText="No">
<Button variant="outline">Delete a task</Button>
</Popconfirm> API リファレンス
| プロパティ | 説明 | タイプ | デフォルト |
|---|---|---|---|
| title | The title of the confirmation dialog. | string | - |
| description | Additional descriptive text. | string | - |
| confirmText | The text for the confirmation button. | string | "Yes" |
| cancelText | The text for the cancellation button. | string | "No" |
| position | The preferred placement of the popconfirm. | "top" | "bottom" | "left" | "right" | "top" |