本文へ移動
日本語

仕組み

The popover is placed against the closest data-ds-boundary element or the viewport, shifting sideways with its arrow kept on the trigger and flipping when there is no room. While a returned promise is pending both buttons hold: the label lifts away for a spinner, then a check is drawn and the popover closes after 650ms.

向いている場面

  • Confirming a single, reversible-but-costly inline action such as removing a member or revoking a link.
  • Places where a full dialog would feel heavy.

向かない場面

  • Irreversible actions with wide impact: use a confirm dialog that names what is lost.
  • Actions that can simply be undone: act and offer Undo instead.

使い方

import { Popconfirm } from './Popconfirm.jsx'

export function RemoveMember({ member }) {
  return (
    <Popconfirm
      title={`Remove ${member.name}?`}
      description="They lose access to every project right away."
      confirmLabel="Remove"
      onConfirm={() => api.removeMember(member.id)}
    >
      <button type="button">Remove</button>
    </Popconfirm>
  )
}

プロパティ

プロパティ型既定値説明
childrenReactElement—The trigger button; it gets aria-haspopup and aria-expanded.
titleReactNode—The question.
descriptionReactNode—The consequence, in one sentence.
onConfirm() => void | Promise—Runs on confirm. A promise shows progress; rejecting keeps the popover open with errorLabel.
tone'danger' | 'default''danger'Red confirm and warning icon, or ink and a question icon.
side'top' | 'bottom''top'Preferred side; flips when there is no room.
confirmLabel / cancelLabel / errorLabelstring'Confirm' / 'Cancel' / 'That didn’t work. Try again.'Button and error text.
defaultOpenbooleanfalseOpen on first render (without taking focus).
onOpenChange(open: boolean) => void—Called when it opens or closes.

アクセシビリティ

  • role alertdialog labelled by the title and described by the description; the trigger carries aria-haspopup and aria-expanded.
  • Opening moves focus to Cancel, so Enter never confirms by accident; Tab cycles between the two buttons.
  • Escape, Cancel or a click outside closes it and returns focus to the trigger.
  • The confirm button sets aria-busy while waiting; an error is announced with role alert.
  • Danger is shown by an icon and wording, not colour alone.
  • With reduced motion the popover fades and the spinner turns slowly.

モーション

Enter 200ms cubic-bezier(0.32, 1.25, 0.5, 1) from 0.94 scale at the arrow; leave 120ms; label lifts 4px, spinner and check spring in, check stroke draws in 280ms.

プロジェクトに追加

プロンプトを Codex または Claude Code に貼り付けます。エージェントが公開ソースを読み、書き込む内容を示したうえで、既存のコンポーネントの隣に追加します。

Popconfirm.jsxpopconfirm.csstokens.cssREADME.md

2 つのファイルを一緒に導入します。スタイルは tokens.css の変数を読み、予備の値も持つため、単体でも表示できます。

オーバーレイ
「ボトムシート」は Pro に含まれます。解除するとプレビューが表示されます。