Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: slide the selected pill on every segmented toggle (#14030)

Etherlaead5249354d
diff --git a/studio/frontend/scripts/check-bundle-budget.ts b/studio/frontend/scripts/check-bundle-budget.ts
index 895b6c7b32a..fc168f7d40f 100644
--- a/studio/frontend/scripts/check-bundle-budget.ts
+++ b/studio/frontend/scripts/check-bundle-budget.ts
@@ -196,8 +196,12 @@ export const BUDGET = {
// 95). Nearly all of it is searching a model maker in the Model hub (#13998, +3,038 B raw / +1,000 B transfer):
// its owner-to-uploads search lives in use-hub-model-search, a hook the startup screen already loads, so there
// is no separate module to lazy-load. #13999 and #13993 add 79 B raw / 58 B transfer. Raised by that growth.
- transferBytes: 2_045_781,
- rawBytes: 6_801_415,
+ // Sliding the selected pill on every segmented toggle (#14030) adds 4,432 B raw / 1,696 B transfer
+ // (6,800,980 -> 6,805,412 B raw, 2,045,645 -> 2,047,341 B transfer against 15e4bc8fde, one machine and build,
+ // Node 24, chunk count unchanged at 95): the shared slide module and SegmentedPill, imported by toggles that
+ // already live in startup chunks, so there is no separate module to lazy-load. Raised by that growth.
+ transferBytes: 2_047_477,
+ rawBytes: 6_805_847,
};
// The chunk count is reported but not budgeted. Splitting a page out of the entry raises it while lowering the
diff --git a/studio/frontend/src/components/resource-picker/picker-tab-toggle.tsx b/studio/frontend/src/components/resource-picker/picker-tab-toggle.tsx
index 480e4f83e0c..a395b705ed4 100644
--- a/studio/frontend/src/components/resource-picker/picker-tab-toggle.tsx
+++ b/studio/frontend/src/components/resource-picker/picker-tab-toggle.tsx
@@ -1,8 +1,9 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-import { SegmentedControlIndicator } from "@/components/segmented-control";
+import { SegmentedPill } from "@/components/segmented-control";
import { cn } from "@/lib/utils";
+import { useId } from "react";
import { PICKER_OPTION_FOCUS_VISIBLE_CLASS } from "./picker-focus";
import { pickerTabId } from "./picker-tab-state";
@@ -40,6 +41,7 @@ export function PickerTabToggle<T extends string>({
ariaLabel: string;
}) {
const [first, second] = options;
+ const pillId = useId();
return (
<div
role="tablist"
@@ -57,11 +59,6 @@ export function PickerTabToggle<T extends string>({
document.getElementById(pickerTabId(idBase, target))?.focus();
}}
>
- <SegmentedControlIndicator
- activeIndex={tab === second.value ? 1 : 0}
- optionCount={options.length}
- className="inset-y-0 start-0"
- />
{options.map((entry) => {
const selected = tab === entry.value;
return (
@@ -75,13 +72,14 @@ export function PickerTabToggle<T extends string>({
tabIndex={selected ? 0 : -1}
onClick={() => onTabChange(entry.value)}
className={cn(
- "relative z-10 inline-flex h-full flex-1 select-none items-center justify-center rounded-full px-3 text-ui-12p5 font-medium transition-colors",
+ "relative inline-flex h-full flex-1 select-none items-center justify-center rounded-full px-3 text-ui-12p5 font-medium transition-colors",
PICKER_OPTION_FOCUS_VISIBLE_CLASS,
selected
? "text-foreground"
: "text-muted-foreground hover:text-foreground",
)}
>
+ {selected && <SegmentedPill group={`${pillId}-pill`} />}
{entry.label}
</button>
);
diff --git a/studio/frontend/src/components/segmented-control.tsx b/studio/frontend/src/components/segmented-control.tsx
index 0b5fb59b74b..5538994f840 100644
--- a/studio/frontend/src/components/segmented-control.tsx
+++ b/studio/frontend/src/components/segmented-control.tsx
@@ -2,12 +2,13 @@
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
import { cn } from "@/lib/utils";
-import { type CSSProperties, type ReactNode, useId } from "react";
+import { type ReactNode, useId, useLayoutEffect, useRef } from "react";
import {
type SegmentedSize,
segmentedSegmentLabel,
segmentedTrackHeight,
} from "./segmented-control-styles";
+import { watchSegmentedPill } from "./segmented-pill-slide";
interface SegmentedControlOption<T extends string> {
value: T;
@@ -15,31 +16,53 @@ interface SegmentedControlOption<T extends string> {
disabled?: boolean;
}
-export function SegmentedControlIndicator({
- activeIndex,
- optionCount,
+const HIDDEN = { display: "none" } as const;
+
+/** The selected segment's pill. Render it inside the active (`relative`)
+ * segment only, with a `group` id unique to the control: when the selection
+ * moves, the new pill slides in from the old one's place on the compositor
+ * (see segmented-pill-slide), or appears in place under reduced motion. It
+ * sits at -z-10 in the track, so the track must isolate (`.hub-tab-toggle`
+ * does) and the segments must not: a segment with its own stacking context
+ * lets the sliding pill cover its neighbours' labels. */
+export function SegmentedPill({
+ group,
className,
- width = `${100 / optionCount}%`,
}: {
- activeIndex: number;
- optionCount: number;
+ group: string;
className?: string;
- width?: CSSProperties["width"];
}) {
+ const ref = useRef<HTMLSpanElement>(null);
+ useLayoutEffect(() => {
+ if (!ref.current) return;
+ return watchSegmentedPill(group, ref.current);
+ }, [group]);
return (
<span
+ ref={ref}
aria-hidden="true"
className={cn(
- "hub-tab-toggle-pill pointer-events-none absolute start-0 rounded-full transition-transform duration-200 ease-out [transform:translateX(calc(var(--segmented-control-index)*100%))] rtl:[transform:translateX(calc(var(--segmented-control-index)*-100%))]",
+ "hub-tab-toggle-pill pointer-events-none absolute inset-0 -z-10 rounded-full",
className,
)}
- style={
- {
- "--segmented-control-index": activeIndex,
- width,
- } as CSSProperties
- }
- />
+ >
+ {/* Shown only while sliding between segments of different widths:
+ the pill's shadow, then its fill. */}
+ <span
+ className={cn(
+ "hub-tab-toggle-pill absolute inset-y-0 left-0 rounded-full",
+ className,
+ )}
+ style={HIDDEN}
+ />
+ <span
+ className={cn(
+ "hub-tab-toggle-pill absolute inset-0 rounded-full",
+ className,
+ )}
+ style={HIDDEN}
+ />
+ </span>
);
}
@@ -63,11 +86,6 @@ export function SegmentedControl<T extends string>({
className?: string;
}) {
const name = useId();
- const activeIndex = Math.max(
- 0,
- options.findIndex((option) => option.value === value),
- );
-
return (
<div
role="radiogroup"
@@ -78,21 +96,17 @@ export function SegmentedControl<T extends string>({
className,
)}
>
- <SegmentedControlIndicator
- activeIndex={activeIndex}
- optionCount={options.length}
- className="inset-y-0"
- />
{options.map((option) => {
const active = option.value === value;
return (
<label
key={option.value}
className={cn(
- "relative z-10 flex h-full min-w-0 flex-1 cursor-pointer rounded-full",
+ "relative flex h-full min-w-0 flex-1 cursor-pointer rounded-full",
option.disabled && "cursor-not-allowed opacity-50",
)}
>
+ {active && <SegmentedPill group={`${name}-pill`} />}
<input
type="radio"
name={name}
diff --git a/studio/frontend/src/components/segmented-pill-slide.ts b/studio/frontend/src/components/segmented-pill-slide.ts
new file mode 100644
index 00000000000..9a4e8b7e622
--- /dev/null
+++ b/studio/frontend/src/components/segmented-pill-slide.ts
@@ -0,0 +1,247 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import { prefersReducedMotion } from "@/features/settings";
+
+// Slides a segmented control's selected pill from the old segment to the new one
+// without running script per frame or forcing layout during the click:
+// - geometry is read once per switch, in the first ResizeObserver callback for
+// the new pill's segment, after the browser has laid out the frame anyway.
+// Both the old and the new segment are measured then, so nothing is cached
+// that could go stale;
+// - the slide is a transform-only Web Animation on both axes (tracks can wrap),
+// which the compositor runs off the main thread. When the two segments differ
+// in width, a fill inside the pill changes width through a round clip-path
+// inset, so the ends stay round (a scaleX would squash them). Chromium runs
+// that on the compositor too; other engines repaint it on the main thread,
+// still with no script.
+// At rest the pill paints itself and the fill and its shadow are hidden.
+
+/** Spring the design system gives segmented controls (design.md, 2.5 Motion). */
+const SPRING = { stiffness: 500, damping: 35, mass: 0.5 };
+
+/** The spring's progress toward the new segment, sampled every millisecond until it settles. */
+const SPRING_CURVE: number[] = (() => {
+ const curve: number[] = [];
+ let offset = 1;
+ let velocity = 0;
+ while (curve.length < 2000) {
+ curve.push(1 - offset);
+ if (Math.abs(offset) < 0.002 && Math.abs(velocity) < 0.05) break;
+ velocity +=
+ ((-SPRING.stiffness * offset - SPRING.damping * velocity) / SPRING.mass) *
+ 0.001;
+ offset += velocity * 0.001;
+ }
+ curve[curve.length - 1] = 1;
+ return curve;
+})();
+
+const SLIDE_MS = SPRING_CURVE.length - 1;
+
+/** Where the CSS curve takes its points: dense early, where the spring moves fastest. */
+const STOPS = [
+ 0.02, 0.04, 0.06, 0.08, 0.1, 0.13, 0.16, 0.2, 0.25, 0.3, 0.36, 0.43, 0.5, 0.6,
+ 0.7, 0.85,
+];
+
+/** design.md's reveal curve, for engines without linear(). */
+const FALLBACK = [0.22, 1, 0.36, 1] as const;
+
+/** cubic-bezier(FALLBACK) sampled every millisecond of the slide. */
+function bezierCurve(): number[] {
+ const [x1, y1, x2, y2] = FALLBACK;
+ const bezier = (a: number, b: number, t: number) =>
+ 3 * (1 - t) ** 2 * t * a + 3 * (1 - t) * t * t * b + t ** 3;
+ const curve: number[] = [];
+ for (let ms = 0; ms <= SLIDE_MS; ms++) {
+ // x(t) only grows, so bisect for the t where it reaches this point in time.
+ const x = ms / SLIDE_MS;
+ let lo = 0;
+ let hi = 1;
+ for (let i = 0; i < 30; i++) {
+ const t = (lo + hi) / 2;
+ if (bezier(x1, x2, t) < x) lo = t;
+ else hi = t;
+ }
+ curve.push(bezier(y1, y2, (lo + hi) / 2));
+ }
+ curve[SLIDE_MS] = 1;
+ return curve;
+}
+
+const HAS_LINEAR =
+ typeof CSS !== "undefined" &&
+ !!CSS.supports?.("transition-timing-function", "linear(0, 1)");
+
+const EASING = HAS_LINEAR
+ ? `linear(0, ${STOPS.map(
+ (at) =>
+ `${SPRING_CURVE[Math.round(at * SLIDE_MS)].toFixed(3)} ${Math.round(at * 100)}%`,
+ ).join(", ")}, 1)`
+ : `cubic-bezier(${FALLBACK.join(", ")})`;
+
+/** Progress of the curve the slide actually runs, so an interrupted slide
+ * restarts from where its pill is drawn. */
+const CURVE = HAS_LINEAR ? SPRING_CURVE : bezierCurve();
+
+function progressAt(ms: number): number {
+ if (ms >= SLIDE_MS) return 1;
+ return CURVE[Math.max(0, Math.round(ms))];
+}
+
+/** Animation timeline time, which the slide's startTime is set from. */
+function now(): number {
+ const time = document.timeline.currentTime;
+ return typeof time === "number" ? time : performance.now();
+}
+
+interface Box {
+ x: number;
+ y: number;
+ w: number;
+}
+
+interface PillState {
+ track: HTMLElement;
+ segment: HTMLElement;
+ /** Offset of the drawn pill from its segment's box when the slide began. */
+ slide?: { dx: number; dy: number; dw: number; start: number };
+}
+
+/** The last pill of each control, keyed by the control's group id. */
+const pills = new Map<string, PillState>();
+
+/** The track isolates (SegmentedPill sits at -z-10 in it); the segment does not. */
+function findTrack(segment: HTMLElement): HTMLElement {
+ for (let node = segment.parentElement; node; node = node.parentElement) {
+ if (getComputedStyle(node).isolation === "isolate") return node;
+ }
+ return segment.parentElement ?? segment;
+}
+
+/** The pill fills its segment's padding box. Layout pixels, transforms
+ * ignored, relative to the page: only differences between two segments of
+ * one track are used. */
+function measure(segment: HTMLElement): Box {
+ let x = segment.clientLeft;
+ let y = segment.clientTop;
+ for (
+ let node: HTMLElement | null = segment;
+ node;
+ node = node.offsetParent as HTMLElement | null
+ ) {
+ x += node.offsetLeft;
+ y += node.offsetTop;
+ }
+ return { x, y, w: segment.clientWidth };
+}
+
+function slide(
+ root: HTMLElement,
+ w: number,
+ dx: number,
+ dy: number,
+ dw: number,
+) {
+ const timing = { duration: SLIDE_MS, easing: EASING };
+ const animations = [
+ root.animate(
+ [{ transform: `translate(${dx}px, ${dy}px)` }, { transform: "none" }],
+ timing,
+ ),
+ ];
+ const [shadow, fill] = Array.from(root.children) as HTMLElement[];
+ const resize = fill && Math.abs(dw) >= 0.5;
+ if (resize) {
+ // The pill spans the wider of the two widths; the fill's clip shows the
+ // current one. A clip also cuts the fill's shadow, so a shadow-only copy
+ // of the pill underneath stretches with it. Its scale bends the shadow's
+ // ends a little, which the blur hides; a filter would follow the clip
+ // instead, but Chromium draws it from a stale clip and leaves a ghost.
+ const span = Math.max(w, w + dw);
+ const inset = (width: number) =>
+ `inset(0 ${span - width}px 0 0 round 9999px)`;
+ root.style.right = "auto";
+ root.style.width = `${span}px`;
+ root.style.setProperty("background-color", "transparent", "important");
+ root.style.setProperty("box-shadow", "none", "important");
+ shadow.style.width = `${w}px`;
+ shadow.style.transformOrigin = "left";
+ shadow.style.setProperty("background-color", "transparent", "important");
+ shadow.style.display = "block";
+ fill.style.setProperty("box-shadow", "none", "important");
+ fill.style.display = "block";
+ animations.push(
+ shadow.animate(
+ [{ transform: `scaleX(${(w + dw) / w})` }, { transform: "none" }],
+ timing,
+ ),
+ fill.animate(
+ [{ clipPath: inset(w + dw) }, { clipPath: inset(w) }],
+ timing,
+ ),
+ );
+ }
+ // One start time, so the move and the resize stay in step.
+ const start = document.timeline.currentTime;
+ for (const animation of animations) animation.startTime = start;
+ if (!resize) return;
+ Promise.all(animations.map((animation) => animation.finished)).then(
+ () => {
+ for (const property of [
+ "right",
+ "width",
+ "background-color",
+ "box-shadow",
+ ]) {
+ root.style.removeProperty(property);
+ }
+ shadow.style.display = "none";
+ fill.style.display = "none";
+ },
+ () => {},
+ );
+}
+
+function place(group: string, root: HTMLElement, segment: HTMLElement) {
+ const track = findTrack(segment);
+ const state: PillState = { track, segment };
+ const prev = pills.get(group);
+ for (const [key, other] of pills) {
+ if (!other.track.isConnected) pills.delete(key);
+ }
+ pills.set(group, state);
+ if (
+ !prev ||
+ prev.track !== track ||
+ !prev.segment.isConnected ||
+ prefersReducedMotion()
+ ) {
+ return;
+ }
+ const from = measure(prev.segment);
+ const to = measure(segment);
+ if (!from.w || !to.w) return;
+ // Start from where the old pill is drawn now, mid-slide included.
+ const time = now();
+ const remaining = prev.slide ? 1 - progressAt(time - prev.slide.start) : 0;
+ const dx = from.x + (prev.slide?.dx ?? 0) * remaining - to.x;
+ const dy = from.y + (prev.slide?.dy ?? 0) * remaining - to.y;
+ const dw = from.w + (prev.slide?.dw ?? 0) * remaining - to.w;
+ if (Math.abs(dx) < 0.5 && Math.abs(dy) < 0.5 && Math.abs(dw) < 0.5) return;
+ state.slide = { dx, dy, dw, start: time };
+ slide(root, to.w, dx, dy, dw);
+}
+
+/** Track a mounted pill: once its segment has been laid out, slide it in from
+ * the control's previous pill. Returns the cleanup. */
+export function watchSegmentedPill(group: string, root: HTMLElement) {
+ const segment = root.parentElement ?? root;
+ const observer = new ResizeObserver(() => {
+ observer.disconnect();
+ place(group, root, segment);
+ });
+ observer.observe(segment);
+ return () => observer.disconnect();
+}
diff --git a/studio/frontend/src/components/segmented-tabs.tsx b/studio/frontend/src/components/segmented-tabs.tsx
index fdcf951b7d4..4a457c44a5c 100644
--- a/studio/frontend/src/components/segmented-tabs.tsx
+++ b/studio/frontend/src/components/segmented-tabs.tsx
@@ -2,8 +2,8 @@
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
import { cn } from "@/lib/utils";
-import type { ReactNode } from "react";
-import { SegmentedControlIndicator } from "./segmented-control";
+import { type ReactNode, useId } from "react";
+import { SegmentedPill } from "./segmented-control";
import {
type SegmentedSize,
segmentedSegmentLabel,
@@ -34,11 +34,7 @@ export function SegmentedTabsList<T extends string>({
size?: SegmentedSize;
className?: string;
}) {
- const activeIndex = Math.max(
- 0,
- options.findIndex((option) => option.value === value),
- );
-
+ const pillId = useId();
return (
<TabsList
unstyled={true}
@@ -49,11 +45,6 @@ export function SegmentedTabsList<T extends string>({
className,
)}
>
- <SegmentedControlIndicator
- activeIndex={activeIndex}
- optionCount={options.length}
- className="inset-y-0"
- />
{options.map((option) => {
const active = option.value === value;
return (
@@ -61,9 +52,9 @@ export function SegmentedTabsList<T extends string>({
key={option.value}
value={option.value}
disabled={option.disabled}
- indicatorClassName="hidden"
+ indicator={<SegmentedPill group={`${pillId}-pill`} />}
className={cn(
- "relative z-10 h-full min-w-0 flex-1 cursor-pointer rounded-full border-0 py-0",
+ "relative h-full min-w-0 flex-1 cursor-pointer rounded-full border-0 py-0",
segmentedSegmentLabel,
active
? "text-foreground"
diff --git a/studio/frontend/src/components/ui/tabs.tsx b/studio/frontend/src/components/ui/tabs.tsx
index 22f2cef66c3..f8a9ce7d591 100644
--- a/studio/frontend/src/components/ui/tabs.tsx
+++ b/studio/frontend/src/components/ui/tabs.tsx
@@ -89,11 +89,14 @@ export function TabsList({
type TabsTriggerProps = React.ComponentProps<typeof TabsPrimitive.Trigger> & {
indicatorClassName?: string;
+ /** Drawn in place of the built-in sliding background while this tab is active. */
+ indicator?: React.ReactNode;
};
export function TabsTrigger({
className,
indicatorClassName,
+ indicator,
value,
children,
...props
@@ -118,7 +121,8 @@ export function TabsTrigger({
)}
{...props}
>
- {isActive && (
+ {isActive && indicator}
+ {isActive && !indicator && (
<motion.span
layoutId={`tab-bg-${ctx.id}`}
className={cn(
diff --git a/studio/frontend/src/features/audio/audio-page.tsx b/studio/frontend/src/features/audio/audio-page.tsx
index 1fbbe8086a8..69c075d5a3e 100644
--- a/studio/frontend/src/features/audio/audio-page.tsx
+++ b/studio/frontend/src/features/audio/audio-page.tsx
@@ -1779,7 +1779,7 @@ export function AudioPage({
void navigateSelf({ to: "/studio" });
}}
fit={true}
- className="h-[calc(34px*var(--ui-space-scale,1))] [&>button]:h-[calc(34px*var(--ui-space-scale,1))] [&>button]:px-3 @[68rem]:[&>button]:px-11 @max-[30rem]:[&>button]:px-2.5 @max-[30rem]:[&>button>span]:sr-only"
+ className="h-[calc(34px*var(--ui-space-scale,1))] [&>button]:h-[calc(34px*var(--ui-space-scale,1))] [&>button]:px-3 @[68rem]:[&>button]:px-11 @max-[30rem]:[&>button]:px-2.5 @max-[30rem]:[&>button>[data-pill-tab-label]]:sr-only"
tabs={[
{
value: "create",
diff --git a/studio/frontend/src/features/hub/catalog/model-search-filters.tsx b/studio/frontend/src/features/hub/catalog/model-search-filters.tsx
index 040a1721515..bad1c304c96 100644
--- a/studio/frontend/src/features/hub/catalog/model-search-filters.tsx
+++ b/studio/frontend/src/features/hub/catalog/model-search-filters.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { SegmentedPill } from "@/components/segmented-control";
import { Button } from "@/components/ui/button";
import { Switch } from "@/components/ui/switch";
import {
@@ -34,7 +35,7 @@ import {
ViewIcon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon, type IconSvgElement } from "@hugeicons/react";
-import { type ReactNode, useEffect, useState } from "react";
+import { type ReactNode, useEffect, useId, useState } from "react";
import type { HubCapabilityFilter } from "../lib/model-capabilities";
import {
HUB_UPLOADERS,
@@ -443,6 +444,7 @@ function SegmentedRow<T extends string>({
options: readonly (readonly [T, string])[];
onChange: (value: T) => void;
}) {
+ const pillId = useId();
return (
<div className="flex items-center justify-between gap-3 px-3">
<span className="text-ui-12 text-muted-foreground">
@@ -471,10 +473,16 @@ function SegmentedRow<T extends string>({
className={cn(
"relative flex h-8 cursor-pointer items-center rounded-full px-3 text-xs font-medium transition-colors",
active
- ? "hub-tab-toggle-pill text-foreground dark:bg-[color-mix(in_srgb,var(--accent),white_8%)]!"
+ ? "text-foreground"
: "text-muted-foreground hover:text-foreground",
)}
>
+ {active && (
+ <SegmentedPill
+ group={`${pillId}-segment`}
+ className="dark:bg-[color-mix(in_srgb,var(--accent),white_8%)]!"
+ />
+ )}
<span className="relative z-10">{text}</span>
</button>
);
diff --git a/studio/frontend/src/features/hub/catalog/models-table.tsx b/studio/frontend/src/features/hub/catalog/models-table.tsx
index 3a9c23c737b..056279c72a8 100644
--- a/studio/frontend/src/features/hub/catalog/models-table.tsx
+++ b/studio/frontend/src/features/hub/catalog/models-table.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { SegmentedPill } from "@/components/segmented-control";
import { useVllmAvailable, useVllmPlatform } from "@/features/model-picker";
import {
Tooltip,
@@ -29,7 +30,7 @@ import {
} from "lucide-react";
import type { IconSvgElement } from "@hugeicons/react";
import { HugeiconsIcon } from "@hugeicons/react";
-import { type ReactNode, memo, useMemo } from "react";
+import { type ReactNode, memo, useId, useMemo } from "react";
import type { DiscoverRow } from "../types";
import {
DOWNLOADING_DOT_CLASS,
@@ -58,11 +59,13 @@ export type AllModelsView = "two" | "split";
function ViewToggleButton({
active,
+ pillId,
label,
icon,
onClick,
}: {
active: boolean;
+ pillId: string;
label: string;
icon: IconSvgElement;
onClick: () => void;
@@ -76,12 +79,13 @@ function ViewToggleButton({
aria-label={label}
onClick={onClick}
className={cn(
- "relative z-10 inline-flex size-8 cursor-pointer items-center justify-center rounded-full transition-colors",
+ "relative inline-flex size-8 cursor-pointer items-center justify-center rounded-full transition-colors",
active
? "text-foreground"
: "text-muted-foreground hover:text-foreground",
)}
>
+ {active && <SegmentedPill group={pillId} />}
<HugeiconsIcon icon={icon} strokeWidth={1.75} className="size-3.5" />
</button>
</TooltipTrigger>
@@ -115,6 +119,7 @@ export function HubListHeader({
isRefreshing?: boolean;
actions?: ReactNode;
}) {
+ const viewPillId = useId();
const accessibleLabel =
count && count > 0 ? `${title} (${count.toLocaleString()})` : undefined;
@@ -182,20 +187,15 @@ export function HubListHeader({
className="hub-tab-toggle relative inline-flex h-8 shrink-0 items-center rounded-full"
aria-label="Results layout"
>
- <span
- aria-hidden="true"
- className="hub-tab-toggle-pill pointer-events-none absolute inset-y-0 left-0 w-8 rounded-full transition-transform duration-200 ease-out"
- style={{
- transform: `translateX(${view === "split" ? 100 : 0}%)`,
- }}
- />
<ViewToggleButton
+ pillId={viewPillId}
active={view === "two"}
label="Two columns"
icon={LayoutTwoColumnIcon}
onClick={() => onViewChange("two")}
/>
<ViewToggleButton
+ pillId={viewPillId}
active={view === "split"}
label="Split view"
icon={ViewSidebarLeftIcon}
diff --git a/studio/frontend/src/features/hub/catalog/models-toolbar.tsx b/studio/frontend/src/features/hub/catalog/models-toolbar.tsx
index 65e77bb7a92..fa6221e40e1 100644
--- a/studio/frontend/src/features/hub/catalog/models-toolbar.tsx
+++ b/studio/frontend/src/features/hub/catalog/models-toolbar.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { SegmentedPill } from "@/components/segmented-control";
import { Checkbox } from "@/components/ui/checkbox";
import { Input } from "@/components/ui/input";
import { Spinner } from "@/components/ui/spinner";
@@ -22,7 +23,7 @@ import {
SparklesIcon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
-import { memo, useLayoutEffect, useMemo, useRef, useState } from "react";
+import { memo, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
import type { HubCapabilityFilter } from "../lib/model-capabilities";
import type {
HubUploader,
@@ -150,6 +151,7 @@ export const ModelsToolbar = memo(function ModelsToolbar({
onOpenFineTune: () => void;
npuAvailable?: boolean;
}) {
+ const viewPillId = useId();
// Recent searches surface while the empty search field is focused, only on
// Discover (on-device search is a local filter and isn't recorded).
const recentSearches = useRecentSearches();
@@ -313,26 +315,19 @@ export const ModelsToolbar = memo(function ModelsToolbar({
role="radiogroup"
aria-label="View"
>
- <span
- aria-hidden="true"
- className={cn(
- "hub-tab-toggle-pill",
- "pointer-events-none absolute inset-y-0 left-0 w-1/2 rounded-full transition-transform duration-200 ease-out",
- tab === "downloaded" ? "translate-x-full" : "translate-x-0",
- )}
- />
<button
type="button"
role="radio"
aria-checked={tab === "discover"}
onClick={() => onTabChange("discover")}
className={cn(
- "relative z-10 inline-flex h-9 flex-1 items-center justify-center rounded-full px-3 text-ui-12p5 transition-colors",
+ "relative inline-flex h-9 flex-1 items-center justify-center rounded-full px-3 text-ui-12p5 transition-colors",
tab === "discover"
? "text-foreground"
: "text-muted-foreground hover:text-foreground",
)}
>
+ {tab === "discover" && <SegmentedPill group={viewPillId} />}
Discover
</button>
<button
@@ -341,12 +336,13 @@ export const ModelsToolbar = memo(function ModelsToolbar({
aria-checked={tab === "downloaded"}
onClick={() => onTabChange("downloaded")}
className={cn(
- "relative z-10 inline-flex h-9 flex-1 items-center justify-center rounded-full px-3 text-ui-12p5 transition-colors",
+ "relative inline-flex h-9 flex-1 items-center justify-center rounded-full px-3 text-ui-12p5 transition-colors",
tab === "downloaded"
? "text-foreground"
: "text-muted-foreground hover:text-foreground",
)}
>
+ {tab === "downloaded" && <SegmentedPill group={viewPillId} />}
On Device
</button>
</div>
diff --git a/studio/frontend/src/features/hub/catalog/transport-toggle.tsx b/studio/frontend/src/features/hub/catalog/transport-toggle.tsx
index 6c0aa5422eb..61c76773254 100644
--- a/studio/frontend/src/features/hub/catalog/transport-toggle.tsx
+++ b/studio/frontend/src/features/hub/catalog/transport-toggle.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { SegmentedPill } from "@/components/segmented-control";
import {
Tooltip,
TooltipContent,
@@ -11,7 +12,7 @@ import {
useTransportMode,
} from "@/features/hub/download-manager";
import { cn } from "@/lib/utils";
-import { useEffect } from "react";
+import { useEffect, useId } from "react";
const OPTIONS: { value: "auto" | "http" | "xet"; label: string; hint: string }[] =
[
@@ -34,6 +35,7 @@ const OPTIONS: { value: "auto" | "http" | "xet"; label: string; hint: string }[]
export function TransportToggle() {
const [mode, setMode] = useTransportMode();
+ const pillId = useId();
const { capabilities, isLoading } = useDownloadTransportCapabilities();
// Two questions. Xet cannot be CHOSEN until we know it runs here; the fallback may only fire
// once we know it does NOT, or a loading tab shows HTTP for a stored Xet that was fine.
@@ -53,7 +55,7 @@ export function TransportToggle() {
return (
<fieldset
aria-label="Download transport"
- className="hub-tag-soft m-0 inline-flex h-[calc(26px*var(--ui-space-scale,1))] min-w-0 items-center gap-0.5 rounded-full border-0 p-0.5 text-ui-11"
+ className="hub-tag-soft isolate m-0 inline-flex h-[calc(26px*var(--ui-space-scale,1))] min-w-0 items-center gap-0.5 rounded-full border-0 p-0.5 text-ui-11"
>
{OPTIONS.map((opt) => {
const active = mode === opt.value;
@@ -79,14 +81,17 @@ export function TransportToggle() {
if (!disabled) setMode(opt.value);
}}
className={cn(
- "inline-flex h-[calc(22px*var(--ui-space-scale,1))] items-center justify-center rounded-full px-2 font-medium tracking-tight transition-colors",
+ "relative inline-flex h-[calc(22px*var(--ui-space-scale,1))] items-center justify-center rounded-full px-2 font-medium tracking-tight transition-colors",
disabled
? "cursor-not-allowed text-muted-foreground/45"
: active
- ? "hub-tab-toggle-pill cursor-pointer text-foreground"
+ ? "cursor-pointer text-foreground"
: "cursor-pointer text-muted-foreground hover:text-foreground/80",
)}
>
+ {active && !disabled && (
+ <SegmentedPill group={`${pillId}-transport`} />
+ )}
{opt.label}
</button>
</TooltipTrigger>
diff --git a/studio/frontend/src/features/hub/hub.css b/studio/frontend/src/features/hub/hub.css
index c1a08905d06..eca027c973a 100644
--- a/studio/frontend/src/features/hub/hub.css
+++ b/studio/frontend/src/features/hub/hub.css
@@ -754,6 +754,12 @@
segmented toggle in the app (Hub Discover/On Device, Models/Datasets,
Unsloth/All, Recent/Name/Size, plus Settings + Train tabs) shares one
design: a soft track with a white, softly-shadowed sliding pill. */
+ /* The selected pill sits at -z-10 under every segment's label (see
+ SegmentedPill), so the track keeps it from sinking below the page. */
+ .hub-tab-toggle {
+ isolation: isolate;
+ }
+
html:not(.dark) .hub-tab-toggle {
background-color: color-mix(in srgb, var(--foreground) calc(5% * var(--contrast-wash-gain, 1)), transparent);
border: 0;
@@ -804,13 +810,6 @@
background-color: color-mix(in srgb, var(--foreground) calc(5% * var(--contrast-wash-gain, 1)), var(--background));
}
- /* A tab is a real button, so unlike the sliding indicator it can hover. In
- light the pill is already the lightest thing on the panel, so it stays
- put rather than moving the only direction left, which is down. */
- html:not(.dark) .hub-tab-toggle-pill[role="tab"]:hover {
- background-color: var(--background);
- }
-
/* The selected segment takes --accent, the app's one selection colour, so it
reads like every other lit row. As its own wash it was scaled by the wash
gain, which falls much further than the token does: at the bottom of the
diff --git a/studio/frontend/src/features/images/images-page.tsx b/studio/frontend/src/features/images/images-page.tsx
index c6e9977660d..8e91a080c21 100644
--- a/studio/frontend/src/features/images/images-page.tsx
+++ b/studio/frontend/src/features/images/images-page.tsx
@@ -5141,7 +5141,7 @@ export function ImagesPage({
value={pageMode}
onValueChange={(v) => setPageMode(v as "create" | "train")}
fit={true}
- className="h-[calc(34px*var(--ui-space-scale,1))] [&>button]:h-[calc(34px*var(--ui-space-scale,1))] [&>button]:px-3 @[68rem]:[&>button]:px-11 @max-[30rem]:[&>button]:px-2.5 @max-[30rem]:[&>button>span]:sr-only"
+ className="h-[calc(34px*var(--ui-space-scale,1))] [&>button]:h-[calc(34px*var(--ui-space-scale,1))] [&>button]:px-3 @[68rem]:[&>button]:px-11 @max-[30rem]:[&>button]:px-2.5 @max-[30rem]:[&>button>[data-pill-tab-label]]:sr-only"
tabs={[
{ value: "create", label: "Create", icon: <HugeiconsIcon icon={SparklesIcon} className="size-3.5" /> },
{ value: "train", label: "Train", icon: <HugeiconsIcon icon={TestTubeOutlineIcon} className="size-3.5" /> },
diff --git a/studio/frontend/src/features/model-picker/components/model-selector/pill-tabs.tsx b/studio/frontend/src/features/model-picker/components/model-selector/pill-tabs.tsx
index 0603490db8e..bb88791645a 100644
--- a/studio/frontend/src/features/model-picker/components/model-selector/pill-tabs.tsx
+++ b/studio/frontend/src/features/model-picker/components/model-selector/pill-tabs.tsx
@@ -1,8 +1,9 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { SegmentedPill } from "@/components/segmented-control";
import { cn } from "@/lib/utils";
-import type { ReactNode } from "react";
+import { type ReactNode, useId } from "react";
export interface PillTab {
value: string;
@@ -34,15 +35,11 @@ export function PillTabs({
dataTour?: string;
/** Block every tab, for a choice that cannot be applied right now. */
disabled?: boolean;
- /** Size each tab to its label instead of equal widths. The active tab carries
- * the pill background directly (the toggle never animates). Tabs only shrink
+ /** Size each tab to its label instead of equal widths. Tabs only shrink
* when their combined intrinsic width exceeds the available space. */
fit?: boolean;
}) {
- const activeIndex = Math.max(
- 0,
- tabs.findIndex((tab) => tab.value === value),
- );
+ const pillId = useId();
return (
<div
role="tablist"
@@ -57,16 +54,6 @@ export function PillTabs({
className,
)}
>
- {!fit && (
- <span
- aria-hidden="true"
- style={{
- width: `${100 / tabs.length}%`,
- transform: `translateX(${activeIndex * 100}%)`,
- }}
- className="hub-tab-toggle-pill pointer-events-none absolute inset-y-0 left-0 rounded-full transition-transform duration-200 ease-out"
- />
- )}
{tabs.map((tab, index) => (
<button
key={tab.value}
@@ -95,7 +82,7 @@ export function PillTabs({
}}
onClick={() => onValueChange(tab.value)}
className={cn(
- "relative z-10 inline-flex items-center justify-center gap-1.5 rounded-full transition-colors",
+ "relative inline-flex items-center justify-center gap-1.5 rounded-full transition-colors",
(disabled || tab.disabled) && "cursor-not-allowed opacity-50",
fit ? "min-w-0 shrink" : "min-w-0 flex-1",
compact
@@ -104,15 +91,15 @@ export function PillTabs({
value === tab.value
? "text-foreground"
: "text-muted-foreground hover:text-foreground",
- // The active tab carries the pill; its hover lives on the pill
- // rules in hub.css. The pin that used to sit here was written
- // without a mode variant, so in dark it painted the page colour
- // over the pill and pointing at the selected tab blacked it out.
- fit && value === tab.value && "hub-tab-toggle-pill",
)}
>
+ {value === tab.value && <SegmentedPill group={`${pillId}-pill`} />}
{tab.icon}
- <span className="min-w-0 truncate">{tab.label}</span>
+ {/* Consumers target the label by this marker; a bare `> span`
+ would also match the pill. */}
+ <span data-pill-tab-label className="min-w-0 truncate">
+ {tab.label}
+ </span>
</button>
))}
</div>
diff --git a/studio/frontend/src/features/profile/components/profile-personalization-panel.tsx b/studio/frontend/src/features/profile/components/profile-personalization-panel.tsx
index 67efa254f9d..0f07fb10644 100644
--- a/studio/frontend/src/features/profile/components/profile-personalization-panel.tsx
+++ b/studio/frontend/src/features/profile/components/profile-personalization-panel.tsx
@@ -2,6 +2,7 @@
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
import { publicAssetUrl } from "@/components/mascot-img";
+import { SegmentedPill } from "@/components/segmented-control";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
@@ -21,7 +22,7 @@ import {
Upload01Icon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
-import { useEffect, useRef, useState } from "react";
+import { useEffect, useId, useRef, useState } from "react";
import { SLOTH_AVATARS } from "../sloth-avatars";
import { loginDisplayName } from "../hooks/use-effective-profile";
import { decodeJwtSubject } from "../utils/jwt-subject";
@@ -71,6 +72,7 @@ function readPersistedProfile(): {
export function ProfilePersonalizationPanel() {
const t = useT();
+ const pillId = useId();
const displayName = useUserProfileStore((s) => s.displayName);
const nickname = useUserProfileStore((s) => s.nickname);
const avatarDataUrl = useUserProfileStore((s) => s.avatarDataUrl);
@@ -270,12 +272,15 @@ export function ProfilePersonalizationPanel() {
onClick={() => setAvatarShape(shape)}
aria-pressed={avatarShape === shape}
className={cn(
- "inline-flex h-8 items-center justify-center rounded-full px-3.5 text-ui-13 font-medium transition-colors",
+ "relative inline-flex h-8 items-center justify-center rounded-full px-3.5 text-ui-13 font-medium transition-colors",
avatarShape === shape
- ? "hub-tab-toggle-pill text-foreground"
+ ? "text-foreground"
: "text-muted-foreground hover:text-foreground",
)}
>
+ {avatarShape === shape && (
+ <SegmentedPill group={`${pillId}-avatar-shape`} />
+ )}
{shape === "circle"
? t("settings.profile.avatarShapeCircle")
: t("settings.profile.avatarShapeRounded")}
diff --git a/studio/frontend/src/features/profile/components/stats/token-activity-card.tsx b/studio/frontend/src/features/profile/components/stats/token-activity-card.tsx
index e823f12a303..dfa76e8c7ef 100644
--- a/studio/frontend/src/features/profile/components/stats/token-activity-card.tsx
+++ b/studio/frontend/src/features/profile/components/stats/token-activity-card.tsx
@@ -1,11 +1,12 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { SegmentedPill } from "@/components/segmented-control";
import { ChartContainer, ChartTooltip } from "@/components/ui/chart";
import type { ChartConfig } from "@/components/ui/chart";
import { useLocale, useT } from "@/i18n";
import { cn } from "@/lib/utils";
-import { useEffect, useMemo, useRef, useState } from "react";
+import { useEffect, useId, useMemo, useRef, useState } from "react";
import {
Bar,
BarChart,
@@ -373,6 +374,7 @@ function WeekChart({
export function TokenActivityCard({ daily }: { daily: ProfileStatsDay[] }) {
const t = useT();
+ const pillId = useId();
const [mode, setMode] = useState<ActivityMode>("daily");
const maxColumns = Math.ceil(daily.length / DAYS_PER_WEEK) + 1;
const { ref, columns } = useVisibleColumns(maxColumns);
@@ -468,12 +470,15 @@ export function TokenActivityCard({ daily }: { daily: ProfileStatsDay[] }) {
onClick={() => setMode(option)}
aria-pressed={mode === option}
className={cn(
- "inline-flex h-8 items-center rounded-full px-3 text-ui-13 font-medium transition-colors",
+ "relative inline-flex h-8 items-center rounded-full px-3 text-ui-13 font-medium transition-colors",
mode === option
- ? "hub-tab-toggle-pill text-foreground"
+ ? "text-foreground"
: "text-muted-foreground hover:text-foreground",
)}
>
+ {mode === option && (
+ <SegmentedPill group={`${pillId}-mode`} />
+ )}
{t(`settings.profile.stats.mode.${option}`)}
</button>
))}
diff --git a/studio/frontend/src/features/settings/components/audio-api-examples.tsx b/studio/frontend/src/features/settings/components/audio-api-examples.tsx
index 0e67f407e41..dfc9f71585c 100644
--- a/studio/frontend/src/features/settings/components/audio-api-examples.tsx
+++ b/studio/frontend/src/features/settings/components/audio-api-examples.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { SegmentedPill } from "@/components/segmented-control";
import { usePlatformStore } from "@/config/env";
import { useT } from "@/i18n";
import type { TranslationKey } from "@/i18n";
@@ -9,7 +10,14 @@ import { Tick02Icon } from "@/lib/tick-icon";
import { cn } from "@/lib/utils";
import { Copy01Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
-import { type ReactNode, useEffect, useMemo, useRef, useState } from "react";
+import {
+ type ReactNode,
+ useEffect,
+ useId,
+ useMemo,
+ useRef,
+ useState,
+} from "react";
import type {
KeylessApiAccessExposure,
KeylessApiAccessScope,
@@ -66,10 +74,12 @@ const RUN_LABEL: Record<AudioRunWorkflow, TranslationKey> = {
function Pill({
active,
+ pillGroup,
onClick,
children,
}: {
active: boolean;
+ pillGroup: string;
onClick: () => void;
children: ReactNode;
}) {
@@ -79,12 +89,13 @@ function Pill({
onClick={onClick}
aria-pressed={active}
className={cn(
- "rounded-full px-2.5 py-1 text-ui-11 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
+ "relative rounded-full px-2.5 py-1 text-ui-11 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
active
- ? "hub-tab-toggle-pill text-foreground"
+ ? "text-foreground"
: "text-muted-foreground hover:text-foreground",
)}
>
+ {active && <SegmentedPill group={pillGroup} />}
{children}
</button>
);
@@ -102,6 +113,7 @@ export function AudioApiExamples({
keylessExposure?: KeylessApiAccessExposure | null;
}) {
const t = useT();
+ const pillId = useId();
const deviceType = usePlatformStore((s) => s.deviceType);
const cloudflareUrl = usePlatformStore((s) => s.cloudflareUrl);
const serverUrl = usePlatformStore((s) => s.serverUrl);
@@ -253,11 +265,12 @@ export function AudioApiExamples({
</p>
<div className="min-w-0 max-w-full overflow-hidden rounded-lg border border-border bg-muted/20">
<div className="flex min-w-0 flex-wrap items-center justify-between gap-x-2 gap-y-1 border-b border-border px-2 py-1.5">
- <div className="flex min-w-0 flex-wrap items-center gap-0.5">
+ <div className="isolate flex min-w-0 flex-wrap items-center gap-0.5">
{AUDIO_API_TABS.map((id) => (
<Pill
key={id}
active={tab === id}
+ pillGroup={`${pillId}-tab`}
onClick={() => {
setTab(id);
setStoredTab(id);
@@ -267,11 +280,12 @@ export function AudioApiExamples({
</Pill>
))}
</div>
- <div className="flex min-w-0 flex-wrap items-center gap-0.5">
+ <div className="isolate flex min-w-0 flex-wrap items-center gap-0.5">
{LANGS.map((item) => (
<Pill
key={item.id}
active={lang === item.id}
+ pillGroup={`${pillId}-lang`}
onClick={() => {
setLang(item.id);
const stored = audioLangToStore(
@@ -287,18 +301,24 @@ export function AudioApiExamples({
</div>
</div>
{tab === "workflows" ? (
- <div className="flex min-w-0 flex-wrap items-center gap-0.5 border-b border-border px-2 py-1.5">
+ <div className="isolate flex min-w-0 flex-wrap items-center gap-0.5 border-b border-border px-2 py-1.5">
{AUDIO_RUN_WORKFLOWS.map((id) => (
- <Pill key={id} active={run === id} onClick={() => setRun(id)}>
+ <Pill
+ key={id}
+ active={run === id}
+ pillGroup={`${pillId}-run`}
+ onClick={() => setRun(id)}
+ >
{t(RUN_LABEL[id])}
</Pill>
))}
</div>
) : null}
{lang === "curl" ? (
- <div className="flex min-w-0 items-center gap-0.5 border-b border-border px-2 py-1.5">
+ <div className="isolate flex min-w-0 items-center gap-0.5 border-b border-border px-2 py-1.5">
<Pill
active={os === "unix"}
+ pillGroup={`${pillId}-os`}
onClick={() => {
setOs("unix");
setStoredOs("unix");
@@ -308,6 +328,7 @@ export function AudioApiExamples({
</Pill>
<Pill
active={os === "windows"}
+ pillGroup={`${pillId}-os`}
onClick={() => {
setOs("windows");
setStoredOs("windows");
diff --git a/studio/frontend/src/features/settings/components/composer-settings.tsx b/studio/frontend/src/features/settings/components/composer-settings.tsx
index 5c609e441f6..108d8c57fa5 100644
--- a/studio/frontend/src/features/settings/components/composer-settings.tsx
+++ b/studio/frontend/src/features/settings/components/composer-settings.tsx
@@ -1,7 +1,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-import { useEffect, useRef } from "react";
+import { useEffect, useId, useRef } from "react";
+import { SegmentedPill } from "@/components/segmented-control";
import {
Select,
SelectContent,
@@ -23,6 +24,7 @@ import { SettingsSection } from "./settings-section";
export function ComposerSettings({ embedded = false }: { embedded?: boolean }) {
const t = useT();
+ const pillId = useId();
const prefs = useChatPreferencesStore();
const ref = useRef<HTMLDivElement>(null);
const scrollTarget = useSettingsDialogStore((s) => s.scrollTarget);
@@ -115,12 +117,15 @@ export function ComposerSettings({ embedded = false }: { embedded?: boolean }) {
aria-pressed={prefs.followUpBehavior === behavior}
onClick={() => prefs.setFollowUpBehavior(behavior)}
className={cn(
- "inline-flex h-8 cursor-pointer items-center rounded-full px-3.5 text-ui-12 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
+ "relative inline-flex h-8 cursor-pointer items-center rounded-full px-3.5 text-ui-12 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
prefs.followUpBehavior === behavior
- ? "hub-tab-toggle-pill text-foreground"
+ ? "text-foreground"
: "text-muted-foreground hover:text-foreground",
)}
>
+ {prefs.followUpBehavior === behavior && (
+ <SegmentedPill group={`${pillId}-follow-up`} />
+ )}
{t(
behavior === "queue"
? "composerSettings.queue"
diff --git a/studio/frontend/src/features/settings/components/create-key-form.tsx b/studio/frontend/src/features/settings/components/create-key-form.tsx
index 09af929f002..08205392ede 100644
--- a/studio/frontend/src/features/settings/components/create-key-form.tsx
+++ b/studio/frontend/src/features/settings/components/create-key-form.tsx
@@ -1,11 +1,12 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { SegmentedPill } from "@/components/segmented-control";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { useT } from "@/i18n";
import { cn } from "@/lib/utils";
-import { useState } from "react";
+import { useId, useState } from "react";
import { createApiKey } from "../api/api-keys";
const EXPIRY_PRESETS = [
@@ -23,6 +24,7 @@ export function CreateKeyForm({
onError: (message: string) => void;
}) {
const t = useT();
+ const pillId = useId();
const [name, setName] = useState("");
const [expiry, setExpiry] = useState<number | null>(null);
const [loading, setLoading] = useState(false);
@@ -64,12 +66,13 @@ export function CreateKeyForm({
onClick={() => setExpiry(p.value)}
aria-pressed={active}
className={cn(
- "inline-flex h-8 items-center rounded-full px-3.5 text-ui-12 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
+ "relative inline-flex h-8 items-center rounded-full px-3.5 text-ui-12 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
active
- ? "hub-tab-toggle-pill text-foreground"
+ ? "text-foreground"
: "text-muted-foreground hover:text-foreground",
)}
>
+ {active && <SegmentedPill group={`${pillId}-expiry`} />}
{p.value === null ? t("settings.apiKeys.never") : p.label}
</button>
);
diff --git a/studio/frontend/src/features/settings/components/download-transport-row.tsx b/studio/frontend/src/features/settings/components/download-transport-row.tsx
index 7480d2df309..04d35f8e523 100644
--- a/studio/frontend/src/features/settings/components/download-transport-row.tsx
+++ b/studio/frontend/src/features/settings/components/download-transport-row.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { SegmentedPill } from "@/components/segmented-control";
import {
Tooltip,
TooltipContent,
@@ -13,7 +14,7 @@ import {
} from "@/features/hub";
import { type TranslationKey, useT } from "@/i18n";
import { cn } from "@/lib/utils";
-import { useEffect, useState } from "react";
+import { useEffect, useId, useState } from "react";
import {
type DownloadTransportSettings,
loadDownloadTransportSettings,
@@ -45,6 +46,7 @@ const OPTIONS: {
export function DownloadTransportRow() {
const t = useT();
+ const pillId = useId();
const [mode, setMode] = useTransportMode();
// huggingface_hub 1.18 refetches an interrupted transfer from zero, so promising HTTPS
// "resumes where it stopped" there is backwards.
@@ -155,10 +157,13 @@ export function DownloadTransportRow() {
disabled
? "cursor-not-allowed text-muted-foreground/45"
: active
- ? "hub-tab-toggle-pill text-foreground"
+ ? "text-foreground"
: "text-muted-foreground hover:text-foreground",
)}
>
+ {active && !disabled && (
+ <SegmentedPill group={`${pillId}-transport`} />
+ )}
<span className="relative z-10">{t(opt.labelKey)}</span>
</button>
</TooltipTrigger>
diff --git a/studio/frontend/src/features/settings/components/hub-settings-section.tsx b/studio/frontend/src/features/settings/components/hub-settings-section.tsx
index 7926eef708f..e7c2b79bdaa 100644
--- a/studio/frontend/src/features/settings/components/hub-settings-section.tsx
+++ b/studio/frontend/src/features/settings/components/hub-settings-section.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { SegmentedPill } from "@/components/segmented-control";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Switch } from "@/components/ui/switch";
@@ -8,7 +9,7 @@ import { useIsAccountOwner } from "@/features/auth";
import { useT } from "@/i18n";
import { DEFAULT_HF_ENDPOINT, type HubSource } from "@/lib/hf-endpoint";
import { cn } from "@/lib/utils";
-import { useEffect, useRef, useState } from "react";
+import { useEffect, useId, useRef, useState } from "react";
import {
type HubEndpointSettings,
type HubSettings,
@@ -28,6 +29,7 @@ const SOURCES: { value: HubSource; label: string }[] = [
export function HubSettingsSection() {
const t = useT();
+ const pillId = useId();
const isOwner = useIsAccountOwner();
const [settings, setSettings] = useState<HubSettings | null>(null);
const [draftEndpoint, setDraftEndpoint] = useState("");
@@ -158,10 +160,11 @@ export function HubSettingsSection() {
className={cn(
"relative flex h-8 items-center rounded-full px-3 text-xs font-medium transition-colors disabled:cursor-not-allowed",
active
- ? "hub-tab-toggle-pill text-foreground"
+ ? "text-foreground"
: "text-muted-foreground hover:text-foreground",
)}
>
+ {active && <SegmentedPill group={`${pillId}-source`} />}
<span className="relative z-10">{option.label}</span>
</button>
);
diff --git a/studio/frontend/src/features/settings/components/mcp-access-section.tsx b/studio/frontend/src/features/settings/components/mcp-access-section.tsx
index 57e22aaa1f4..18ee34b6147 100644
--- a/studio/frontend/src/features/settings/components/mcp-access-section.tsx
+++ b/studio/frontend/src/features/settings/components/mcp-access-section.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { SegmentedPill } from "@/components/segmented-control";
import {
Select,
SelectContent,
@@ -17,6 +18,7 @@ import { HugeiconsIcon } from "@hugeicons/react";
import {
type ReactElement,
useEffect,
+ useId,
useState,
useSyncExternalStore,
} from "react";
@@ -61,6 +63,7 @@ export function McpAccessSection({
apiKey?: string | null;
}): ReactElement | null {
const t = useT();
+ const pillId = useId();
const [settings, setSettings] = useState<McpAccessSettings | null>(null);
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
@@ -225,12 +228,15 @@ export function McpAccessSection({
onClick={() => setStoredOs(option.os)}
aria-pressed={os === option.os}
className={cn(
- "inline-flex h-8 items-center rounded-full px-3.5 text-ui-12 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
+ "relative inline-flex h-8 items-center rounded-full px-3.5 text-ui-12 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
os === option.os
- ? "hub-tab-toggle-pill text-foreground"
+ ? "text-foreground"
: "text-muted-foreground hover:text-foreground",
)}
>
+ {os === option.os && (
+ <SegmentedPill group={`${pillId}-shell`} />
+ )}
{t(option.labelKey)}
</button>
))}
diff --git a/studio/frontend/src/features/settings/components/update-studio-instructions.tsx b/studio/frontend/src/features/settings/components/update-studio-instructions.tsx
index cf8d683c3ab..7ac024d5dae 100644
--- a/studio/frontend/src/features/settings/components/update-studio-instructions.tsx
+++ b/studio/frontend/src/features/settings/components/update-studio-instructions.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { SegmentedPill } from "@/components/segmented-control";
import { copyToClipboard } from "@/lib/copy-to-clipboard";
import { useT } from "@/i18n";
import { Tick02Icon } from "@/lib/tick-icon";
@@ -12,7 +13,7 @@ import {
import { HugeiconsIcon } from "@hugeicons/react";
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
import type { ReactElement } from "react";
-import { useEffect, useRef, useState } from "react";
+import { useEffect, useId, useRef, useState } from "react";
const STUDIO_INSTALL_UNIX_CMD =
"curl -fsSL https://unsloth.ai/install.sh | sh";
@@ -175,10 +176,12 @@ function UpdateDocsLinks(): ReactElement {
function ShellToggleButton({
active,
label,
+ pillGroup,
onClick,
}: {
active: boolean;
label: string;
+ pillGroup: string;
onClick: () => void;
}): ReactElement {
return (
@@ -187,12 +190,13 @@ function ShellToggleButton({
onClick={onClick}
aria-pressed={active}
className={cn(
- "inline-flex h-8 items-center justify-center rounded-full px-3.5 text-ui-12 font-medium transition-colors",
+ "relative inline-flex h-8 items-center justify-center rounded-full px-3.5 text-ui-12 font-medium transition-colors",
active
- ? "hub-tab-toggle-pill text-foreground"
+ ? "text-foreground"
: "cursor-pointer text-muted-foreground hover:text-foreground",
)}
>
+ {active && <SegmentedPill group={pillGroup} />}
{label}
</button>
);
@@ -211,6 +215,7 @@ export function UpdateStudioInstructions({
showTitle?: boolean;
}): ReactElement {
const t = useT();
+ const pillId = useId();
const [shellOverride, setShellOverride] = useState<UpdateShell | null>(null);
const shell = shellOverride ?? defaultShell;
const prefersReducedMotion = useReducedMotion();
@@ -268,11 +273,13 @@ export function UpdateStudioInstructions({
<ShellToggleButton
active={!windows}
label="MacOS / Linux"
+ pillGroup={`${pillId}-shell`}
onClick={() => setShellOverride("unix")}
/>
<ShellToggleButton
active={windows}
label="Windows"
+ pillGroup={`${pillId}-shell`}
onClick={() => setShellOverride("windows")}
/>
</div>
diff --git a/studio/frontend/src/features/settings/components/usage-examples.tsx b/studio/frontend/src/features/settings/components/usage-examples.tsx
index 9bd78a0a8d1..68b30e84f6f 100644
--- a/studio/frontend/src/features/settings/components/usage-examples.tsx
+++ b/studio/frontend/src/features/settings/components/usage-examples.tsx
@@ -6,6 +6,7 @@ import {
unslothDarkTheme,
unslothLightTheme,
} from "@/components/assistant-ui/code-themes";
+import { SegmentedPill } from "@/components/segmented-control";
import { Switch } from "@/components/ui/switch";
import {
Tooltip,
@@ -35,6 +36,7 @@ import { HugeiconsIcon } from "@hugeicons/react";
import {
useCallback,
useEffect,
+ useId,
useMemo,
useRef,
useState,
@@ -589,6 +591,7 @@ export function UsageExamples({
keylessExposure?: KeylessApiAccessExposure | null;
}) {
const t = useT();
+ const pillId = useId();
const deviceType = usePlatformStore((s) => s.deviceType);
const cloudflareUrl = usePlatformStore((s) => s.cloudflareUrl);
const serverUrl = usePlatformStore((s) => s.serverUrl);
@@ -944,7 +947,7 @@ export function UsageExamples({
</div>
) : null}
<div className="flex min-w-0 items-center justify-between gap-2 border-b border-border px-2 py-1.5">
- <div className="flex min-w-0 flex-wrap items-center gap-0.5">
+ <div className="isolate flex min-w-0 flex-wrap items-center gap-0.5">
{TYPE_TABS.map((tab) => {
const active = lang === tab.id;
const labelKey = TYPE_LABEL_KEY[tab.id];
@@ -958,12 +961,13 @@ export function UsageExamples({
}}
aria-pressed={active}
className={cn(
- "rounded-full px-2.5 py-1 text-ui-11 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
+ "relative rounded-full px-2.5 py-1 text-ui-11 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
active
- ? "hub-tab-toggle-pill text-foreground"
+ ? "text-foreground"
: "text-muted-foreground hover:text-foreground",
)}
>
+ {active && <SegmentedPill group={`${pillId}-lang`} />}
{labelKey ? t(labelKey) : tab.label}
</button>
);
@@ -971,7 +975,7 @@ export function UsageExamples({
</div>
</div>
{osAware ? (
- <div className="flex min-w-0 items-center gap-0.5 border-b border-border px-2 py-1.5">
+ <div className="isolate flex min-w-0 items-center gap-0.5 border-b border-border px-2 py-1.5">
<button
type="button"
onClick={() => {
@@ -980,12 +984,15 @@ export function UsageExamples({
}}
aria-pressed={os === "unix"}
className={cn(
- "rounded-full px-2.5 py-1 text-ui-11 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
+ "relative rounded-full px-2.5 py-1 text-ui-11 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
os === "unix"
- ? "hub-tab-toggle-pill text-foreground"
+ ? "text-foreground"
: "text-muted-foreground hover:text-foreground",
)}
>
+ {os === "unix" && (
+ <SegmentedPill group={`${pillId}-os`} />
+ )}
{t("settings.apiKeys.osUnix")}
</button>
<button
@@ -996,12 +1003,15 @@ export function UsageExamples({
}}
aria-pressed={os === "windows"}
className={cn(
- "rounded-full px-2.5 py-1 text-ui-11 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
+ "relative rounded-full px-2.5 py-1 text-ui-11 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
os === "windows"
- ? "hub-tab-toggle-pill text-foreground"
+ ? "text-foreground"
: "text-muted-foreground hover:text-foreground",
)}
>
+ {os === "windows" && (
+ <SegmentedPill group={`${pillId}-os`} />
+ )}
{t("settings.apiKeys.osWindows")}
</button>
</div>
@@ -1041,7 +1051,7 @@ export function UsageExamples({
<span className="text-ui-11 leading-snug text-muted-foreground">
{t("settings.apiKeys.codingAgentsHint")}
</span>
- <div className="flex min-w-0 flex-wrap items-center gap-1">
+ <div className="isolate flex min-w-0 flex-wrap items-center gap-1">
{availableAgents.map((id) => {
const installed = detectedAgents.includes(id);
const active = agent === id;
@@ -1062,12 +1072,13 @@ export function UsageExamples({
: undefined
}
className={cn(
- "flex items-center gap-1 rounded-full px-2.5 py-1 text-ui-11 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
+ "relative flex items-center gap-1 rounded-full px-2.5 py-1 text-ui-11 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
active
- ? "hub-tab-toggle-pill text-foreground"
+ ? "text-foreground"
: "text-muted-foreground hover:text-foreground",
)}
>
+ {active && <SegmentedPill group={`${pillId}-agent`} />}
{AGENT_LABELS[id] ?? id}
{installed ? (
<span
diff --git a/studio/frontend/src/features/settings/tabs/agents-tab.tsx b/studio/frontend/src/features/settings/tabs/agents-tab.tsx
index 849187c76c8..258c50f093c 100644
--- a/studio/frontend/src/features/settings/tabs/agents-tab.tsx
+++ b/studio/frontend/src/features/settings/tabs/agents-tab.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { SegmentedPill } from "@/components/segmented-control";
import { getClientPlatform } from "@/components/tauri/window-titlebar";
import {
Command,
@@ -50,7 +51,14 @@ import { Tick02Icon } from "@/lib/tick-icon";
import { cn } from "@/lib/utils";
import { ArrowUpRight01Icon, Copy01Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
-import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import {
+ useCallback,
+ useEffect,
+ useId,
+ useMemo,
+ useRef,
+ useState,
+} from "react";
import { loadCodingAgents } from "../api/coding-agents";
import {
buildAgentShellCommands,
@@ -453,6 +461,7 @@ function SubagentSection({
export function AgentsTab() {
const t = useT();
+ const pillId = useId();
const serverUrl = usePlatformStore((s) => s.serverUrl);
const hfToken = useHfTokenStore((s) => s.token);
const hfAccessToken = hfApiToken(hfToken);
@@ -1151,12 +1160,15 @@ export function AgentsTab() {
}}
aria-pressed={commandOs === "unix"}
className={cn(
- "inline-flex h-8 items-center rounded-full px-3.5 text-ui-12 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
+ "relative inline-flex h-8 items-center rounded-full px-3.5 text-ui-12 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
commandOs === "unix"
- ? "hub-tab-toggle-pill text-foreground"
+ ? "text-foreground"
: "text-muted-foreground hover:text-foreground",
)}
>
+ {commandOs === "unix" && (
+ <SegmentedPill group={`${pillId}-shell`} />
+ )}
{t("settings.apiKeys.osUnix")}
</button>
<button
@@ -1168,12 +1180,15 @@ export function AgentsTab() {
}}
aria-pressed={commandOs === "windows"}
className={cn(
- "inline-flex h-8 items-center rounded-full px-3.5 text-ui-12 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
+ "relative inline-flex h-8 items-center rounded-full px-3.5 text-ui-12 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
commandOs === "windows"
- ? "hub-tab-toggle-pill text-foreground"
+ ? "text-foreground"
: "text-muted-foreground hover:text-foreground",
)}
>
+ {commandOs === "windows" && (
+ <SegmentedPill group={`${pillId}-shell`} />
+ )}
{t("settings.apiKeys.osWindows")}
</button>
</div>
diff --git a/studio/frontend/src/features/settings/tabs/chat-tab.tsx b/studio/frontend/src/features/settings/tabs/chat-tab.tsx
index 4187b5c8130..73f71fc6a48 100644
--- a/studio/frontend/src/features/settings/tabs/chat-tab.tsx
+++ b/studio/frontend/src/features/settings/tabs/chat-tab.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { SegmentedPill } from "@/components/segmented-control";
import { Button } from "@/components/ui/button";
import {
Select,
@@ -44,7 +45,7 @@ import { HugeiconsIcon } from "@hugeicons/react";
import { CursorInWindowIcon } from "@/lib/browser-use-icon";
import { useNavigate } from "@tanstack/react-router";
import { Columns2Icon } from "lucide-react";
-import { useEffect, useState } from "react";
+import { useEffect, useId, useState } from "react";
import type { ReactNode } from "react";
import {
type CurrentDatePromptSettings,
@@ -281,6 +282,7 @@ function ToolResultLimitRow() {
export function ChatTab() {
const isOwner = useIsAccountOwner();
const t = useT();
+ const pillId = useId();
const navigate = useNavigate();
const resetPlusMenu = usePlusMenuPrefsStore((state) => state.resetMenu);
const autoTitle = useChatRuntimeStore((state) => state.autoTitle);
@@ -546,12 +548,15 @@ export function ChatTab() {
aria-pressed={autoScrollWhileGenerating === follow}
onClick={() => setAutoScrollWhileGenerating(follow)}
className={cn(
- "inline-flex h-8 cursor-pointer items-center rounded-full px-3.5 text-ui-12 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
+ "relative inline-flex h-8 cursor-pointer items-center rounded-full px-3.5 text-ui-12 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
autoScrollWhileGenerating === follow
- ? "hub-tab-toggle-pill text-foreground"
+ ? "text-foreground"
: "text-muted-foreground hover:text-foreground",
)}
>
+ {autoScrollWhileGenerating === follow && (
+ <SegmentedPill group={`${pillId}-auto-scroll`} />
+ )}
{t(
follow
? "settings.chat.autoScrollAuto"
diff --git a/studio/frontend/src/features/settings/tabs/debugging-tab.tsx b/studio/frontend/src/features/settings/tabs/debugging-tab.tsx
index 7b3cad07389..76cfe037c3e 100644
--- a/studio/frontend/src/features/settings/tabs/debugging-tab.tsx
+++ b/studio/frontend/src/features/settings/tabs/debugging-tab.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { SegmentedPill } from "@/components/segmented-control";
import { Button } from "@/components/ui/button";
import {
InputGroup,
@@ -42,7 +43,14 @@ import {
Tick02Icon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
-import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import {
+ useCallback,
+ useEffect,
+ useId,
+ useMemo,
+ useRef,
+ useState,
+} from "react";
import {
type DebugLogSource,
LogExportError,
@@ -141,6 +149,7 @@ function NoticeStrip({
export function DebuggingTab() {
const t = useT();
+ const pillId = useId();
const [sources, setSources] = useState<DebugLogSource[]>([]);
const [sourceId, setSourceId] = useState<string | null>(null);
const [mode, setMode] = useState<RefreshMode>(readStoredMode);
@@ -576,10 +585,11 @@ export function DebuggingTab() {
className={cn(
"relative flex h-8 items-center rounded-full px-3 text-xs font-medium transition-colors",
active
- ? "hub-tab-toggle-pill text-foreground"
+ ? "text-foreground"
: "text-muted-foreground hover:text-foreground",
)}
>
+ {active && <SegmentedPill group={`${pillId}-mode`} />}
<span className="relative z-10">
{modeLabel(candidate)}
</span>
diff --git a/studio/frontend/src/features/settings/tabs/sandbox-tab.tsx b/studio/frontend/src/features/settings/tabs/sandbox-tab.tsx
index 92e266546f8..6e7fc792614 100644
--- a/studio/frontend/src/features/settings/tabs/sandbox-tab.tsx
+++ b/studio/frontend/src/features/settings/tabs/sandbox-tab.tsx
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import { SegmentedPill } from "@/components/segmented-control";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
@@ -237,6 +238,7 @@ function PermissionsSection() {
);
const [setupOpen, setSetupOpen] = useState(false);
const levelDescriptionId = useId();
+ const pillId = useId();
const scrollTarget = useSettingsDialogStore((s) => s.scrollTarget);
const consumeScrollTarget = useSettingsDialogStore((s) => s.consumeScrollTarget);
@@ -301,12 +303,13 @@ function PermissionsSection() {
void pickSandboxLevel(level, setSandboxLevel, () => setSetupOpen(true));
}}
className={cn(
- "inline-flex h-8 cursor-pointer items-center rounded-full px-3.5 text-ui-12 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
+ "relative inline-flex h-8 cursor-pointer items-center rounded-full px-3.5 text-ui-12 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
selected
- ? "hub-tab-toggle-pill cursor-default text-foreground"
+ ? "cursor-default text-foreground"
: "text-muted-foreground hover:text-foreground disabled:hover:text-muted-foreground",
)}
>
+ {selected && <SegmentedPill group={`${pillId}-level`} />}
{t(SANDBOX_LEVEL_TEXT[level].name)}
</button>
);
diff --git a/studio/frontend/tests/debug-log-export.test.ts b/studio/frontend/tests/debug-log-export.test.ts
index 1b7f5c11490..49455aa05be 100644
--- a/studio/frontend/tests/debug-log-export.test.ts
+++ b/studio/frontend/tests/debug-log-export.test.ts
@@ -176,6 +176,8 @@ function makeWorld(options: {
);
},
},
+ // The selected mode's sliding pill is decoration, not under test.
+ "@/components/segmented-control": { SegmentedPill: () => null },
// pass-through wrappers: the markup around the buttons is not under test
"@/components/ui/input-group": {
InputGroup: passthrough,
diff --git a/studio/frontend/tests/hub-tab-toggle-track.test.ts b/studio/frontend/tests/hub-tab-toggle-track.test.ts
index bffb182a659..0a15900cb9f 100644
--- a/studio/frontend/tests/hub-tab-toggle-track.test.ts
+++ b/studio/frontend/tests/hub-tab-toggle-track.test.ts
@@ -118,11 +118,18 @@ test("a highlighted row still lifts clear of the lighter menu", () => {
});
test("a white pill in light mode stays put, having nowhere lighter to go", () => {
- const rule = HUB_CSS.match(
- /html:not\(\.dark\) \.hub-tab-toggle-pill\[role="tab"\]:hover \{([^}]*)\}/,
+ // The selected pill is its own span under the tab, and it takes no pointer,
+ // so hovering the tab cannot move the pill off white.
+ const pill = readSrc("components/segmented-control.tsx").match(
+ /export function SegmentedPill[\s\S]*?className=\{cn\(\s*"([^"]*)"/,
);
- assert.ok(rule, "the light tab hover is missing");
- assert.match(rule[1] ?? "", /background-color:\s*var\(--background\)/);
+ assert.ok(pill, "SegmentedPill not found");
+ assert.match(pill[1] ?? "", /\bhub-tab-toggle-pill\b/);
+ assert.match(pill[1] ?? "", /\bpointer-events-none\b/);
+ const tabs = readSrc(
+ "features/model-picker/components/model-selector/pill-tabs.tsx",
+ );
+ assert.doesNotMatch(tabs, /&& "hub-tab-toggle-pill"/);
});
test("a button borrowing the pill look gets the hover the pill pins away", () => {
diff --git a/tests/studio/test_model_picker_contracts.py b/tests/studio/test_model_picker_contracts.py
index 30bd31e5f2f..30484ce5761 100644
--- a/tests/studio/test_model_picker_contracts.py
+++ b/tests/studio/test_model_picker_contracts.py
@@ -731,7 +731,7 @@ def test_model_picker_toolbar_reflows_before_crossing_picker_edge():
tabs = _read("features/model-picker/components/model-selector/pill-tabs.tsx")
assert 'fit ? "min-w-0 shrink" : "min-w-0 flex-1"' in tabs
- assert '<span className="min-w-0 truncate">{tab.label}</span>' in tabs
+ assert '<span data-pill-tab-label className="min-w-0 truncate">' in tabs
selector = _read("features/model-picker/components/model-selector.tsx")
assert 'icon={StarIcon} className="size-3.5 shrink-0"' in selector