Skip to content

Popover

The Popover component displays content in a floating container that appears when clicking on a trigger element. It provides a flexible way to show additional information or actions.

import {
Button,
Popover,
TextAreaInput,
} from '@fintech-sandpit/ui/react';
return (
<Popover.Root>
<Popover.Trigger>
<Button colorScheme="primary">
Add Comment
</Button>
</Popover.Trigger>
<Popover.Content className="w-80 p-sm space-y-4">
<TextAreaInput
placeholder="Write your comment here..."
rows={4}
size="sm"
/>
<div className="flex gap-2 justify-end">
<Button
size="sm"
variant="ghost"
>
Cancel
</Button>
<Button
colorScheme="primary"
size="sm"
>
Post Comment
</Button>
</div>
</Popover.Content>
</Popover.Root>
);

The root component that manages the popover state and provides context to child components. Supports both controlled and uncontrolled usage.

The element that triggers the popover when clicked. Use asChild prop to merge props with a child element.

The main content container for the popover. Automatically includes positioning and portal rendering.

NameTypeDefaultDescription
openbooleanWhether the popover is open (controlled)
defaultOpenbooleanfalseWhether the popover is open by default (uncontrolled)
autoFocusbooleantrueWhether to focus the trigger element when the popover is opened
modalbooleanfalseWhether to trap focus inside the popover
portalledbooleantrueWhether to portal the popover content
closeOnInteractOutsidebooleantrueWhether to close on outside interaction
closeOnEscapebooleantrueWhether to close on Escape key
lazyMountbooleantrueWhether to lazy mount the popover content
unmountOnExitbooleantrueWhether to unmount the popover content when it is closed
placementPlacementbottom-startThe placement of the popover
offsetMainAxisnumber8The offset of the popover on the main axis, px
offsetCrossAxisnumber0The offset of the popover on the cross axis, px
NameTypeDescription
onOpen() => voidCallback fired when the popover is opened
onClose() => voidCallback fired when the popover is closed
type Placement = (
| 'top'
| 'top-start'
| 'top-end'
| 'bottom'
| 'bottom-start'
| 'bottom-end'
| 'left'
| 'left-start'
| 'left-end'
| 'right'
| 'right-start'
| 'right-end'
)