Reflex Logo

Intro

Gallery

Hosting

Learn

Components

Recipes

API Reference

Onboarding

Library

/

Chakra

/

Overlay

/

Modal

A modal dialog is a window overlaid on either the primary window or another dialog window. Content behind a modal dialog is inert, meaning that users cannot interact with it.

class ModalState(rx.State):
    show: bool = False

    def change(self):
        self.show = not (self.show)


def modal_example():
    return rx.chakra.vstack(
        rx.chakra.button(
            "Confirm", on_click=ModalState.change
        ),
        rx.chakra.modal(
            rx.chakra.modal_overlay(
                rx.chakra.modal_content(
                    rx.chakra.modal_header("Confirm"),
                    rx.chakra.modal_body(
                        "Do you want to confirm example?"
                    ),
                    rx.chakra.modal_footer(
                        rx.chakra.button(
                            "Close",
                            on_click=ModalState.change,
                        )
                    ),
                )
            ),
            is_open=ModalState.show,
        ),
    )

The wrapper that provides context for its children.

PropTypeDefault ValueValues
is_open
bool
allow_pinch_zoom
bool
auto_focus
bool
block_scroll_on_mount
bool
close_on_esc
bool
close_on_overlay_click
bool
is_centered
bool
lock_focus_across_frames
bool
motion_preset
str
preserve_scroll_bar_gap
bool
return_focus_on_close
bool
size
Literal
use_inert
bool

Event Triggers

TriggerDescription
on_close

Fired when the modal is closing.

on_close_complete

Fired when the modal is closed and the exit animation is complete.

on_esc

Fired when the Esc key is pressed.

on_overlay_click

Fired when the overlay is clicked.

The dimmed overlay behind the modal dialog.

Props

No component specific props

The container for the modal dialog's content.

Props

No component specific props

The header that labels the modal dialog.

Props

No component specific props

The wrapper that houses the modal's main content.

Props

No component specific props

The footer that houses the modal events.

Props

No component specific props

Did you find this useful?

HomeGalleryChangelogIntroductionHosting