v2 introduces Svelte 5 support and an API overhaul to better solve the community requests from v1. Please check out the new documentation to see detailed examples and usage. The v1 documentation will remain available here
The following issues have been addressed or fixed with this release:
#7
#9
#18
#15
#17
#27
#21
#34
#35
Migration from v1
You can continue to use the v1 API and incrementally adopt the new API by using the svelte-modals/legacy
import. Please check out the migration guide for a detailed walkthrough.
Breaking changes
API
- Svelte 5 is now required as a peer dependency
modals
has been changed from a store to being the main entrypoint for most svelte-modals methods.openModal
->modals.open
and now returns a promise- when using
{ replace: true }
and the currently opened modal prevents the close, the promise will reject
- when using
closeModal
->modals.close
closeAllModals
->modals.closeAll
modals
->modals.stack
and changed from a store to a runeaction
->modals.action
and changed from a store to a runetransition
->modals.transition
and changed from a store to a rune
<Modals />
has been updated to use snippets instead of slots. The default slot has been changed to amodals
snippet.svelte-modals/legacy
continues to use slots and the default slot
- Deferred transitions are now enabled by using the
exitBeforeEnter
action instead of forwarding events
Types
SvelteModalComponent
has been renamed toModalComponent
and updated for Svelte 5 component typesLazySvelteModalComponent
has been renamed toLazyModalComponent
and updated for Svelte 5 component types