Buttons & actions / Segmented buttons

Glass Segmented Category Tabs

Pill-shaped track with hairline border holding text tabs; the active tab is a raised glossy pill with white text and gradient highlight, inactive tabs are grey.

Rebuilt from raycast.com in the Obsidian Launcher style.

npx shadcn@latest add https://justyoink.it/r/obsidian-launcher/blocks/glass-segmented-tabs.json

Looks exactly like raycast.com: brings its fonts and colours, namespaced so your own theme stays untouched.

Usage

Props: tabs (string[]), defaultIndex, onChange(value, index), className. Click or use arrow keys; the glossy pill slides to the active tab.

components/glass-segmented-tabs.tsx
import { useRef, useState, useLayoutEffect } from "react";

type Props = {
  tabs?: string[];
  defaultIndex?: number;
  onChange?: (value: string, index: number) => void;
  className?: string;
};

export default function GlassSegmentedCategoryTabs({
  tabs = ["Productivity", "Engineering", "Design", "Writing"],
  defaultIndex = 0,
  onChange,
  className = "",
}: Props) {
  const [active, setActive] = useState(defaultIndex);
  const refs = useRef<(HTMLButtonElement | null)[]>([]);
  const [pill, setPill] = useState({ left: 0, width: 0 });

  useLayoutEffect(() => {
    const measure = () => {
      const el = refs.current[active];
      if (el) setPill({ left: el.offsetLeft, width: el.offsetWidth });
    };
    measure();
    window.addEventListener("resize", measure);
    return () => window.removeEventListener("resize", measure);
  }, [active, tabs]);

  const move = (i: number) => {
    const n = (i + tabs.length) % tabs.length;
    setActive(n);
    refs.current[n]?.focus();
    onChange?.(tabs[n], n);
  };

  return (
    <div className={`bg-canvas p-6 ${className}`}>
      <div
        role="tablist"
        aria-label="Categories"
        className="relative inline-flex items-center rounded-pill border border-hairline bg-overlay-subtle p-2 backdrop-blur-[2px]"
      >
        <span
          aria-hidden
          className="pointer-events-none absolute top-2 bottom-2 overflow-hidden rounded-pill bg-surface-elevated shadow-keycap transition-[left,width] duration-300 ease-[cubic-bezier(0.19,1,0.22,1)]"
          style={{ left: pill.left, width: pill.width }}
        >
          <span className="absolute inset-0 bg-[linear-gradient(rgba(255,255,255,0.18),rgba(255,255,255,0))]" />
        </span>
        {tabs.map((t, i) => (
          <button
            key={t}
            ref={(el) => {
              refs.current[i] = el;
            }}
            role="tab"
            aria-selected={i === active}
            tabIndex={i === active ? 0 : -1}
            onClick={() => move(i)}
            onKeyDown={(e) => {
              if (e.key === "ArrowRight") move(active + 1);
              if (e.key === "ArrowLeft") move(active - 1);
            }}
            className={`relative z-10 whitespace-nowrap rounded-pill px-3 py-3 text-ui font-medium transition-colors duration-300 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-red/60 ${
              i === active ? "text-primary" : "text-tertiary hover:text-primary"
            }`}
          >
            {t}
          </button>
        ))}
      </div>
    </div>
  );
}

Quality checks

Automated, in a real browser · 4d ago
—

More from Obsidian Launcher

The whole style →

AI Agent Bento Showcase

Feature sections

Blog Category Filter Row

Tab bars

Frosted Pill Navbar

Headers & nav bars

Centered Glow Hero

Heroes

Light Pill Download Button

Buttons

Launcher Window Showcase

Media & mockups