Popover
Used to show detailed information inside a pop-up
Naruto is a Japanese manga series written and illustrated by Masashi Kishimoto.
Usage
import { Popover } from "@chakra-ui/react"<Popover.Root>
<Popover.Trigger />
<Popover.Positioner>
<Popover.Content>
<Popover.CloseTrigger />
<Popover.Arrow>
<Popover.ArrowTip />
</Popover.Arrow>
<Popover.Body>
<Popover.Title />
</Popover.Body>
</Popover.Content>
</Popover.Positioner>
</Popover.Root>Shortcuts
The Popover provides a shortcuts for common use cases.
Arrow
The Popover.Arrow renders the Popover.ArrowTip component within in by
default.
This works:
<Popover.Arrow>
<Popover.ArrowTip />
</Popover.Arrow>This might be more concise, if you don't need to customize the arrow tip.
<Popover.Arrow />Examples
Controlled
Use the open and onOpenChange to control the visibility of the popover.
Sizes
Use the size prop to change the size of the popover component.
Naruto is a Japanese manga series written and illustrated by Masashi Kishimoto.
Naruto is a Japanese manga series written and illustrated by Masashi Kishimoto.
Naruto is a Japanese manga series written and illustrated by Masashi Kishimoto.
Naruto is a Japanese manga series written and illustrated by Masashi Kishimoto.
Lazy Mount
Use the lazyMounted and/or unmountOnExit prop to defer the mounting of the
popover content until it's opened.
Placement
Use the positioning.placement prop to configure the underlying floating-ui
positioning logic.
Offset
Use the positioning.offset prop to adjust the position of the popover content.
Same Width
Use the positioning.sameWidth prop to make the popover content the same width
as the trigger.
Nested Popover
When nesting floating elements like popover, select, menu, inside of the popover, avoid portalling them to the document's body.
-<Portal>
<Popover.Positioner>
<Popover.Content>
{/* ... */}
</Popover.Content>
</Popover.Positioner>
-</Portal>Naruto is a Japanese manga series written and illustrated by Masashi Kishimoto.
Initial Focus
Use the initialFocusEl prop to set the initial focus of the popover content.
Form
Here's an example of a popover with a form inside.
Custom Background
Use the --popover-bg CSS variable to change the background color of the
popover content and its arrow.
Naruto is a Japanese manga series written and illustrated by Masashi Kishimoto.
Within Dialog
To use the Popover within a Dialog, you need to avoid portalling the
Popover.Positioner to the document's body.
-<Portal>
<Popover.Positioner>
<Popover.Content>
{/* ... */}
</Popover.Content>
</Popover.Positioner>
-</Portal>If you have set scrollBehavior="inside" on the Dialog, you need to:
- Set the popover positioning to
fixedto avoid the popover from being clipped by the dialog. - Set
hideWhenDetachedtotrueto hide the popover when the trigger is scrolled out of view.
<Popover.Root positioning={{ strategy: "fixed", hideWhenDetached: true }}>
{/* ... */}
</Popover.Root>Props
Root
| Prop | Default | Type |
|---|---|---|
autoFocus | true | booleanWhether to automatically set focus on the first focusable content within the popover when opened. |
closeOnEscape | true | booleanWhether to close the popover when the escape key is pressed. |
closeOnInteractOutside | true | booleanWhether to close the popover when the user clicks outside of the popover. |
lazyMount | false | booleanWhether to enable lazy mounting |
modal | false | booleanWhether the popover should be modal. When set to `true`: - interaction with outside elements will be disabled - only popover content will be visible to screen readers - scrolling is blocked - focus is trapped within the popover |
portalled | true | booleanWhether the popover is portalled. This will proxy the tabbing behavior regardless of the DOM position of the popover content. |
skipAnimationOnMount | false | booleanWhether to allow the initial presence animation. |
unmountOnExit | false | booleanWhether to unmount on exit. |
colorPalette | gray | 'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'cyan' | 'purple' | 'pink'The color palette of the component |
size | md | 'xs' | 'sm' | 'md' | 'lg'The size of the component |
as | React.ElementTypeThe underlying element to render. | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. | |
unstyled | booleanWhether to remove the component's style. | |
defaultOpen | booleanThe initial open state of the popover when rendered. Use when you don't need to control the open state of the popover. | |
id | stringThe unique identifier of the machine. | |
ids | Partial<{
anchor: string
trigger: string
content: string
title: string
description: string
closeTrigger: string
positioner: string
arrow: string
}>The ids of the elements in the popover. Useful for composition. | |
immediate | booleanWhether to synchronize the present change immediately or defer it to the next frame | |
initialFocusEl | () => HTMLElement | nullThe element to focus on when the popover is opened. | |
onEscapeKeyDown | (event: KeyboardEvent) => voidFunction called when the escape key is pressed | |
onExitComplete | VoidFunctionFunction called when the animation ends in the closed state | |
onFocusOutside | (event: FocusOutsideEvent) => voidFunction called when the focus is moved outside the component | |
onInteractOutside | (event: InteractOutsideEvent) => voidFunction called when an interaction happens outside the component | |
onOpenChange | (details: OpenChangeDetails) => voidFunction invoked when the popover opens or closes | |
onPointerDownOutside | (event: PointerDownOutsideEvent) => voidFunction called when the pointer is pressed down outside the component | |
open | booleanThe controlled open state of the popover | |
persistentElements | (() => Element | null)[]Returns the persistent elements that: - should not have pointer-events disabled - should not trigger the dismiss event | |
positioning | PositioningOptionsThe user provided options used to position the popover content | |
present | booleanWhether the node is present (controlled by the user) |
Explorer
Explore the Popover component parts interactively. Click on parts in the
sidebar to highlight them in the preview.
Fill in your favorite character below:
Component Anatomy
Hover to highlight, click to select parts
arrow
arrowTip
anchor
trigger
indicator
positioner
content
title
description
closeTrigger
header
body
footer