Skip to content

Basic Structure & Props

Your custom popup component is a standard React component that receives special props from ntPopups.

Injected Props

PropTypeDescription
closePopup(hasAction?: boolean) => voidFunction to close the popup. Pass true if the close was an intentional action.
popupstylesobjectCSS Module classes. Use these to style your component with the library's theme (e.g., popupstyles.header, popupstyles.body, popupstyles.baseButton).
requireActionbooleantrue if this popup must be closed via an action (disables 'X' button, backdrop click, etc.).
dataobjectAll custom props you pass via openPopup('my_type', { data: { ... } }) are here.

💡 Tip: When requireAction = true, closePopup() (or closePopup(false)) will not work. You must call closePopup(true) to close it.

Basic Common Structure

jsx
export default function MyCustomPopup({
  // Provided by library
  closePopup,      // Function to close popup
  popupstyles,     // Predefined CSS classes
  requireAction,   // Boolean - requires user action to close
  
  // Your custom props
  data = {}
}) {
  return (
    <>
      {/* Header */}
      <div className={popupstyles.header}>
        <div className={popupstyles.icon}>ⓘ</div>
        <span>Custom Popup Title</span>
      </div>

      {/* Body */}
      <div className={popupstyles.body}>
        <p>Your custom content here</p>
      </div>

      {/* Footer */}
      <div className={popupstyles.footer}>
        <button
          className={popupstyles.baseButton}
          base-button-style="0"
          onClick={() => closePopup(true)}
        >
          Confirm
        </button>
      </div>
    </>
  );
}