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/popover.md.
  • English
  • Popover

    Show details or actions next to an element.

    Triggers

    basic.tsx
    import { Button, Flex, Popover } from '@ifhover/leaf-ui';
    
    export function PopoverBasic() {
      return (
        <Flex gap="md" align="center" wrap justify="center">
          <Popover title="Project details" content="See project details and recent updates here.">
            <Button variant="outline">Click for details</Button>
          </Popover>
          <Popover
            title="Hint"
            trigger="hover"
            placement="right"
            content="Find more project information here."
          >
            <Button variant="outline">Hover for details</Button>
          </Popover>
        </Flex>
      );
    }
    

    Controlled editing

    controlled.tsx
    import { Button, Form, FormField, Input, Popover } from '@ifhover/leaf-ui';
    
    import { useState } from 'react';
    
    export function PopoverControlled() {
      const [open, setOpen] = useState(false);
      return (
        <Popover
          title="Edit project"
          open={open}
          onOpenChange={setOpen}
          width={260}
          content={
            <Form
              layout="vertical"
              onSubmit={(event) => {
                event.preventDefault();
                setOpen(false);
              }}
            >
              <FormField label="Project name">
                <Input defaultValue="Leaf Garden" />
              </FormField>
              <Button type="submit">Save and close</Button>
            </Form>
          }
        >
          <Button variant="outline">Click to edit</Button>
        </Popover>
      );
    }
    

    Panel placement

    placements.tsx
    import { Button, Flex, Popover } from '@ifhover/leaf-ui';
    
    export function PopoverPlacements() {
      return (
        <Flex gap="md" align="center" wrap justify="center">
          {(['top', 'bottom', 'left', 'right'] as const).map((placement) => (
            <Popover
              key={placement}
              placement={placement}
              title="Project hint"
              content="The panel adjusts to available space."
            >
              <Button variant="outline">
                {{ top: 'Top', bottom: 'Bottom', left: 'Left', right: 'Right' }[placement]}
              </Button>
            </Popover>
          ))}
        </Flex>
      );
    }
    

    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 '@ifhover/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.