Unsave Popup
A popup component to confirm before discarding changes. Inspired by Discord, it will shake when the user tries to leave without saving.Playground
Open inInstallation
Usage Examples
Default Usage
// Default usage
<UnsavePopup
show={hasUnsavedChanges}
onSave={handleSave}
onReset={handleReset}
>
You have unsaved changes
</UnsavePopup>
When using compound components:
UnsavePopupDescription
UnsavePopupAction
UnsavePopupDismiss
You must include all three components together. Using them individually will throw an error.
Customized Usage
// Customized usage with compound components
<UnsavePopup show={hasUnsavedChanges} className="w-full">
<UnsavePopupDescription>
🔴 You have unsaved changes
</UnsavePopupDescription>
<UnsavePopupDismiss onClick={handleReset}>
Reset
</UnsavePopupDismiss>
<UnsavePopupAction onClick={handleSave}>
Save Changes
</UnsavePopupAction>
</UnsavePopup>
Props
<UnsavePopup />
Controls the visibility of the popup
The content to be displayed in the popup. Can be plain text for default usage, or compound components for custom usage
Callback function when save button is clicked (used in default mode)
Callback function when reset button is clicked (used in default mode)
Function to determine if the popup should trigger the block animation
Additional CSS classes to apply to the popup container
<UnsavePopupDescription />
The content to be displayed in the description area
<UnsavePopupAction />
The content of the action button
Controls the loading state of the button
Callback function when the action button is clicked
<UnsavePopupDismiss />
The content of the dismiss button
Callback function when the dismiss button is clicked