Cover Flow
Row of covers that turn in 3D as you scroll, inspired by Cover Flow on iOS 6.
- Dependencies (1)
Features
- Drag with a mouse; a flick coasts and lands on a cover.
- The value changes as each cover passes the center, so a caption keeps up while scrolling.
Installation
pnpm dlx shadcn@latest add @ncdai/cover-flow
Usage
import {
CoverFlow,
CoverFlowCover,
CoverFlowItem,
CoverFlowReflection,
} from "@/components/cover-flow"<CoverFlow aria-label="Albums">
<CoverFlowItem value="album">
<CoverFlowCover>
<img src="/album.jpg" alt="Album" />
<CoverFlowReflection>
<img src="/album.jpg" alt="" />
</CoverFlowReflection>
</CoverFlowCover>
</CoverFlowItem>
</CoverFlow>CoverFlowReflection is optional and needs the same content as the cover.
Composition
Use the following composition to build a CoverFlow
CoverFlow
└── CoverFlowItem
└── CoverFlowCover
└── CoverFlowReflectionAPI reference
CoverFlow
Prop
Type
CoverFlowItem
Prop
Type
CSS variables
Set them on CoverFlow, for example className="[--cover-flow-size:--spacing(56)]".
| Variable | Default | Description |
|---|---|---|
--cover-flow-size | --spacing(48) | Width and height of a cover. |
--cover-flow-angle | 70deg | How far the side covers turn. |
--cover-flow-first | size * 0.64 | Gap between the center and the next cover. |
--cover-flow-step | size * 0.26 | Gap between the stacked side covers. |
--cover-flow-depth | size * -0.75 | How far the side covers sit back. |
Data attributes
| Attribute | Element | Present when |
|---|---|---|
data-selected | CoverFlowItem, CoverFlowCover | The cover is at the center. |
Accessibility
- The row is a listbox and the centered cover its selected option. Name the row with
aria-labeland each cover with its image'salt. ArrowLeftandArrowRightstep through the covers,HomeandEndjump to the ends.- With
prefers-reduced-motion, clicks and keys jump to the cover instead of gliding.
Credits
- Apple
- Photos by Marina Lobato, diGital Sennin, Thai Tong, Tam Dang Ngoc, Jonathan Ouimet, Tron Le, and Ngô Thanh Tùng on Unsplash
References
- Scroll-driven animations — view timelines that draw the covers
License and usage
- Free to use and modify in both personal and commercial projects.
- Attribution is appreciated but not required.
- Released under the MIT License.
Every component here is built and maintained by one person. If you enjoy using them, you can sponsor my work.






