- { options.label }
-
+
+ (cx);
+ create_effect(cx, move |_| {
+ let Some(label) = label_ref.get() else {
+ return;
+ };
+ let Some(label_list) = label_list_ref.get() else {
+ return;
+ };
+ if options.key == active_key.get() {
+ request_animation_frame(move || {
+ let list_rect = label_list.get_bounding_client_rect();
+ let rect = label.get_bounding_client_rect();
+ label_line.set(Some(TabsLabelLine {
+ width: rect.width(),
+ left: rect.left() - list_rect.left(),
+ }));
+ });
+ }
+ });
+ view! {cx, class=class_name,
+
+ { options.label }
+
+ }
}>
-
+
{ children(cx) }
@@ -41,6 +78,12 @@ pub fn Tabs(cx: Scope, active_key: RwSignal<&'static str>, children: Children) -
}
}
+#[derive(Clone)]
+pub(crate) struct TabsLabelLine {
+ width: f64,
+ left: f64,
+}
+
#[derive(Clone)]
pub struct TabsInjectionKey {
active_key: RwSignal<&'static str>,
diff --git a/src/tabs/tab.css b/src/tabs/tab.css
index d28c3f8..75b3261 100644
--- a/src/tabs/tab.css
+++ b/src/tabs/tab.css
@@ -1,3 +1,7 @@
+.melt-tab {
+ padding-top: 12px;
+}
+
.melt-tab--hidden {
display: none;
}
diff --git a/src/tabs/tabs.css b/src/tabs/tabs.css
index 59e62ca..6e46bc2 100644
--- a/src/tabs/tabs.css
+++ b/src/tabs/tabs.css
@@ -10,11 +10,11 @@
cursor: pointer;
}
-.melt-tabs-label__active {
+.melt-tabs-label__line {
position: absolute;
height: 3px;
background-color: var(--label-active-background-color);
border-radius: 3px;
bottom: 0;
left: 0;
-}
\ No newline at end of file
+}