Ir al contenido
Español
Carrusel cilíndrico viene con Pro. La vista previa aparece al desbloquearlo.

Cómo funciona

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.

Úsalo para

  • 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.

Busca otra opción cuando

  • Not for content that must be read in order or compared: the cards behind are dim and mirrored away.

Uso

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>
      )}
    />
  )
}

Propiedades

PropiedadTipoPor defectoQué hace
itemsT[][]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.
indexnumber—Controlled current card. Omit to let the ring keep its own.
defaultIndexnumber0First 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.
slotsnumber0Places 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.
cardWidthnumber168Card width in pixels; the radius follows from it, the gap and the number of places.
cardRationumber1.25Card height over width.
gapnumber14Space between neighbouring cards round the ring, in pixels.
tiltnumber10How far the ring is tipped toward the viewer, in degrees.
autoSpinbooleantrueTurn slowly on its own. It stops while the ring is pointed at or focused, adds a pause button and never runs under reduced motion.
speednumber9Speed of the slow spin in degrees per second.
pausedbooleanfalseHolds the slow spin from outside.
controlsbooleantrueShow the previous, pause and next buttons under the ring.
labelstring'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).

Accesibilidad

  • 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.

Movimiento

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.

Añádelo a tu proyecto

Los miembros Pro copian un prompt y su agente de programación instala el código, igual que con los gratuitos.

CylinderCarousel.jsxcylinder-carousel.csstokens.cssREADME.md

Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.

Listas
Carrusel en arco viene con Pro. La vista previa aparece al desbloquearlo.
Acordeón de mazos viene con Pro. La vista previa aparece al desbloquearlo.