docs/components/popover
Sections
Components
Utilities
Forms
Hooks
Copy Markdown
Overlay with extra info or options on trigger.
PreviewCode
Open
CLIManual
pnpmbunnpmyarn
pnpm dlx shadcn@latest add @shark/popover
Popover
├── PopoverTrigger
└── PopoverContent
├── PopoverHeader
│ ├── PopoverTitle
│ └── PopoverDescription
├── PopoverBody
├── PopoverFooter
└── PopoverClose
import {
Popover,
PopoverTrigger,
PopoverContent,
PopoverHeader,
PopoverTitle,
PopoverDescription,
PopoverBody,
PopoverFooter,
PopoverClose,
} from "@/components/ui/popover";
<Popover>
<PopoverTrigger />
<PopoverContent>
<PopoverHeader>
<PopoverTitle />
<PopoverDescription />
</PopoverHeader>
<PopoverBody>
</PopoverBody>
<PopoverFooter>
<PopoverClose />
</PopoverFooter>
</PopoverContent>
</Popover>
Use open and onOpenChange on the root to control the popover state.
PreviewCode
Open controlledOpen uncontrolled
Control the position of the popover relative to the trigger using the positioning prop.
PreviewCode
lefttopright
PopoverHeader supports two usage patterns:
Pass title and description props directly to PopoverHeader.
<PopoverHeader title="Popover Title" description="Popover description" />
This approach does not require
PopoverTitleorPopoverDescriptioncomponents.
Use PopoverTitle and PopoverDescription as children for more control.
<PopoverHeader>
<PopoverTitle>Popover Title</PopoverTitle>
<PopoverDescription>Popover description</PopoverDescription>
</PopoverHeader>
To make the popover non-modal, set the modal prop to false.
PreviewCode
Open
Nest popovers within one another.
PreviewCode
Open
Use PopoverAnchor to position the popover relative to a different element than the trigger.
PreviewCode
Open
Use showCloseButton prop to show a close button in the top-right corner.
PreviewCode
Open
Use closeOnInteractOutside and closeOnEscape props to prevent closing on outside click and escape.
PreviewCode
Open outside clickOpen escape
Use PopoverBody to make the content area scrollable while keeping header and footer fixed.
PreviewCode
Open
Render a popover inside a dialog.
PreviewCode
Open
Use [--space:--spacing("value")] on PopoverContent to adjust internal padding.
Default spacing is --spacing(4).
PreviewCode
Open
You can use breakpoint utilities to change the internal spacing at different screen sizes.
md:[--space:--spacing(6)] lg:[--space:--spacing(8)]
Root element of the popover.
| Prop | Type | Default |
|---|---|---|
open | boolean | - |
defaultOpen | boolean | - |
onOpenChange | (details: OpenChangeDetails) => void | - |
positioning | PositioningOptions | - |
modal | boolean | true |
closeOnInteractOutside | boolean | true |
closeOnEscape | boolean | true |
Opens the popover on click. Use asChild for custom trigger elements.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | - |
Element the popover is positioned relative to. Use when the reference is not the trigger.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | - |
Holds the popover panel content. Displayed in a portal.
| Prop | Type | Default |
|---|---|---|
showCloseButton | boolean | false |
className | string | - |
| Attribute | Default |
|---|---|
--space | --spacing(4) |
Header container. Accepts title and description props or children.
| Prop | Type | Default |
|---|---|---|
title | string | - |
description | string | - |
className | string | - |
Accessible title for the popover panel.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | - |
className | string | - |
Accessible description for the popover panel.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | - |
className | string | - |
Scrollable content area. Uses ScrollArea for overflow.
| Prop | Type | Default |
|---|---|---|
className | string | - |
Footer area for actions or secondary content.
| Prop | Type | Default |
|---|---|---|
className | string | - |
Closes the popover on click. Use asChild for custom close elements.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | - |
Optional arrow pointing toward the trigger element.
| Prop | Type | Default |
|---|---|---|
className | string | - |
| Attribute | Default |
|---|---|
--arrow-background | var(--popover) |
--arrow-size | calc(1.5 * var(--spacing)) |
For a complete list of props, see the Ark UI documentation.
[
Previous page
Password Input ](/docs/components/password-input)[
Next page
Progress ](/docs/components/progress)
On This Page
InstallationAnatomyUsageControlledPositioningTitle & DescriptionUsing propsUsing componentsExamplesNon-modalNestedAnchorClose buttonClose behaviorScrollableInside dialogCustom spacingAPI ReferencePopoverPopoverTriggerPopoverAnchorPopoverContentPopoverHeaderPopoverTitlePopoverDescriptionPopoverBodyPopoverFooterPopoverClosePopoverArrow