Modal()

Creates a modal dialog overlay for displaying content that requires user interaction. Modals use the Popover API in MaterializeCSS 2.1.1+.

Syntax
Result = MaterialSB::Modal(Flags = #Modal_Default)
Parameters
Flags Optional. Combination of modal flags for styling and behavior.
Flags
FlagDescription
#Modal_DefaultStandard modal (default)
#Modal_FixedFooterFixed footer with scrolling content area
#Modal_BottomSheetBottom sheet style (slides up from bottom)
#Modal_DismissibleClick outside modal to close
Return Value

Returns the modal element. Use this reference for Init(), ModalOpen(), and ModalClose().

Remarks

Important: Modal requires Init() to be called before it can be opened.

Modals are automatically added to the document body, not inside the current parent. Use ModalHeader(), ModalContent(), and ModalFooter() to structure the modal. Both ModalContent() and ModalFooter() push to the parent stack.

MaterializeCSS 2.1.1+ uses the Popover API for modals instead of the older overlay system.

Example
Global myModal

Procedure CloseModal()
  MaterialSB::ModalClose(myModal)
EndProcedure

Procedure OpenModal()
  MaterialSB::ModalOpen(myModal)
EndProcedure

Procedure Main(Success)
  If Success
    ; Create the modal
    myModal = MaterialSB::Modal(MaterialSB::#Modal_FixedFooter)
    
    MaterialSB::ModalHeader("Confirm Action")
    
    MaterialSB::ModalContent()
      MaterialSB::Append(MaterialSB::Paragraph("Are you sure you want to proceed with this action?"))
      MaterialSB::Append(MaterialSB::Paragraph("This operation cannot be undone."))
    MaterialSB::CloseCurrentParent()
    
    MaterialSB::ModalFooter()
      MaterialSB::Button("Cancel", @CloseModal(), MaterialSB::#Button_Text)
      MaterialSB::Button("Confirm", @CloseModal())
    MaterialSB::CloseCurrentParent()
    
    ; Initialize the modal
    MaterialSB::Init(myModal, #Null)
    
    ; Create button to open modal
    MaterialSB::Row(MaterialSB::#Grid_Container)
      MaterialSB::Col(12)
        MaterialSB::Button("Open Modal", @OpenModal())
      MaterialSB::CloseCurrentParent()
    MaterialSB::CloseCurrentParent()
  EndIf
EndProcedure

MaterialSB::Download(@Main())
See Also

ModalHeader(), ModalContent(), ModalFooter(), ModalOpen(), ModalClose(), Init()