Modal Contracts

ModalRenderProps<Input, Result>

Every registered component receives three namespaced props:

PropTypePurpose
inputInputData supplied to open()
resolve(value: Result) => voidCompletes the flow with a value
cancel(reason?: 'programmatic') => voidCancels the flow
function NameForm({
  input,
  resolve,
  cancel,
}: ModalRenderProps<{ initialName: string }, string>) {
  // ...
}

ModalOutcome<Result>

type ModalOutcome<Result> =
  | { status: 'resolved'; value: Result }
  | {
      status: 'cancelled';
      reason:
        | 'escape'
        | 'backdrop'
        | 'programmatic'
        | 'replaced'
        | 'provider-unmounted';
    };

Cancellation is normal control flow and never rejects the promise.

ModalOpenOptions

OptionPurpose
ariaLabelAccessible name, defaulting to Modal
ariaLabelledByID of a visible label
ariaDescribedByID of descriptive content
closeOnClickOutsideEnables backdrop cancellation; defaults to true
closeOnPressEscEnables Escape cancellation; defaults to true
positionOverrides preset placement
motionOverrides preset motion targets
backdropBackdrop className and inline style
bodyBody wrapper className and inline style
blurEnables an 8px backdrop filter

Options merge in this order:

  1. provider defaultOptions
  2. motion preset
  3. definition defaultOptions
  4. per-open options