gpui_router/
outlet.rs

1use gpui::*;
2
3/// An outlet is a placeholder in the UI where routed components will be rendered.
4pub fn outlet() -> impl IntoElement {
5  Outlet::new()
6}
7
8/// A placeholder element for routed components.
9/// When no component is routed to this outlet, it renders as an empty element.
10#[derive(IntoElement)]
11pub struct Outlet {
12  pub(crate) element: AnyElement,
13}
14
15impl Default for Outlet {
16  fn default() -> Self {
17    Outlet {
18      element: Empty {}.into_any_element(),
19    }
20  }
21}
22
23impl Outlet {
24  pub fn new() -> Self {
25    Default::default()
26  }
27}
28
29impl From<AnyElement> for Outlet {
30  fn from(element: AnyElement) -> Outlet {
31    Outlet { element }
32  }
33}
34
35impl RenderOnce for Outlet {
36  fn render(self, _window: &mut Window, _cx: &mut App) -> impl IntoElement {
37    self.element
38  }
39}