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.

1.8 KB
Raw Blame
// 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 { cn } from "@/lib/utils";
import { type ReactNode, useId } from "react";
import { SegmentedPill } from "./segmented-control";
import {
  type SegmentedSize,
  segmentedSegmentLabel,
  segmentedTrackHeight,
} from "./segmented-control-styles";
import { TabsList, TabsTrigger } from "./ui/tabs";

export interface SegmentedTabOption<T extends string> {
  value: T;
  label: ReactNode;
  disabled?: boolean;
}

export function SegmentedTabsList<T extends string>({
  value,
  options,
  ariaLabel,
  size = "default",
  className,
}: {
  value: T;
  options: readonly [
    SegmentedTabOption<T>,
    SegmentedTabOption<T>,
    ...SegmentedTabOption<T>[],
  ];
  ariaLabel: string;
  size?: SegmentedSize;
  className?: string;
}) {
  const pillId = useId();
  return (
    <TabsList
      unstyled={true}
      aria-label={ariaLabel}
      className={cn(
        "hub-menu-trigger hub-tab-toggle relative inline-flex w-full shrink-0 items-center rounded-full",
        segmentedTrackHeight[size],
        className,
      )}
    >
      {options.map((option) => {
        const active = option.value === value;
        return (
          <TabsTrigger
            key={option.value}
            value={option.value}
            disabled={option.disabled}
            indicator={<SegmentedPill group={`${pillId}-pill`} />}
            className={cn(
              "relative h-full min-w-0 flex-1 cursor-pointer rounded-full border-0 py-0",
              segmentedSegmentLabel,
              active
                ? "text-foreground"
                : "text-muted-foreground hover:text-foreground",
            )}
          >
            {option.label}
          </TabsTrigger>
        );
      })}
    </TabsList>
  );
}