pub fn side_bar_provider(
args: SideBarProviderArgs,
state: Arc<RwLock<SideBarProviderState>>,
main_content: impl FnOnce() + Send + Sync + 'static,
side_bar_content: impl FnOnce() + Send + Sync + 'static,
)
Expand description
Renders a side bar UI group, managing its animation, scrim, keyboard handling and content.
This is the primary function to create a side bar. Call it inside a component that owns or
has access to the application’s shared state. The provider renders the main content first,
then the scrim (overlay) and the side bar when the state
indicates visibility.
§Arguments
args
: Configuration options including theon_close_request
callback and visualstyle
. SeeSideBarProviderArgs
.state
: Shared state controlling open/closed animation timing. SeeSideBarProviderState
.main_content
: Closure rendering the always-visible main UI (background for the side bar).side_bar_content
: Closure rendering the side bar’s content.
The provider registers a keyboard handler that invokes the provided on_close_request
when
the Escape
key is pressed. Clicking the scrim also triggers the same callback.