Stretch Index

Hover Accordion List for React

A list of rows that open in place. The row you're on grows taller, its tab widens into a photo, the title slides over to make room and the details rise out from under it, while the rows below glide down.

  • List
  • Hover
  • Layout

Uses motion, clsx, tailwind-merge

Inspired by State of AI in Design

Open in ChatGPTOpen in Claude
openOn
collapseOnLeavefalse
dimtrue
duration0.50s
hoverDelay0.09s
<StretchIndex />

The demo follows as you drag.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Stretch Index: A list of rows that open in place. The row you're on grows taller, its tab widens into a photo, the title slides over to make room and the details rise out from under it, while the rows below glide down.
This demo, Customer Stories: A product site's customer stories. Move down the list: a row opens once the pointer settles, so a quick sweep doesn't make the list ripple. Each company's tab warms to its own color and opens into a photo, and the whole row links to the story.

1. Install it:
   npx shadcn@latest add @keyframeui/stretch-index-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/stretch-index-demo.json instead.)
   It adds the demo, components/stretch-index-demo.tsx, and the component, components/ui/stretch-index.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <StretchIndex> on its own.

3. These props set its feel. Change them before you change the file:
   - openOn (default "hover"): `hover` opens the row under the pointer once it slows down, and the row keyboard focus reaches. `click` waits for a click, tap or Enter, and a second one closes a row without a link.
   - collapseOnLeave (default false): Close the open row when the pointer or keyboard focus leaves the list. Otherwise the last row opened stays open.
   - dim (default true): Fade the other rows back while one is open and the pointer or keyboard focus is in the list.
   - duration (default 0.5): Seconds a row takes to open while the rows below glide down. The tab widening into a photo, the title sliding over and the details rising all ride the same spring.
   - hoverDelay (default 0.09): Seconds the pointer has to rest on a row before it opens, when it arrives moving fast. A slow pointer opens it at once. Lower lets a quick sweep ripple the list; higher waits longer for intent.

4. Don't change, in components/ui/stretch-index.tsx:
   - Each row runs on one motion value, `open`, written to `--stretch-p`; the frame, the title's slide and the details all read it, so they move as one spring with no re-render per frame.
   - The title and details are laid out at the open width all along and slid back over the tab with `translate`, so nothing rewraps while a row opens.
   - Hover intent: a slow pointer opens a row at once, a fast one waits `hoverDelay`, so sweeping down the list doesn't set rows rippling.
   - Closed details are `inert`, and each row's trigger points at them with `aria-expanded` and `aria-controls`.
   - Reduced motion jumps `open` instead of springing it, so rows switch at once.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/stretch-index.md

Installation

Add the component on its own with the CLI, or copy the file in by hand.

The CLI writes components/ui/stretch-index.tsx and installs motion, clsx and tailwind-merge. It needs the @keyframeui registry in components.json; add it once per project.

npx shadcn@latest add @keyframeui/stretch-index

Examples

Finished sections built with Stretch Index. Each one installs whole, with the component included.

Open Roles

A careers page with `openOn="click"` and `numbered={false}`: rows open like an accordion, a second click closes them, and the Apply link inside stays clickable. In a narrow frame the team and place move under the title.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Stretch Index: A list of rows that open in place. The row you're on grows taller, its tab widens into a photo, the title slides over to make room and the details rise out from under it, while the rows below glide down.
This demo, Open Roles: A careers page with `openOn="click"` and `numbered={false}`: rows open like an accordion, a second click closes them, and the Apply link inside stays clickable. In a narrow frame the team and place move under the title.

1. Install it:
   npx shadcn@latest add @keyframeui/stretch-index-careers-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/stretch-index-careers-demo.json instead.)
   It adds the demo, components/stretch-index-careers-demo.tsx, and the component, components/ui/stretch-index.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <StretchIndex> on its own.

3. These props set its feel. Change them before you change the file:
   - openOn (default "hover"): `hover` opens the row under the pointer once it slows down, and the row keyboard focus reaches. `click` waits for a click, tap or Enter, and a second one closes a row without a link.
   - collapseOnLeave (default false): Close the open row when the pointer or keyboard focus leaves the list. Otherwise the last row opened stays open.
   - dim (default true): Fade the other rows back while one is open and the pointer or keyboard focus is in the list.
   - duration (default 0.5): Seconds a row takes to open while the rows below glide down. The tab widening into a photo, the title sliding over and the details rising all ride the same spring.
   - hoverDelay (default 0.09): Seconds the pointer has to rest on a row before it opens, when it arrives moving fast. A slow pointer opens it at once. Lower lets a quick sweep ripple the list; higher waits longer for intent.

4. Don't change, in components/ui/stretch-index.tsx:
   - Each row runs on one motion value, `open`, written to `--stretch-p`; the frame, the title's slide and the details all read it, so they move as one spring with no re-render per frame.
   - The title and details are laid out at the open width all along and slid back over the tab with `translate`, so nothing rewraps while a row opens.
   - Hover intent: a slow pointer opens a row at once, a fast one waits `hoverDelay`, so sweeping down the list doesn't set rows rippling.
   - Closed details are `inert`, and each row's trigger points at them with `aria-expanded` and `aria-controls`.
   - Reduced motion jumps `open` instead of springing it, so rows switch at once.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/stretch-index.md

Podcast Episodes

A podcast's latest episodes on a dark panel, with square covers through `imageAspect={1}` and episode numbers through `number`. With `collapseOnLeave`, the list folds shut when the pointer leaves it.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Stretch Index: A list of rows that open in place. The row you're on grows taller, its tab widens into a photo, the title slides over to make room and the details rise out from under it, while the rows below glide down.
This demo, Podcast Episodes: A podcast's latest episodes on a dark panel, with square covers through `imageAspect={1}` and episode numbers through `number`. With `collapseOnLeave`, the list folds shut when the pointer leaves it.

1. Install it:
   npx shadcn@latest add @keyframeui/stretch-index-episodes-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/stretch-index-episodes-demo.json instead.)
   It adds the demo, components/stretch-index-episodes-demo.tsx, and the component, components/ui/stretch-index.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <StretchIndex> on its own.

3. These props set its feel. Change them before you change the file:
   - openOn (default "hover"): `hover` opens the row under the pointer once it slows down, and the row keyboard focus reaches. `click` waits for a click, tap or Enter, and a second one closes a row without a link.
   - collapseOnLeave (default false): Close the open row when the pointer or keyboard focus leaves the list. Otherwise the last row opened stays open.
   - dim (default true): Fade the other rows back while one is open and the pointer or keyboard focus is in the list.
   - duration (default 0.5): Seconds a row takes to open while the rows below glide down. The tab widening into a photo, the title sliding over and the details rising all ride the same spring.
   - hoverDelay (default 0.09): Seconds the pointer has to rest on a row before it opens, when it arrives moving fast. A slow pointer opens it at once. Lower lets a quick sweep ripple the list; higher waits longer for intent.

4. Don't change, in components/ui/stretch-index.tsx:
   - Each row runs on one motion value, `open`, written to `--stretch-p`; the frame, the title's slide and the details all read it, so they move as one spring with no re-render per frame.
   - The title and details are laid out at the open width all along and slid back over the tab with `translate`, so nothing rewraps while a row opens.
   - Hover intent: a slow pointer opens a row at once, a fast one waits `hoverDelay`, so sweeping down the list doesn't set rows rippling.
   - Closed details are `inert`, and each row's trigger points at them with `aria-expanded` and `aria-controls`.
   - Reduced motion jumps `open` instead of springing it, so rows switch at once.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/stretch-index.md

Props

children Required

TypeReact.ReactNode

The rows, as StretchIndexItems.

defaultIndex

Typenumber | nullDefaultnull

The row that starts open. null starts with every row closed.

index

Typenumber | null

The open row, or null for none. Set it with onIndexChange to control the list from outside.

onIndexChange

Type(index: number | null) => void

Called when a row opens, or with null when the open row closes.

openOn

Type"hover" | "click"Default"hover"

hover opens the row under the pointer once it slows down, and the row keyboard focus reaches. click waits for a click, tap or Enter, and a second one closes a row without a link.

collapseOnLeave

TypebooleanDefaultfalse

Close the open row when the pointer or keyboard focus leaves the list. Otherwise the last row opened stays open.

dim

TypebooleanDefaulttrue

Fade the other rows back while one is open and the pointer or keyboard focus is in the list.

duration

TypenumberDefault0.5

Seconds a row takes to open while the rows below glide down. The tab widening into a photo, the title sliding over and the details rising all ride the same spring.

hoverDelay

TypenumberDefault0.09

Seconds the pointer has to rest on a row before it opens, when it arrives moving fast. A slow pointer opens it at once. Lower lets a quick sweep ripple the list; higher waits longer for intent.

numbered

TypebooleanDefaulttrue

Show a 01, 02, … column before the titles.

imageWidth

TypestringDefault"clamp(5rem, 24cqi, 11rem)"

Width of an open row's photo, as a CSS length. cqi is a percentage of the list's width.

imageAspect

TypenumberDefault4 / 3

Width-to-height ratio of an open row's photo. 1 for square covers.

className

Typestring

Classes for the list. Rows draw their dividers in the text color, so set text-* here to recolor the whole list.

item.title Required

TypeReact.ReactNode

StretchIndexItem: the row's title. It's laid out at its open width, so it never rewraps while the row opens.

item.meta

TypeReact.ReactNode

StretchIndexItem: short text at the end of the row, like a year, a company or a length. Moves under the title in lists narrower than 32rem.

item.number

TypeReact.ReactNode

StretchIndexItem: replaces the automatic 01, 02, … for this row.

item.href

Typestring

StretchIndexItem: makes the whole row a link. On touch, and in click lists, the first tap opens the row and the second follows the link.

item.image

Typestring

StretchIndexItem: photo URL. The tab widens into a frame around it as the row opens. Without one, the frame fills with the accent.

item.accent

Typestring

StretchIndexItem: the color the tab warms to on hover and open, and the frame's color before the photo shows. Defaults to the text color.

item.children

TypeReact.ReactNode

StretchIndexItem: details that rise out from under the title when the row opens. Links and buttons in here stay clickable.

item.className

Typestring

StretchIndexItem: classes for the row. It's a group/row with data-state="open" or "closed".