Skip to main content

TabContent

Trait TabContent 

Source
pub trait TabContent: 'static {
    // Required methods
    fn render(
        &self,
        focused: bool,
        window: &mut Window,
        cx: &mut App,
    ) -> AnyElement;
    fn title(&self) -> SharedString;
}
Expand description

Content rendered inside a single tab of a Pane.

Object-safe by design (no generics, no Self return type) so Pane can hold a heterogeneous Vec<Box<dyn TabContent>>.

§Example

struct FileTab { path: SharedString }
impl TabContent for FileTab {
    fn render(&self, _focused: bool, _window: &mut Window, _cx: &mut App) -> AnyElement {
        div().child(self.path.clone()).into_any_element()
    }
    fn title(&self) -> SharedString { self.path.clone() }
}

Required Methods§

Source

fn render(&self, focused: bool, window: &mut Window, cx: &mut App) -> AnyElement

Renders this tab’s body. focused is true when this tab is the active tab of a Pane that is itself PaneGroup’s active pane.

Source

fn title(&self) -> SharedString

The label shown on the tab strip.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§