Morph Tabs
Tabs whose indicator flows between options like a drop of liquid.
- Category
- Creative
- Access
- Free with an account
- Source
- 177 lines · one file
- States
- 5 drawn
The decision inside it
Two edges, two springs
Each edge of the indicator gets its own spring per move, the one in the direction of travel quicker, which is what makes it stretch, for tabs of any width. It is a real tablist: arrows, Home and End, labelled panels. Reduced motion swaps without travel.
When to use it
Use Morph Tabs for a few views of the same thing where the switch should feel connected: the pill stretches between tabs and the content slides the same way.
Installation
How you get it
Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.
Use Liro's Morph Tabs for this.
Install it: npx shadcn@latest add @liro/morph-tabs
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/morph-tabs.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Free components install through the @liro registry with your CLI token: see the Namespaced tab.
Usage
import { MorphTabs } from "@/components/ui/morph-tabs";
export function OverviewTabs() {
return (
<MorphTabs
tabs={[
{ id: "overview", label: "Overview", content: <p>Three launches this week.</p> },
{ id: "revenue", label: "Revenue", content: <p>$84,200 invoiced in October.</p> },
]}
/>
);
}API reference
“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.
Props
Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.
| Type | Notes | ||
|---|---|---|---|
tabs | MorphTab[] | Yes | – |
value | string | No | – |
defaultValue | string | No | – |
onValueChange | (id: string) => void | No | – |
Dependencies
npm packages
clsxframer-motiontailwind-mergeLiro foundations, installed alongside it
liro-themeStates
All of them are drawn by the component. None is left for you to design.
- Selected
- Moving right
- Moving left
- Keyboard
- Reduced motion
Accessibility
- Keyboard reachable throughout, in visual order
- Focus trapped in overlays, Escape closes them
- Focus returns to whatever opened it
- Live regions announce what changed, not that something did
- Honours prefers-reduced-motion
Responsive behavior
- Sizes to its container, not the viewport
- Usable from 320px up
- Pointer-based interaction, so trackpad and touch both work
- No hover-only affordances