Reflex Logo
Docs Logo
Library

/

Overlay

/

Drawer

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

API Reference

rx.drawer.root

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

PropType | ValuesDefault
as_child
bool
-
default_open
bool
-
open
bool
-
modal
bool
`True`
direction
"top" | "right" | ...
`"bottom"`
dismissible
bool
-
handle_only
bool
-
snap_points
Union[Sequence, NoneType]
-
fade_from_index
int
the last snap point
scroll_lock_timeout
int
500ms
prevent_scroll_restoration
bool
`True`
should_scale_background
bool
-
close_threshold
float
-

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.

PropType | ValuesDefault
as_child
bool
true, if the first child acts as the trigger

rx.drawer.overlay

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

PropType | ValuesDefault
as_child
bool
-

rx.drawer.portal

Portals your drawer into the body.

PropType | ValuesDefault
as_child
bool
-

rx.drawer.content

Content that should be rendered in the drawer.

PropType | ValuesDefault
as_child
bool
-

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.

PropType | ValuesDefault
as_child
bool
true, if the first child acts as the trigger

Built with Reflex