Popover
KPop is a popover component that comes in handy when you need to display more content than can fit in a tooltip.
<KPop
button-text="Open popover"
title="Communications settings"
width="350"
>
<template #content>
<KInputSwitch label="Receive marketing communications" />
<KInputSwitch label="Receive important updates" />
</template>
<template #footer>
<KButton>Apply</KButton>
</template>
</KPop>
NOTE
Check out KTooltip if you're looking for a component for showing tooltips. KPop is ideal for displaying more complex popover dialogs that might need to have interactive elements.
Props
buttonText
Popover trigger button text. If you want to use your custom element as a popover trigger, check out the default
slot.
<KPop button-text="Open popover">
<template #content>
Popover content.
</template>
</KPop>
title
Popover container title. Can also be slotted.
<KPop
title="Popover title"
button-text="Open popover"
>
<template #content>
Popover content.
</template>
</KPop>
placement
Placement of the popover.
Accepted values are:
auto
(default)top
top-start
top-end
left
left-start
left-end
right
right-start
right-end
bottom
bottom-start
bottom-end
<KPop
placement="bottom-end"
button-text="Open popover"
>
<template #content>
Popover content.
</template>
</KPop>
trigger
Whether popover should be opened on trigger element click or mouseover.
Accepted values are:
click
(default)hover
<KPop
trigger="hover"
button-text="Open popover"
>
<template #content>
Popover content.
</template>
</KPop>
popoverTimeout
When trigger
prop is hover
, you can provide a timeout for popover to wait before it closes. Default value is 300 milliseconds.
<KPop
:popover-timeout="3000"
trigger="hover"
button-text="Open popover"
>
<template #content>
Popover content.
</template>
</KPop>
disabled
Boolean to control whether popover should be disabled. Defaults to false
.
<KPop
disabled
button-text="Open popover"
>
<template #content>
Popover content.
</template>
</KPop>
hideCaret
Boolean to control whether the popover caret should be visible. Defaults to false
.
<KPop
hide-caret
button-text="Open popover"
>
<template #content>
Popover content.
</template>
</KPop>
closeOnPopoverClick
Boolean to control whether or not the popover should close when a user clicks within the popover content. Default to false
.
<KPop
close-on-popover-click
button-text="Open popover"
>
<template #content>
<KButton size="small">
Click here
</KButton>
</template>
</KPop>
hideCloseIcon
Boolean to hide close button in popover content.
<KPop
hide-close-icon
button-text="Open popover"
>
<template #content>
Popover content.
</template>
</KPop>
width
Width of the popover container. Default value is 200px
.
<KPop
width="500"
button-text="Open popover"
>
<template #content>
Popover content.
</template>
</KPop>
maxWidth
Maximum width of the popover container. Default value is auto
.
<KPop
max-width="120"
button-text="Open popover"
>
<template #content>
Popover content.
</template>
</KPop>
tag
KPop wrapper element type. Default value is div
.
popoverClasses
List of class names you want to assign to .k-popover
element.
<KPop
popover-classes="foo bar"
button-text="Open popover"
>
<template #content>
Popover content.
</template>
</KPop>
zIndex
Pass a number to use for the z-index
property. Default value is 1000
.
Slots
content
Slot for passing popover content.
<KPop button-text="Open popover">
<template #content>
Popover content.
</template>
</KPop>
default
Slot for passing custom popover trigger element.
NOTE
When providing your custom element as popover trigger, make sure to set appropriate tabindex
attribute in order to make popover accessible for assistive technology users.
<KPop hide-close-icon>
<KInput
label="Password"
type="password"
placeholder="Enter a strong password"
/>
<template #content>
Must contain at least one special character: *!&#.
</template>
</KPop>
DANGER
KPop logic is built on the presumption that trigger element is going to be in the DOM when the component is mounted. If you need to render the element conditionally, avoid setting v-if
directive on the trigger element directly and render the entire KPop component conditionally instead.
<KPop v-if="!loading">
<KButton>Open popover</KButton>
<template #content>
...
</template>
</KPop>
<KPop>
<KButton v-if="!loading">Open popover</KButton>
<template #content>
...
</template>
</KPop>
<KPop>
<template
#default
v-if="!loading"
>
<KButton>Open popover</KButton>
</template>
<template #content>
...
</template>
</KPop>
title
Slot for passing custom popover title.
<KPop button-text="Open popover">
<template #title>
Popover title
</template>
<template #content>
Popover content.
</template>
</KPop>
footer
Slot for passing footer content that goes directly underneath main popover content.
<KPop button-text="Open popover">
<template #content>
Popover content.
</template>
<template #footer>
<KBadge>Footer</KBadge>
</template>
</KPop>
Events
open
Fires when the popover is opened.
close
Fires when the popover is closed.
popover-click
Fires when the popover content is clicked.