πŸš€ Ship faster with premium components πŸš€
Search documentation v1.1.0

Exit Intent Popup

Display a popup for leaving users

πŸš€ Launch faster

Get access to premium UI components, templates, and much more!

Source Report Issue
Command docs
How to add this block to your project
npm run add ExitIntentPopup

Use the ExitIntentPopup component to detect when a user is about to leave your page and display a popup with a targeted message or offer.

Preview

Move your mouse towards the address bar, outside the window to trigger the popup.

Unlock code
How to use the ExitIntentPopup component in Astro
---
import { Button, Input } from 'webcoreui/astro'
const modal = {
title: 'πŸš€ Launch faster'
}
---
<ExitIntentPopup modal={modal}>
<p>Get access to premium UI components, templates, and much more!</p>
<div class="flex column md">
<Input type="email" placeholder="Your email address" />
<Button>Get Access</Button>
</div>
</ExitIntentPopup>

The component works in the following way:

You can create any type of popup by passing content as the children of the component. To customize the modal itself, pass a modal prop that accepts an object in the form of ModalProps.

If you need to tweak the logic on when this popup should be triggered, you can modify the shouldShowExitIntent variable inside the component.

Cookies

You can also specify a cookie prop to prevent showing the popup again to users for x days after it has been showed. For example, the following popup will only be shown once every 15 days:

Unlock code
How to use cookies
<ExitIntentPopup
modal={modal}
cookie="exitIntentShown"
cookieDays={15} {/* Defaults to 30 */}
>
...
</ExitIntentPopup>

If the cookie prop is not set, no cookies will be stored, and the popup will trigger for the next session.

API

Unlock code
Component API reference
type ExitIntentPopupProps = {
timeOut?: number
cookie?: string
cookieDays?: number
modal?: ModalProps
className?: string
}
For ModalProps please see the documentation of the Modal component.
PropDefaultPurpose
timeOut 10_000 Sets the minimum time in seconds a user has to spend on the page to trigger the popup.
cookie - Sets the name of the cookie that is set when the popup becomes visible.
cookieDays 30 Sets the expiration date for the cookie.
modal - Pass ModalProps to customize the modal.
className - Pass additional CSS classes for the component.