本文へ移動
日本語
「アーチ型カルーセル」は Pro に含まれます。解除するとプレビューが表示されます。

仕組み

The layout is one number: the row's position in cards, a registered CSS property set on the stage. Each card works out its distance d to it in CSS and from that its offset (spacing tightens slightly with distance), a drop that grows with d² (the arc), a tilt of 3.2° and a turn of −7° toward the centre per card, a scale that steps down 15% per card, and a veil in the background colour that deepens with distance; past the visible range cards fade out. Dragging writes the position on every frame. On release the row projects where it would coast at the speed of the throw, picks that card and glides there on the ease-out curve, for longer the further it goes. A grab during a glide catches the row where it is. Past either end the row gives way like a rubber band. Sideways trackpad scrolling moves the row and settles once the fingers stop.

向いている場面

  • A showcase row on a landing page or a shop: collections, destinations, featured products.
  • Browsing a handful of visual items where one at a time deserves attention.
  • Onboarding or plan pickers where the centre choice is the one being described.

向かない場面

  • Long lists people need to scan or compare: use a grid or a list.
  • Content that must all be read: only the centre card is fully visible.
  • Text-heavy cards: side cards are small and veiled.

使い方

import { useState } from 'react'
import { ArcCarousel } from './ArcCarousel.jsx'

export function Collections({ collections, openCollection }) {
  const [index, setIndex] = useState(0)
  return (
    <ArcCarousel
      items={collections}
      index={index}
      onIndexChange={setIndex}
      label="Collections"
      cardWidth={180}
      getLabel={(c) => c.name}
      renderCard={(c) => <img src={c.cover} alt="" style={{ width: '100%', height: '100%', objectFit: 'cover' }} />}
      renderCaption={(c) => (
        <>
          <strong>{c.name}</strong>
          <span>{c.itemCount} pieces</span>
        </>
      )}
      onSelect={(c) => openCollection(c.id)}
    />
  )
}

プロパティ

プロパティ型既定値説明
itemsT[]—The cards, in order. An `id` on each item is used as its key.
renderCard(item, { index, active }) => ReactNode—Draws a card's face. It fills the card, which clips it to the rounded corners.
renderCaption(item, index) => ReactNode—The caption under the centre card; it fades in each time the centre card changes. Defaults to the label.
getLabel(item, index) => stringitem.title ?? item.nameAccessible name of each card, read with its position ("Salt Bay, 1 of 7").
indexnumber—The centre card (controlled). Leave undefined to let the carousel keep its own.
defaultIndexnumber0The first centre card when uncontrolled.
onIndexChange(index, item) => void—Called when a drag, swipe, key, trackpad scroll, button or press on a side card chooses a new centre card.
onSelect(item, index) => void—Called when the centre card is pressed, or on Enter while the carousel has focus.
cardWidthnumber168Width of the centre card in pixels; the stage height follows.
cardRationumber1.3Card height as a multiple of its width.
curvenumber1Strength of the arc: how far side cards drop and tilt. 0 is a flat row.
spreadnumber1Spacing between cards as a multiple of the default.
visiblenumber2Cards drawn on each side of the centre before they fade out.
controlsbooleantrueShows the previous and next buttons beside the caption.
labelstring'Gallery'Accessible name of the carousel.
labelsobject—Replaces built-in text: previous, next, slide(n, total) and hint (read when the stage gets focus). Shallow-merged over the English defaults.
...restHTMLAttributes—Other attributes go to the root <section>.

アクセシビリティ

  • The root is a section with aria-roledescription carousel; each card is a group with aria-roledescription slide, named by getLabel plus its position, and the centre one carries aria-current.
  • The stage is focusable: Left and Right move one card, Home and End jump to the ends, Enter selects the centre card.
  • The caption is a polite live region, so each change is announced with the card's position.
  • The previous and next buttons are native buttons with labels and are disabled at the ends.
  • On touch the stage keeps vertical scrolling (touch-action: pan-y) and only takes over once a finger moves sideways.
  • Reduced motion jumps straight to the chosen card and swaps the caption without moving it; a drag still follows the finger.

モーション

Per card from the centre: scale −15%, tilt 3.2°, turn −7°, drop growing with the square of the distance, veil +26% (all × curve). Glide: ease-out, 520ms for a key or button, 340–900ms after a throw depending on how far it coasts. Caption: rises 6px and fades in over 360ms.

プロジェクトに追加

Pro メンバーはプロンプトをコピーし、コーディングエージェントが無料コンポーネントと同じ手順でソースを導入します。

ArcCarousel.jsxarc-carousel.csstokens.cssREADME.md

2 つのファイルを一緒に導入します。スタイルは tokens.css の変数を読み、予備の値も持つため、単体でも表示できます。

リスト
「円柱カルーセル」は Pro に含まれます。解除するとプレビューが表示されます。
「カード束リスト」は Pro に含まれます。解除するとプレビューが表示されます。