Skip to content

Popconfirm

A short question beside the button that asked it: «Remove this filter?». For small actions that are easy to bring back; destroying data uses ConfirmDialog.

import { Popconfirm } from '@sypnia/ui/react'

On this page
  1. Removing filters
  2. When to use it
  3. For everyone
  4. Props

Removing filters

Press a ×: the question opens beside it.

status: paidcountry: COtotal > 100
Code
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 />
    </>
  );
}

When to use it

Use it when

  • Removing a filter, a tag or a draft line.
  • Write the question with the thing's name and the button with the action.

Do not use it when

  • Deleting data: use ConfirmDialog, which stops the page and can ask for the name.
  • Actions that undo themselves: do them and offer Undo in a toast.

For everyone

  • It is an alertdialog named by the question; Cancel has the focus so Enter never confirms by accident.
  • Escape closes it and the focus goes back to the button.

Props

PopconfirmTypeDefault
actionrequired

The confirm button says what it does: «Remove».

string
onConfirmrequired () => void
titlerequired

The question, naming the thing.

ReactNode
triggerrequired

The button that asks.

ReactElement<any, string | JSXElementConstructor<any>>
children

One sentence on what will happen.

ReactNode
placement "bottom start" | "bottom end" | "bottom" | "top" bottom
tone "primary" | "danger" primary
  1. Removing filters
  2. When to use it
  3. For everyone
  4. Props

    Search pages, sections and terms