Interactive Media Accordion
A sticky media accordion that advances with scroll and reverses as you scroll back. Click or focus a card to select it directly; narrow layouts keep every card visible when space allows.
Installation#
pnpm dlx shadcn@latest add @davinciui/interactive-media-accordionUsage#
API Reference#
| Prop | Type | Default |
|---|---|---|
itemsGallery data. Each item needs an id + media (image or video URL), optional mediaType ('auto' | 'image' | 'video'), alt, title, description, and focal positionX / positionY (0–100). Works with any item count. | InteractiveMediaAccordionItem[] | — |
triggerScroll mode pins the gallery and advances one card per scroll band. Hover and click remain available for compact, non-scrolling placements. | "scroll" | "hover" | "click" | "scroll" |
scrollStepScroll distance in pixels assigned to each item while trigger is scroll. | number | 800 |
stickyTopSticky offset from the top of the nearest scroll container. | number | 40 |
activeIndex / initialActiveIndexControlled active index, or the uncontrolled starting index. | number | 0 |
onActiveChangeFires whenever the expanded item changes. | (index: number) => void | — |
heightGallery height in pixels. | number | 600 |
gapGap between cards in pixels (reduced automatically on narrow containers). | number | 14 |
collapsedWidthInactive pill width on desktop. Tablet and mobile widths adapt via tabletCollapsedWidth / mobileCollapsedWidth. | number | 132 |
radius / collapsedRadiusActive card radius and pill radius. The pill defaults to a capsule. | number | 48 / collapsedWidth ÷ 2 |
outerPaddingOuter padding of the gallery in pixels. | number | 0 |
fitHow media fills its card. Cover keeps the crop-window behavior. | "cover" | "contain" | "cover" |
textGradient / gradientStrengthBottom gradient behind the active text, with 0–1 strength. | boolean / number | true / 0.8 |
inactiveBrightness / inactiveSaturationOptional treatment for inactive pills. Defaults keep the original image. | number | 1 / 1 |
titleSize / descriptionSizeActive text sizes in pixels, scaled down on narrow containers. | number | 40 / 15 |
titleFont / descriptionFontFont families for the active title and subtitle. | string | — |
titleColor / descriptionColorActive text colors. | string | "#ffffff" / white 82% |
contentPaddingActive text inset [x, y] from the card edges. | [number, number] | [40, 44] |
textAlignActive text alignment. | "left" | "center" | "right" | "left" |
autoPlay / autoPlayIntervalAuto-advance in hover or click mode. Scroll mode always follows scroll position. | boolean / number | false / 4000 |
pauseAutoPlayOnHoverPause auto-play while the pointer is over the gallery. | boolean | true |
duration / easingSingle shared transition for width, radius, and position. | number / string | 650 / cubic-bezier(0.22, 1, 0.36, 1) |
reducedMotionShorten transitions while preserving functionality. System preference is respected automatically. | boolean | false |
Accessibility#
Each card is a button with aria-expanded, aria-current, and a label from title or alt, inside a group labelled 'Interactive media gallery'. Focus activates a card and focus-visible rings are provided; focus activation does not scroll the page in scroll mode.
Motion#
Card width, radius, media filter, gradient opacity, and text position transition using duration and easing; system reduced motion or the reducedMotion prop shortens duration to zero and caps radius. Autoplay pauses under reduced motion.
View source
Keep in mind
Need a custom component?
I build bespoke UI components & websites tailored to your brand.

