Pill Dialog
A confirm dialog whose answers are glossy 3D capsules, a blue pill that cancels and a red pill that confirms: they lift on hover and focus, and the chosen one grows while the other fades as the dialog closes. UI SDK's AlertDialog underneath, with an async confirm, and data-agent-confirm on the red pill.
Example
Installation
Usage
Use it like ConfirmDialog where a decision deserves a moment: a migration, a release, a point of no return. The blue pill leaves everything as it is; the red pill goes ahead.
API reference
PillDialog
| Prop | Type | Default |
|---|---|---|
titlerequired | ReactNode | – |
description | ReactNode | – |
confirmLabelrequiredThe red pill's text. | ReactNode | – |
agentConfirmrequiredSentence an agent must show a person before confirming, e.g. "Migrates the production database". | string | – |
labels | PillDialogLabels | – |
onConfirmrequiredRuns before the dialog closes. A returned Promise keeps it open and pending; a rejection keeps it open. | PillDialogAction | – |
triggerContent of the button that opens the dialog. Omit it when opening through `open` or `controller`. | ReactNode | – |
triggerVariant | VariantProps<typeof buttonVariants>["variant"] | "outline" |
triggerDisabledThe trigger can't open the dialog; nor can an agent or a controller. | boolean | false |
triggerPendingWork the trigger stands for is running elsewhere: a spinner, `aria-busy`, and the dialog doesn't open. | boolean | – |
renderError | (error: unknown) => ReactNode | defaultRenderError |
className | string | – |
Also takes Pick< AlertDialogRootProps, "open" | "defaultOpen" | "onOpenChange" | "onOpenChangeComplete" | "controller" | "pendingAnnouncement" >.
Other exports
type PillChoicetype PillDialogLabelstype PillDialogPropsAccessibility
- An alert dialog: opening focuses the blue pill, Escape cancels, focus is trapped and returns to the trigger.
- Each pill is a button with its text under the capsule; both lift on keyboard focus as on hover.
- While onConfirm runs the red pill is busy and the dialog stays open; a failure is announced.
Agent actions
Agents press the pills by their text. The red pill carries data-agent-confirm, so its press waits for your allow callback.
Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.