Popup
ProNewA promo popup as a split photo/form modal, left or right slide-in panel, corner card or countdown banner, opened by delay, scroll depth or exit intent.
Installation
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
Props
| Prop | Type | Default |
|---|---|---|
| layout | "modal" | "side" | "corner" | "banner"`modal` is a centred dialog, `side` a slide-in panel, `corner` a small pinned card, `banner` a bar along the top or bottom. | "modal" |
| open | booleanControlled visibility. | — |
| defaultOpen | booleanInitial visibility when uncontrolled. | false |
| onOpenChange | (open: boolean) => voidCalled when the popup opens by a trigger or is closed. | — |
| returnFocus | HTMLElement | nullElement to refocus on close when a controlled popup opens after its previous focus target was removed. | — |
| trigger | PopupTriggerOpens the popup by itself; the first condition that is met wins. | — |
| frequency | "always" | "session" | "once"How often a visitor sees it once dismissed: every time, once per browser session, or once ever. | "always" |
| storageKey | stringStorage key used to remember a dismissal. | "viewport-popup" |
| container | HTMLElement | nullRender inside this element instead of over the page. The popup is placed against it, scroll depth and exit intent are read from it, and the modal layout no longer traps focus or locks scrolling. Meant for previews and embedded frames; the element must be positioned. | — |
| position | "bottom-left" | "bottom-right" | "top-left" | "top-right" | "bottom" | "top"Corner for the `corner` layout; `top` or `bottom` for the banner. | — |
| title* | stringHeadline. | — |
| eyebrow | stringSmall line above the headline. | — |
| description | stringText under the headline. | — |
| logo | React.ReactNodeLogo shown above the headline. | — |
| image | stringPhoto: half of the modal, the top of the corner card, a thumbnail in the banner. | — |
| imageAlt | stringAlt text for the photo; leave empty when it is decorative. | "" |
| imageSide | "left" | "right"Side of the photo in the modal on wide screens. | "left" |
| fields | PopupField[]Form fields. With none, the button is a plain call to action. | [] |
| cta | stringButton label. | — |
| href | stringMakes the call to action a link. Ignored when there are fields. | — |
| onCta | () => voidCalled when the call to action is pressed and there are no fields. The popup then closes. | — |
| onSubmit | (values: Record<string, string>) => void | Promise<void>Called with the field values. Return a promise to show the busy state; reject to show `errorText`. | — |
| dismissLabel | stringText button under the form that closes the popup, for example "No, thanks". | — |
| code | stringCoupon code shown in a box with a copy button. | — |
| codeLabel | stringCaption above the coupon code. | "Your coupon code" |
| countdown | Date | number | stringDeadline for the countdown: a Date, a timestamp or a date string. | — |
| countdownLabel | stringCaption above the countdown. | — |
| expiredText | stringShown in place of the countdown once the deadline has passed. | "This offer has ended." |
| onExpire | () => voidCalled once when the countdown reaches zero. | — |
| successTitle | stringHeading shown after a successful submission. | "You're in!" |
| successText | stringText shown after a successful submission. | "Check your inbox for the details." |
| errorText | stringMessage shown when `onSubmit` fails. | "Something went wrong. Please try again." |
| closeLabel | stringName of the close button, also the label of the button under the success message. | "Close" |
| tone | "auto" | "dark" | "accent"Surface: `auto` follows the theme, `dark` is always dark, `accent` fills the popup with the accent color. | "auto" |
| accent | stringBrand color for the button, or the surface when `tone` is `accent`. | "#1f4bff" |
| buttonColor | stringButton fill; defaults to the accent, or near black on an accent surface. | — |
| buttonTextColor | stringButton text color. | "#fff" |
| shape | "rounded" | "square"`rounded` uses soft corners and pill fields, `square` uses sharp ones. | "rounded" |
| closeOnOverlay | booleanClose the modal when the backdrop is pressed. | true |
| className | string | — |
Accessibility
- Full-page modals and side panels are Radix dialogs: focus is trapped, the page behind is hidden from screen readers, Escape closes and focus returns to the opener or supplied returnFocus element.
- The corner card and banner are labelled non-modal dialogs that never take focus; a live region reads the headline when they arrive.
- Fields are labelled, a bad value is marked aria-invalid with its own role=alert message, and focus moves to the first one.
- While sending the button is aria-busy; the success heading takes focus so the result is read at once.
- The countdown is a role=timer with the time left as its name; paired panel/backdrop timing runs only when motion is allowed.