Confirmación Emergente (Popconfirm)
Muestra un cuadro de confirmación en forma de burbuja para una acción.
Cuándo Usar
- Un diálogo simple y compacto que se utiliza para solicitar la confirmación del usuario.
- La diferencia con el diálogo modal de confirmación es que es más ligero que el modal estático a pantalla completa.
Básico
El ejemplo básico.
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> Ubicación
Hay 4 opciones de ubicación disponibles.
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> Texto localizado
Establece las propiedades confirmText y cancelText para personalizar las etiquetas de los botones.
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> Referencia de la API
| Propiedad | Descripción | Tipo | Por defecto |
|---|---|---|---|
| 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" |