Magic Modallatest
API reference

Modal configuration

Configure animation, backdrop, swipe behavior, callbacks, and container style.

Pass a partial configuration as the second argument to magicModal.show:

magicModal.show(() => <SettingsModal />, {
  animationInTiming: 220,
  backdropColor: "rgba(8, 7, 20, 0.72)",
  swipeDirection: "down",
});

Prop

Type

NewConfigProps is the partial override accepted by show. The exported ModalProps type is the fully resolved internal shape after defaults are applied.

Direction

type Direction = "up" | "down" | "left" | "right";

Set swipeDirection to undefined to disable the dismiss gesture. This is recommended for scrollable content.

Callback overrides

Providing onBackdropPress or onBackButtonPress replaces the default close behavior. Call the supplied hide function yourself when the override should close:

magicModal.show(() => <DraftModal />, {
  onBackdropPress: ({ hide }) => {
    saveDraft();
    hide({ reason: MagicModalHideReason.BACKDROP_PRESS });
  },
});

On this page