For AI agents: the complete documentation index is available at https://ifhover.github.io/leaf-ui/v/0.6.0/en/llms.txt, the full documentation bundle is available at https://ifhover.github.io/leaf-ui/v/0.6.0/en/llms-full.txt, and this page is available as Markdown at https://ifhover.github.io/leaf-ui/v/0.6.0/en/components/popconfirm.md.
  • English
  • Popconfirm

    Confirm important actions near their triggers.

    Basic usage

    basic.tsx
    import { Button, Popconfirm } from '@ifhover/leaf-ui';
    
    import { useState } from 'react';
    
    export function PopconfirmBasic() {
      const [removed, setRemoved] = useState(false);
      return (
        <Popconfirm
          title="Remove this project?"
          description="You can restore it from the recycle bin."
          onConfirm={() => setRemoved(true)}
        >
          <Button variant="outline" danger disabled={removed}>
            {removed ? 'Removed' : 'Remove project'}
          </Button>
        </Popconfirm>
      );
    }
    

    More examples

    advanced.tsx
    import { Button, Popconfirm } from '@ifhover/leaf-ui';
    
    export function PopconfirmAsync() {
      return (
        <Popconfirm
          title="Submit for review?"
          type="info"
          onConfirm={() => new Promise<void>((resolve) => setTimeout(resolve, 900))}
        >
          <Button>Async confirmation</Button>
        </Popconfirm>
      );
    }
    

    Usage

    onConfirm can return a Promise. Pending operations display loading and prevent duplicate submissions. The popup closes on success and stays open on failure; use onError for feedback. The trigger must accept a ref and button interactions.

    Types

    Import these types for data, callbacks and refs.

    import type { PopconfirmProps, ButtonProps } from '@ifhover/leaf-ui';

    PopconfirmProps API

    PropertyTypeDefaultDescription
    popupPlacement'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end'—Placement relative to the trigger.
    popupClassNamestring—Custom class for the popup.
    popupStyleCSSProperties—Custom popup styles.
    popupRender(content: React.ReactNode) => React.ReactNode—Wrap or extend popup content; retain the supplied content to preserve interaction.
    getPopupContainer() => Element | DocumentFragment—Return a popup container, including a ShadowRoot.
    childrenReactElement< HTMLAttributes<HTMLElement> & { ref?: Ref<HTMLElement>; disabled?: boolean } >RequiredRequired. Content or child items
    placement'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end''top'Placement
    openboolean—Controlled visibility
    defaultOpenbooleanfalseInitial visibility
    onOpenChange(open: boolean) => void—Open state changes
    disabledboolean—Disable interaction.
    enterDelaynumber100Pointer opening delay in milliseconds
    leaveDelaynumber100Pointer closing delay in milliseconds
    widthnumber | string—Width, numbers are in pixels
    maxWidthnumber | string—Maximum popup width
    classNamestring—Container class name
    styleCSSProperties—Container inline styles
    aria-labelstring—Accessible name when no visible label is provided
    titleReactNodeRequiredRequired. Title content
    descriptionReactNode—Supporting description
    type'success' | 'info' | 'warning' | 'error' | 'default''warning'Visual or item type
    iconReactNode—Custom icon
    confirmTextReactNode—Confirm button content
    cancelTextReactNode—Cancel button content
    confirmButtonPropsButtonProps—Confirm button props
    cancelButtonPropsButtonProps—Cancel button props
    showCancelbooleantrueShow cancel button
    onConfirm() => void | Promise<void>—Confirm action; supports async completion
    onCancel() => void—Cancel action
    onError(error: unknown) => void—Error callback

    ButtonProps API

    PropertyTypeDefaultDescription
    variant'solid' | 'soft' | 'outline' | 'ghost''solid'Button appearance
    size'sm' | 'md' | 'lg''md'Size or spacing preset
    dangerbooleanfalseDanger colors
    loadingbooleanfalseLoading state
    fullWidthbooleanfalseFill available width
    startIconReactNode—Leading icon
    endIconReactNode—Trailing icon