Popover
A component that displays rich content in a portal, triggered by a button. Perfect settings panels, and contextual information with smooth animations and positioning control.
Import
import {Popover,PopoverTrigger,PopoverContent,PopoverClose,PopoverArrow,PopoverPortal,PopoverAnchor} from "@sparrowengg/twigs-react";Usage
const PopoverExample = () => {
return (
<Box css={{ display: "flex", flexDirection: "column", gap: "$6", alignItems: "center" }}>
<Popover>
<PopoverTrigger asChild>
<Button size="md" leftIcon={<SettingsIcon />} color="primary">
Settings
</Button>
</PopoverTrigger>
<PopoverContent side="bottom" align="start" sideOffset={8}>
<Box css={{ display: "flex", flexDirection: "column", gap: "$4" }}>
<Text css={{ fontSize: "$md", fontWeight: "$6" }}>Settings</Text>
<Flex css={{ flexDirection: "column", gap: "$3" }}>
<Text css={{ fontSize: "$sm" }}>Configure your preferences</Text>
<Text css={{ fontSize: "$sm" }}>Update your profile settings</Text>
<Text css={{ fontSize: "$sm" }}>Manage notifications</Text>
</Flex>
<PopoverClose asChild>
<Button size="sm" color="default">
Close
</Button>
</PopoverClose>
</Box>
<PopoverArrow />
</PopoverContent>
</Popover>
</Box>
);
};Props
Popover
| Prop | Type | Default |
|---|---|---|
defaultOpen? | boolean | - |
open? | boolean | - |
onOpenChange? | (open: boolean) => void | - |
modal? | boolean | false |
css? | object | - |
PopoverTrigger
| Prop | Type | Default |
|---|---|---|
asChild? | boolean | false |
PopoverContent
| Prop | Type | Default |
|---|---|---|
side? | 'top' | 'right' | 'bottom' | 'left' | 'bottom' |
sideOffset? | number | 0 |
align? | 'start' | 'center' | 'end' | 'center' |
alignOffset? | number | 0 |
avoidCollisions? | boolean | true |
collisionBoundary? | Boundary | [] |
collisionPadding? | number | Padding | 0 |
arrowPadding? | number | 0 |
sticky? | 'partial' | 'always' | 'partial' |
hideWhenDetached? | boolean | false |
forceMount? | boolean | - |
onOpenAutoFocus? | (event: Event) => void | - |
onCloseAutoFocus? | (event: Event) => void | - |
onEscapeKeyDown? | (event: KeyboardEvent) => void | - |
onPointerDownOutside? | (event: PointerDownOutsideEvent) => void | - |
onFocusOutside? | (event: FocusOutsideEvent) => void | - |
onInteractOutside? | (event: PointerDownOutsideEvent | FocusOutsideEvent) => void | - |
asChild? | boolean | false |
PopoverClose
| Prop | Type | Default |
|---|---|---|
asChild? | boolean | false |
PopoverArrow
| Prop | Type | Default |
|---|---|---|
width? | number | 10 |
height? | number | 5 |
asChild? | boolean | false |
PopoverPortal
| Prop | Type | Default |
|---|---|---|
forceMount? | boolean | - |
container? | HTMLElement | document.body |
PopoverAnchor
| Prop | Type | Default |
|---|---|---|
asChild? | boolean | false |
Data Attributes
These props are used for the conditional rendering of the components
Applicable - PopoverTrigger
| Prop | Type | Default |
|---|---|---|
[data-state]? | 'open' | 'closed' | - |
Applicable - PopoverContent
| Prop | Type | Default |
|---|---|---|
[data-state]? | 'open' | 'closed' | - |
[data-side]? | 'top' | 'right' | 'bottom' | 'left' | - |
[data-align]? | 'start' | 'center' | 'end' | - |
HoverCard
A component that displays additional content when hovering over a trigger element, with smooth animations and positioning control.
Tooltip
A popup that displays information related to an element when the element receives keyboard focus or the mouse hovers. Perfect for providing contextual help and additional information.