Reflex Logo

Intro

Gallery

Hosting

Learn

Components

Recipes

API Reference

Onboarding

Library

/

Chakra

/

Overlay

/

Drawer

The Drawer component is a panel that slides out from the edge of the screen. It can be useful when you need users to complete a task or view some details without leaving the current page.

class DrawerState(rx.State):
    show_right: bool = False
    show_top: bool = False

    def top(self):
        self.show_top = not (self.show_top)

    def right(self):
        self.show_right = not (self.show_right)


def drawer_example():
    return rx.chakra.vstack(
        rx.chakra.button(
            "Show Right Drawer", on_click=DrawerState.right
        ),
        rx.chakra.drawer(
            rx.chakra.drawer_overlay(
                rx.chakra.drawer_content(
                    rx.chakra.drawer_header("Confirm"),
                    rx.chakra.drawer_body(
                        "Do you want to confirm example?"
                    ),
                    rx.chakra.drawer_footer(
                        rx.chakra.button(
                            "Close",
                            on_click=DrawerState.right,
                        )
                    ),
                    bg="rgba(0, 0, 0, 0.3)",
                )
            ),
            is_open=DrawerState.show_right,
        ),
    )

Drawer can display from the top, bottom, left, or right. By defualt it displays to the right as seen above

rx.chakra.vstack(
    rx.chakra.button(
        "Show Top Drawer", on_click=DrawerState.top
    ),
    rx.chakra.drawer(
        rx.chakra.drawer_overlay(
            rx.chakra.drawer_content(
                rx.chakra.drawer_header("Confirm"),
                rx.chakra.drawer_body(
                    "Do you want to confirm example?"
                ),
                rx.chakra.drawer_footer(
                    rx.chakra.button(
                        "Close", on_click=DrawerState.top
                    )
                ),
            )
        ),
        placement="top",
        is_open=DrawerState.show_top,
    ),
)

A drawer component.

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
is_full_height
bool
lock_focus_across_frames
bool
placement
str
preserve_scroll_bar_gap
bool
return_focus_on_close
bool
size
Literal
use_inert
bool
variant
str
color_scheme
Literal

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.

Drawer overlay.

Props

No component specific props

Drawer content.

Props

No component specific props

Drawer header.

Props

No component specific props

Drawer body.

Props

No component specific props

Drawer footer.

Props

No component specific props

Did you find this useful?

HomeGalleryChangelogIntroductionHosting