Skip to content
StackD
Elastic tabs, the StackD component

Navigation · €7

Elastic tabs

Tabs whose highlight stretches like elastic between options.

Pay once on Gumroad: the download, plus a licence key for the registry and the MCP server.

Details

Category
Navigation
Plan
Paid, €7 once
Code
React + Tailwind, TypeScript · 301 lines
Files
ElasticTabs.tsx
Needs
React and Tailwind only
Agents
MCP server and shadcn registry

About

Tabs with an indicator that moves like a drop. The front edge leaves first and the back edge catches up, so it stretches (and gets a little thinner) on the way, then lands with a small wobble. Grab it and drag: it follows your finger, stretches with your speed, gives like rubber past the ends and drops on the nearest tab. The labels under it change colour right at its edge. Mouse, touch and keyboard, and it works with screen readers. White and black versions, any colour. React + Tailwind, no other libraries. Respects reduced motion.

Install

Once: add the StackD registry to components.json, with the licence key from your receipt in STACKD_LICENSE_KEY (in .env.local):

"registries": {
  "@stackd": {
    "url": "https://www.stackd.codes/r/{name}.json",
    "headers": { "X-License-Key": "${STACKD_LICENSE_KEY}" }
  }
}

With the shadcn CLI:

npx shadcn@latest add @stackd/elastic-tabs

Or let your agent add it through the StackD MCP server:

claude mcp add --transport http stackd https://www.stackd.codes/mcp

Prompt for your agent

Paste it into Claude Code, Cursor, Codex or VS Code once the MCP server is connected.

Add the StackD Elastic tabs component to this project. Use the StackD MCP server: call get_component with { "name": "elastic-tabs" }, write the files at the paths it gives and install any npm packages it lists. Then use it where it fits, following its README for the props, and keep its own styles. It is a paid component: if the server says it needs a licence, tell me where to buy it.

Use

  1. Copy ElasticTabs.tsx into your project (for example components/ElasticTabs.tsx).
  2. Use it:
import { ElasticTabs } from './components/ElasticTabs'

const range = [
  { id: 'day', label: 'Day' },
  { id: 'week', label: 'Week' },
  { id: 'month', label: 'Month' },
  { id: 'year', label: 'Year' },
]

<ElasticTabs tabs={range} onChange={(id) => setRange(id)} />

With icons, on a black bar, in Lilac:

const nav = [
  { id: 'home', label: 'Home', icon: <HomeIcon /> },
  { id: 'search', label: 'Search', icon: <SearchIcon /> },
  { id: 'inbox', label: 'Inbox', icon: <InboxIcon /> },
]

<ElasticTabs tabs={nav} theme="dark" color="#C9B8FF" />
<ElasticTabs tabs={nav} iconOnly />   // icons only, labels kept for screen readers

Any SVG icon works; it is sized to 18 px and takes the text colour (currentColor).

To keep the selected tab in your own state:

const [tab, setTab] = useState('week')

<ElasticTabs tabs={range} value={tab} onChange={setTab} />

In Next.js the file already starts with 'use client'. In other React setups that line does nothing.

Options

PropDefaultWhat it does
tabs{ id, label, icon? }[]
valueControlled selected id. Leave it out and the tabs keep their own
defaultValuefirst tabStarting tab when not controlled
onChangeCalled with the id of the new tab
theme'light''light' (white bar) or 'dark' (black bar)
colorink on light, white on darkThe indicator's colour. The text on it turns ink or white, whichever reads better
fillfalseStretch the bar to the width of its parent, tabs sharing the space
iconOnlyfalseShow only the icons
aria-label'Tabs'Name of the tab list for screen readers

Tuning the stretch

At the top of the file: FRONT and BACK are the springs of the two edges. A bigger gap between their k values means a longer stretch; a lower z on FRONT means more wobble.

Keyboard

Left / Right: previous / next tab. Home / End: first / last.

Colours from StackD

White #FFFFFF · Ink #141310 · Wine #901919 · Olive #6C8544 · Ochre #BE9344 · Lilac #C9B8FF

Licence

You can use it in personal and commercial projects. Don't resell or share the component on its own.

Made by StackD · stackd.codes