Feedbackduskmoonimplemented1 demos

Popconfirm

Popconfirm asks for confirmation around a risky inline action.

Import@duskmoon-dev/components/popconfirm
4API sections
19documented props
11behavior scenarios
Key API
titledescriptionplacementtriggericonopen

Usage

When to use

  • Use it immediately after user actions or system checks that need visible confirmation.
  • Choose the least interruptive feedback surface that still makes the state clear.

Implementation notes

StylesheetImport @duskmoon-dev/components/styles.css once in the app or docs shell.
StateStart with default props for static examples, then switch to controlled props when state must be shared.
ThemeThe preview inherits the active DuskMoon data-theme value from the docs layout.

Features

User feedback

Covers transient, inline, or blocking feedback patterns for user actions and system status.

Action recovery

Shows how the component keeps next actions visible after success, warning, or failure states.

Primary API surface

Popconfirm is most often configured through `title`, `description`, `placement`, `trigger`.

Covered behavior

Preserves Fragment trigger clicks without invalid Fragment props

Feature Demos

Feature demos are authored for the component page, then supplemented with behavior scenarios from the component test coverage.

Preview
!Delete this draft?A simulated request takes a moment. A rejection keeps these actions available.

Choose whether the next simulated request succeeds.

Confirmed: 0 · Canceled: 0

Async confirmation and retry

authored

A real button opens native Popconfirm. Reject the next simulated request to keep the confirmation available, then retry successfully or cancel. Pending controls and outcome counters use actual callbacks.

Source
import React, { useEffect, useRef, useState } from "react";
import "@duskmoon-dev/components/styles.css";
import { Popconfirm } from "@duskmoon-dev/components/popconfirm";

export function PopconfirmAsyncPreview() {
  const [shouldReject, setShouldReject] = useState(false);
  const [pending, setPending] = useState(false);
  const [confirmed, setConfirmed] = useState(0);
  const [canceled, setCanceled] = useState(0);
  const [status, setStatus] = useState("Choose whether the next simulated request succeeds.");
  const timerRef = useRef<number | undefined>(undefined);
  useEffect(() => () => window.clearTimeout(timerRef.current), []);

  async function confirm() {
    setPending(true);
    setStatus("Confirming deletion…");
    try {
      await new Promise<void>((resolve) => {
        timerRef.current = window.setTimeout(resolve, 300);
      });
      if (shouldReject) {
        setShouldReject(false);
        setStatus("Request rejected. The confirmation remains available; retry or cancel.");
        throw new Error("Simulated request rejection");
      }
      setConfirmed((count) => count + 1);
      setStatus("Deletion confirmed.");
    } finally {
      setPending(false);
    }
  }

  return <div data-overlay-confirm-demo style={{ display: "grid", gap: "0.75rem", justifyItems: "start" }}>
    <label style={{ display: "flex", alignItems: "center", gap: "0.5rem" }}>
      <input className="checkbox" type="checkbox" checked={shouldReject} disabled={pending} onChange={(event) => setShouldReject(event.currentTarget.checked)} />
      Reject next request
    </label>
    <Popconfirm
      title="Delete this draft?"
      description="A simulated request takes a moment. A rejection keeps these actions available."
      placement="bottom"
      okText="Delete draft"
      cancelText="Keep draft"
      cancelButtonProps={{ disabled: pending }}
      onConfirm={confirm}
      onCancel={() => { setCanceled((count) => count + 1); setStatus("Deletion canceled."); }}
    >
      <button className="btn btn-outlined" type="button">Review draft deletion</button>
    </Popconfirm>
    <p role="status" aria-atomic="true">{status}</p>
    <p>Confirmed: {confirmed} · Canceled: {canceled}</p>
  </div>;
}

API

The API reference below lists every parsed exported type or interface for Popconfirm. Start with `title`, `description`, `placement`, `trigger` for common usage.

Types: packages/components/src/components/popconfirm/Popconfirm.types.tsScenarios: packages/components/src/components/popconfirm/Popconfirm.test.tsx
PopconfirmPropsinterface extends Omit< ComponentProps<"span">, "children" | "title" >
PropTypeRequiredDescription
titleReactNodeNotitle configures Popconfirm.
descriptionReactNodeNodescription configures Popconfirm.
placementPopconfirmPlacementNoplacement configures Popconfirm.
triggerPopconfirmTrigger | PopconfirmTrigger[]Notrigger configures Popconfirm.
iconReactNodeNoicon configures Popconfirm.
openbooleanNoopen configures Popconfirm.
defaultOpenbooleanNodefaultOpen configures Popconfirm.
disabledbooleanNodisabled configures Popconfirm.
arrowbooleanNoarrow configures Popconfirm.
destroyTooltipOnHidebooleanNodestroyTooltipOnHide configures Popconfirm.
okTextReactNodeNookText configures Popconfirm.
cancelTextReactNodeNocancelText configures Popconfirm.
okButtonPropsButtonPropsNookButtonProps configures Popconfirm.
cancelButtonPropsButtonPropsNocancelButtonProps configures Popconfirm.
showCancelbooleanNoshowCancel configures Popconfirm.
onConfirm(event: MouseEvent<HTMLButtonElement>) => PopconfirmActionNoonConfirm configures Popconfirm.
onCancel(event: MouseEvent<HTMLButtonElement>) => PopconfirmActionNoonCancel configures Popconfirm.
onOpenChange(open: boolean) => voidNoonOpenChange configures Popconfirm.
childrenReactElementYeschildren configures Popconfirm.
PopconfirmPlacementtype
Type definition
| "top" | "bottom" | "left" | "right" | "topLeft" | "topRight" | "bottomLeft" | "bottomRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom"
PopconfirmTriggertype
Type definition
"hover" | "focus" | "click" | "contextMenu" | "contextmenu"
PopconfirmActiontype
Type definition
void | Promise<void> | Promise<unknown> | unknown