For AI agents: the complete documentation index is at llms.txt. Markdown versions are available by appending .md or sending Accept: text/markdown.
Reflex Logo
Docs Logo
Library

/

Overlay

/

Drawer

Drawer

Expand

This example shows how to create a sidebar menu with a drawer. The drawer is opened by clicking a button. The drawer contains links to different sections of the page. When a link is clicked the drawer closes and the page scrolls to the section.

The rx.drawer.root component has an open prop that is set by the state variable is_open. Setting the modal prop to False allows the user to interact with the rest of the page while the drawer is open and allows the page to be scrolled when a user clicks one of the links.

Test1

Test2

Expand

API Reference

rx.drawer.root

The Root component of a Drawer, contains all parts of a drawer.

Props

PropTypeDescription
as_child
bool

Change the default rendered element for the one passed as a child.

default_open
bool

The open state of the drawer when it is initially rendered. Use when you do not need to control its open state.

open
bool

Whether the drawer is open or not.

modal
bool

When False, it allows interaction with elements outside of the drawer without closing it.

direction
"top""right""bottom""left"

Direction of the drawer. This adjusts the animations and the drag direction.

dismissible
bool

When False, dragging, clicking outside, pressing esc, etc. will not close the drawer. Use this in combination with the open prop, otherwise you won't be able to open/close the drawer.

handle_only
bool

When True, dragging will only be possible by the handle.

snap_points
Union[Sequence, NoneType]

Array of numbers from 0 to 100 that corresponds to % of the screen a given snap point should take up. Should go from least visible. Also Accept px values, which doesn't take screen height into account.

fade_from_index
int

Index of a snapPoint from which the overlay fade should be applied.

scroll_lock_timeout
int

Duration for which the drawer is not draggable after scrolling content inside of the drawer.

prevent_scroll_restoration
bool

When True, it prevents scroll restoration.

should_scale_background
bool

Enable background scaling, it requires container element with vaul-drawer-wrapper attribute to scale its background.

close_threshold
float

Number between 0 and 1 that determines when the drawer should be closed.

Event Triggers

See the full list of default event triggers
TriggerDescription
on_open_changeFires when the drawer is opened or closed.
on_animation_endGets triggered after the open or close animation ends, it receives an open argument with the open state of the drawer by the time the function was triggered.

rx.drawer.trigger

The button that opens the dialog.

Props

PropTypeDescription
as_child
bool

rx.drawer.overlay

A layer that covers the inert portion of the view when the dialog is open.

Props

PropTypeDescription
as_child
bool

Change the default rendered element for the one passed as a child.

rx.drawer.portal

Portals your drawer into the body.

Props

PropTypeDescription
as_child
bool

Change the default rendered element for the one passed as a child.

rx.drawer.content

Content that should be rendered in the drawer.

Props

PropTypeDescription
as_child
bool

Change the default rendered element for the one passed as a child.

Event Triggers

See the full list of default event triggers
TriggerDescription
on_open_auto_focusFired when the drawer content is opened.
on_close_auto_focusFired when the drawer content is closed.
on_escape_key_downFired when the escape key is pressed.
on_pointer_down_outsideFired when the pointer is down outside the drawer content.
on_interact_outsideFired when interacting outside the drawer content.

rx.drawer.close

A button that closes the drawer.

Props

PropTypeDescription
as_child
bool

Built with Reflex