How it works
A preserve-3d ring turned by one angle in degrees. Each card stands at its own place round the ring, pushed out by a radius worked out from the card width, the gap and the number of places, so neighbours never overlap. The ring is tipped back by the tilt, which shows the far side over the near one. In CSS each card takes the cosine of the way it faces and darkens as it turns away; behind the ring its back shows. The card in front steps out of the ring and takes an accent rim. One frame loop turns the ring: a tween to a chosen card by the shortest way round, the coast after a throw (it slows by friction and settles on a card), and the slow spin after the ring has been left alone for a moment. The scene scales down to fit narrow containers.
Use it for
- A showcase on a landing page or a portfolio, where the ring itself draws the eye: principles, features, testimonials, projects.
- Six to twenty short cards. With fewer items, set slots so they repeat and the ring looks full.
Look elsewhere when
- Not for content that must be read in order or compared: the cards behind are dim and mirrored away.
Usage
import { CylinderCarousel } from './CylinderCarousel.jsx'
const principles = [
{ id: 'hierarchy', title: 'Clear hierarchy', text: 'Space groups content before borders do.' },
{ id: 'motion', title: 'Honest motion', text: 'Every transition explains origin and destination.' },
{ id: 'precision', title: 'Tabular precision', text: 'Numbers stay calm while live metrics tick.' },
{ id: 'keyboard', title: 'Keyboard first', text: 'Every interactive control works without a pointer.' },
]
export function Principles({ onOpen }) {
return (
<CylinderCarousel
items={principles}
slots={12}
label="Design principles"
onSelect={(item) => onOpen(item.id)}
renderCard={(item, { active }) => (
<div style={{ padding: 14, height: '100%', boxSizing: 'border-box' }}>
<strong>{item.title}</strong>
<p>{item.text}</p>
</div>
)}
/>
)
}Props
| Prop | Type | Default | What it does |
|---|---|---|---|
items | T[] | [] | The cards, in order round the ring. |
renderCard | (item, { index, active }) => ReactNode | — | Content of a card's face. active is true for the card facing the viewer. |
renderBack | (item, { index }) => ReactNode | — | Optional content for the back of a card, seen through the ring. A plain dark back by default. |
getLabel | (item, index) => string | — | Name of each slide for screen readers. Defaults to item.title or item.name. |
index | number | — | Controlled current card. Omit to let the ring keep its own. |
defaultIndex | number | 0 | First card in front for an uncontrolled ring. |
onIndexChange | (index, item) => void | — | Called when another card comes to the front, by a key, a press, a throw or the slow spin. |
onSelect | (item, index) => void | — | Called when the front card is pressed, or Enter is pressed on the ring. |
slots | number | 0 | Places round the ring. When larger than the number of items, the items repeat (the copies are hidden from screen readers) so a short list still makes a full ring. |
cardWidth | number | 168 | Card width in pixels; the radius follows from it, the gap and the number of places. |
cardRatio | number | 1.25 | Card height over width. |
gap | number | 14 | Space between neighbouring cards round the ring, in pixels. |
tilt | number | 10 | How far the ring is tipped toward the viewer, in degrees. |
autoSpin | boolean | true | Turn slowly on its own. It stops while the ring is pointed at or focused, adds a pause button and never runs under reduced motion. |
speed | number | 9 | Speed of the slow spin in degrees per second. |
paused | boolean | false | Holds the slow spin from outside. |
controls | boolean | true | Show the previous, pause and next buttons under the ring. |
label | string | 'Carousel' | Accessible name of the carousel. |
labels | { previous?, next?, pause?, play?, slide?, hint? } | — | Replaces the built-in English text; slide is a function of (n, total). |
Accessibility
- The section is a carousel (aria-roledescription) and each original card a slide named by its label and position; repeated copies are aria-hidden.
- The ring is one focusable stop: Left and Right bring the previous or next card to the front, Home and End the first and last, Enter selects the front card.
- Previous, pause and next are real buttons. The slow spin stops while the ring is pointed at or focused, and the pause button stops it for good (aria-pressed).
- A polite live region names the front card when it changes by a key, a press or a throw; it stays quiet while the ring spins on its own.
- A finger must move sideways before the ring turns, so a vertical page scroll that starts on it still works.
- Under reduced motion there is no ring and no spin: the cards stand in a flat row that scrolls sideways and snaps to each card, and the keys scroll the chosen card into view.
Motion
A chosen card turns to the front in 640 ms on an ease-out cubic; a throw coasts with friction and settles in 420 ms; the slow spin starts 0.9 s after the last touch. Under reduced motion the ring is replaced by a flat scrolling row with no animation.
Add it to your project
Pro members copy a prompt and their coding agent installs the source, the same way as the free components.
CylinderCarousel.jsxcylinder-carousel.csstokens.cssREADME.md
Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.





