Popconfirm
Una pregunta corta junto al botón que la hizo: «¿Quitar este filtro?». Para acciones pequeñas que se recuperan fácil; borrar datos usa ConfirmDialog.
import { Popconfirm } from '@sypnia/ui/react'
En esta página
Quitar filtros
Pulsa una ×: la pregunta se abre a su lado.
status: paidcountry: COtotal > 100
Código
import { useState } from 'react';
import { Chip, IconButton, Popconfirm, toast, Toaster } from '@sypnia/ui/react';
// Small things that are easy to bring back. The question sits beside its button and Cancel has the focus.
export default function Filters() {
const [filters, setFilters] = useState(['status: paid', 'country: CO', 'total > 100']);
return (
<>
<div className="sy-row">
{filters.map((f) => (
<span key={f} className="sy-row">
<Chip>{f}</Chip>
<Popconfirm title="Remove this filter?" action="Remove" onConfirm={() => { setFilters(filters.filter((x) => x !== f)); toast(`Removed ${f}`); }}
trigger={<IconButton size="sm" icon="close" label={`Remove ${f}`} tooltip={false} />}>
The list shows every row again for this column.
</Popconfirm>
</span>
))}
</div>
<Toaster />
</>
);
} Cuándo usarlo
Úsalo cuando
- Quitar un filtro, una etiqueta o una línea de borrador.
- Escribe la pregunta con el nombre de la cosa y el botón con la acción.
No lo uses cuando
- Borrar datos: usa ConfirmDialog, que detiene la página y puede pedir el nombre.
- Acciones que se deshacen solas: hazlas y ofrece Deshacer en un toast.
Para todos
- Es un
alertdialognombrado por la pregunta; Cancelar tiene el foco, así Enter nunca confirma por accidente. - Escape la cierra y el foco vuelve al botón.
Props
| Popconfirm | Tipo | Por defecto |
|---|---|---|
actionobligatorioThe confirm button says what it does: «Remove». | string | |
onConfirmobligatorio | () => void | |
titleobligatorioThe question, naming the thing. | ReactNode | |
triggerobligatorioThe button that asks. | ReactElement<any, string | JSXElementConstructor<any>> | |
childrenOne sentence on what will happen. | ReactNode | |
placement | "bottom start" | "bottom end" | "bottom" | "top" | bottom |
tone | "primary" | "danger" | primary |