Use attribute content to set the display content when hover. The attribute placement determines the position of the Popover. Its value is [orientation]-[alignment] with four orientations top, left, right, bottom and three alignments start, end, null, and the default alignment is null. Take placement="left-end" for example, Popover will display on the left of the element which you are hovering and the bottom of the Popover aligns with the bottom of the element.
Popover is built with ElTooltip. So for some duplicated attributes, please refer to the documentation of Tooltip.
The trigger attribute is used to define how popover is triggered: hover, click, focus or contextmenu . If you want to manually control it, you can set :visible.
export function PopoverBasicUsage() { const [visible, setVisible] = useState(false); return ( <> <ElPopover placement="top-start" title="Title" width={200} trigger="hover" content="this is content, this is content, this is content" > <ElButton className={styles.m2}>Hover to activate</ElButton> </ElPopover> <ElPopover placement="bottom" title="Title" width={200} trigger="click" content="this is content, this is content, this is content" > <ElButton className={styles.m2}>Click to activate</ElButton> </ElPopover> <ElPopover placement="right" title="Title" width={200} trigger="focus" content="this is content, this is content, this is content" > <ElButton className={styles.m2}>Focus to activate</ElButton> </ElPopover> <ElPopover title="Title" width={200} trigger="contextmenu" content="this is content, this is content, this is content" > <ElButton className={styles.m2}>contextmenu to activate</ElButton> </ElPopover> <ElPopover visible={visible} placement="bottom" title="Title" width={200} content="this is content, this is content, this is content" > <ElButton className={styles.m2} onClick={() => setVisible((value) => !value)}> Manual to activate </ElButton> </ElPopover> </> );}
Virtual triggering
Like Tooltip, Popover can be triggered by virtual elements, if your use case includes separate the triggering element and the content element, you should definitely use the mechanism, normally we use #reference to place our triggering element, with virtual-ref API you can set your triggering element anywhere you like, but notice that the triggering element should be an element that accepts mouse and keyboard event.
WARNING
v-popover is about to be deprecated, please use virtual-ref as alternative.
You can still using popover in directive way but this is not recommended anymore since this makes your application
complicated, you may refer to the virtual triggering for more information.
how the popover is triggered, not valid in controlled mode
enum / array
hover
trigger-keys 2.9.8
When you click the mouse to focus on the trigger element, you can define a set of keyboard codes to control the display of popover through the keyboard, not valid in controlled mode
Array
['Enter','Space']
title
popover title
string
—
effect
Tooltip theme, built-in theme: dark / light
enum / string
light
content
popover content, can be replaced with a default slot
string
''
width
popover width
string / number
150
placement
popover placement
enum
bottom
disabled
whether Popover is disabled
boolean
false
visible / v-model:visible
whether popover is visible
boolean / null
null
offset
popover offset, Popover is built with Tooltip, offset of Popover is undefined, but offset of Tooltip is 12
number
undefined
transition
popover transition animation, the default is el-fade-in-linear
string
—
show-arrow
whether a tooltip arrow is displayed or not. For more info, please refer to ElPopper