• English
  • Popover

    Show details or actions next to an element.

    Basic usage

    Live previewBasic usage
    basic.tsx
    import { Button, Input, Popover } from '@sudden3/leaf-ui';
    
    export function PopoverBasic() {
      return (
        <div className="leaf-demo-row">
          <Popover
            title="Project details"
            content={
              <div className="leaf-demo-stack">
                <Input aria-label="Project name" defaultValue="Leaf Garden" />
                <Button>Save</Button>
              </div>
            }
            width={260}
          >
            <Button variant="outline">Click to edit</Button>
          </Popover>
          <Popover
            title="Details"
            trigger="hover"
            placement="right"
            content="Read more details about this project."
          >
            <Button variant="soft">Hover for details</Button>
          </Popover>
        </div>
      );
    }
    

    Popover API

    PropertyTypeDefaultDescription
    childrenReactElementRequiredTrigger element, with ref and event support
    title / contentReactNode— / RequiredTitle / content
    trigger'click' | 'hover''click'Trigger mode
    placement'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end''top'Popup placement
    open / defaultOpenbooleanfalseControlled / initial open state
    onOpenChange(open: boolean) => void—Open state change
    disabledbooleanfalseDisable opening
    autoFocusbooleantrueFocus the first action on click opening
    enterDelay / leaveDelaynumber100Hover enter / leave delay in ms
    width / maxWidthnumber | string'max-content' / 320Width / maximum width
    className / stylestring / CSSProperties—Applied to the popup

    Types

    Import the exported types when defining props or building item lists.

    import type { PopoverProps } from '@sudden3/leaf-ui';

    Usage notes

    Use click mode for interactive content and hover mode for descriptions. Escape, outside click and focus leaving dismiss the popup. Tab keeps interactive content accessible. Supply aria-label when there is no title.