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.
npx shadcn@latest add https://justyoink.it/r/obsidian-launcher/mine/glass-segmented-tabs.json
Restyled to your project: uses your shadcn colours, fonts and radius, so it matches the rest of your app. Layout, type sizes and motion stay as designed.
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> ); }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-background p-6 ${className}`}> <div role="tablist" aria-label="Categories" className="relative inline-flex items-center rounded-full border border-border bg-primary p-2 backdrop-blur-[2px]" > <span aria-hidden className="pointer-events-none absolute top-2 bottom-2 overflow-hidden rounded-full bg-popover shadow-obsidian-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-full px-3 py-3 text-obsidian-ui font-medium transition-colors duration-300 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/60 ${ i === active ? "text-foreground" : "text-muted-foreground hover:text-foreground" }`} > {t} </button> ))} </div> </div> ); }
Quality checks
Automated, in a real browser · 4d ago- Accessible: not passedError at desktop: Minified React error #185; visit https://reactjs.org/docs/error-decoder.html?invariant=185 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
- Responsive: not passedError at 390px: Minified React error #185; visit https://reactjs.org/docs/error-decoder.html?invariant=185 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.Error at 768px: Minified React error #185; visit https://reactjs.org/docs/error-decoder.html?invariant=185 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
- Dark mode: not passedError at dark mode: Minified React error #185; visit https://reactjs.org/docs/error-decoder.html?invariant=185 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
- Themeable: passedUses design tokens rather than hard-coded colours, so it follows your theme cleanly.
- Animates cleanly: doesn't applyDoesn't animate, so there's nothing to check.