-
Notifications
You must be signed in to change notification settings - Fork 422
Open
Description
Description
Use English with clear and concise description of the bug, if you just have a question or need help, please submit to Discussions.
Environment
- GPUI: v0.2.2
- GPUI Component: v0.5.0
- Platform: Windows 11
Steps to Reproduce
struct TabsWithContent {
active_tab: usize,
tab_contents: Vec<String>,
}
impl TabsWithContent {
fn render_tab_content(&self, cx: &mut Context<Self>) -> impl IntoElement {
match self.active_tab {
0 => div().child("Account content"),
1 => div().child("Profile content"),
2 => div().child("Settings content"),
_ => div().child("Unknown content"),
}
}
}
impl Render for TabsWithContent {
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
v_flex()
.child(
TabBar::new("content-tabs")
.selected_index(self.active_tab)
.on_click(cx.listener(|view, index, _, cx| {
view.active_tab = *index;
cx.notify();
}))
.child(Tab::new().label("Account"))
.child(Tab::new().label("Profile"))
.child(Tab::new().label("Settings"))
)
.child(
div()
.flex_1()
.p_4()
.child(self.render_tab_content(cx))
)
}
}Tabs with Close Buttons
Copilot