BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/loomui/elastic-tabs

Elastic Tabs

loomui/elastic-tabs
FreeComponent

A tab group whose pill stretches to cover both tabs before it contracts onto the one you picked.

Live preview

live · rendered by the registry
Rendered by loomui on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://loomui.design/r/elastic-tabs.json

Source

registry/loomui/elastic-tabs.tsxloomui.design/r/elastic-tabs.json
1"use client"
2
3import * as React from "react"
4
5import { cn } from "@/lib/utils"
6
7export interface ElasticTabsItem {
8 value: string
9 label: React.ReactNode
10}
11
12export interface ElasticTabsProps extends Omit<
13 React.ComponentProps<"div">,
14 "onChange"
15> {
16 /** The tabs, in order. */
17 items: ElasticTabsItem[]
18 /** Selected tab. Leave it out to let the group own the selection. */
19 value?: string
20 /** Starting tab when the group owns the selection. */
21 defaultValue?: string
22 /** Called with the value of the tab moved to. */
23 onValueChange?: (value: string) => void
24 /** Length of the whole travel, in milliseconds. */
25 duration?: number
26}
27
28const EMPTY = { left: 0, width: 0 }
29
30export function ElasticTabs({
31 items,
32 value,
33 defaultValue,
34 onValueChange,
35 duration = 280,
36 className,
37 ...props
38}: ElasticTabsProps) {
39 const [own, setOwn] = React.useState(defaultValue ?? items[0]?.value)
40 const isControlled = value !== undefined
41 const active = isControlled ? value : own
42 const index = Math.max(
43 items.findIndex((item) => item.value === active),
44 0
45 )
46
47 const listRef = React.useRef<HTMLDivElement>(null)
48 const tabsRef = React.useRef<(HTMLButtonElement | null)[]>([])
49 const [pill, setPill] = React.useState(EMPTY)
50 // The first placement is a measurement, not a move, so it must not travel.
51 const [settled, setSettled] = React.useState(false)
52
53 const measure = React.useCallback((position: number) => {
54 const tab = tabsRef.current[position]
55 return tab ? { left: tab.offsetLeft, width: tab.offsetWidth } : EMPTY
56 }, [])
57
58 const indexRef = React.useRef(index)
59 indexRef.current = index
60 const pillRef = React.useRef(EMPTY)
61 React.useEffect(() => {
62 pillRef.current = pill
63 }, [pill])
64
65 // Placement. Runs once on mount and again whenever the row is resized, so a
66 // wrapped or re-laid-out group never leaves the pill behind.
67 React.useEffect(() => {
68 const list = listRef.current
69 if (!list) {
70 return
71 }
72
73 const observer = new ResizeObserver(() =>
74 setPill(measure(indexRef.current))
75 )
76 observer.observe(list)
77
78 const timer = window.setTimeout(() => setSettled(true), 0)
79 return () => {
80 observer.disconnect()
81 window.clearTimeout(timer)
82 }
83 }, [measure])
84
85 // Travel. The pill first stretches to cover both tabs, then contracts onto
86 // the new one. Moving `left` and `width` straight to the target slides a
87 // fixed shape across. Spanning first is what makes it read as elastic.
88// … truncated

What it pulls in

Other registry items

  • utils

Files it writes

  • registry/loomui/elastic-tabs.tsx

Facts

Registry
loomui
Type
registry:ui
Access
Free
Files written
1
Theme wiring
ships cssVars
Licence
MIT
In the index
at or before 2026-08-20
Last confirmed
yesterday

Go to the source

Docs on loomui loomui.design rjcuff/Loom-UI on GitHub Raw registry item This item as JSON

More from loomui

All 91 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Aurora Backdropaurora-backdroploomuiComponentsFreeno deps
Bento Gridbento-gridloomuiComponentsFreeno deps
Card Stackcard-stackloomuiComponentsFreeno deps
Compare Slidercompare-sliderloomuiComponentsFreeno deps
Confetti Buttonconfetti-buttonloomuiComponentsFreeno deps
Count Upcount-uploomuiComponentsFreeno deps
Credit Cardcredit-cardloomuiComponentsFreeno deps
DrawerdrawerloomuiComponentsFree1 dep

Also from Kynth Studios

Built for the same person as BlockDex

SkillWorks

Claude Code skills and plugins, scored

skillworks.kynth.studio

RuleStack

AGENTS.md gallery and agent-config comparison

rulestack.kynth.studio

KitGrade

SaaS starter kits, scored on what can be checked

kitgrade.kynth.studio

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and KitGrade

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and KitGrade

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and KitGrade

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex