仕組み
Folder i sits one step lower than the folder behind it and 6px wider on each side, so the stack reads as stairs, and its tab steps from left to right across the width. Each folder is three layers: the tab (part of the back), the index card, and the front panel, so a card rises from between them, in front of the folders behind and behind the ones in front. Opening slides the card up by its height less 14px on a 600ms spring with a small overshoot; the folders in front dip 10px and the header fades. Closing slides it back in 360ms. Pointing at a folder or focusing its tab lifts it 6px. Folders further back are a shade deeper. While a card is out its own tab is behind it, so the tab's focus ring is drawn around the card.
向いている場面
- Testimonials or reviews on a landing page, one at a time.
- A recipe box, study cards or notes grouped by section.
- Any short set of sections where each has one card worth of content.
向かない場面
- More than about eight sections: the tabs get too small; use tabs or a list.
- Long content: a card shows about 130px; link to the full page instead.
- Comparing several sections side by side: only one card is out at a time.
使い方
import { useState } from 'react'
import { IndexCardStack } from './IndexCardStack.jsx'
export function Reviews({ reviews }) {
const [open, setOpen] = useState(null)
return (
<IndexCardStack
label="Customer reviews"
items={reviews.map((r) => ({
id: r.id,
tab: r.company,
content: (
<figure>
<blockquote>{r.quote}</blockquote>
<figcaption>{r.author}, {r.role}</figcaption>
</figure>
),
}))}
value={open}
onValueChange={setOpen}
header={<h3>What teams say</h3>}
footer={`Reviews · ${reviews.length}`}
cardHeight={170}
/>
)
}プロパティ
| プロパティ | 型 | 既定値 | 説明 |
|---|---|---|---|
items | { id, tab, content }[] | — | The folders from back to front: the tab label and the content of its card. Five to eight read best. |
value | id | null | — | The id of the card that is out (controlled), or null for none. |
defaultValue | id | null | null | The card out at first when uncontrolled. |
onValueChange | (id | null) => void | — | Called when a tab, a press on the card or Escape takes a card out or puts it back. |
header | ReactNode | — | Shown in the headroom above the folders; it fades away while a card is out. |
footer | ReactNode | — | Text on the front of the box, such as a count. |
step | number | 26 | Vertical step between folders in pixels. |
cardHeight | number | 150 | Height of each card; the headroom above the folders follows, so the back card has room to rise. |
label | string | — | Accessible name of the group. |
...rest | HTMLAttributes | — | Other attributes go to the root element. |
アクセシビリティ
- Each tab is a native button with aria-expanded and aria-controls pointing at its card, which is a region labelled by the tab.
- Tabs use a roving tab stop: Up, Down, Left and Right move between them, Home and End jump to the ends, Enter or Space opens or closes, Escape puts the card back.
- Cards that are tucked away are inert, so neither the keyboard nor a screen reader reaches their content.
- Pressing the card (outside its own links and buttons) or a folder's front panel also toggles it, for pointer and touch.
- Tab labels are 13px and end in an ellipsis when long; card text is at least 12px.
- Reduced motion moves cards and folders to their places at once, without sliding, springing or dipping.
モーション
Card out: 600ms spring with a slight overshoot. Card back: 360ms ease-in-out. Folders in front dip 10px and lifted folders rise 6px, 360ms ease-out. Header fades in 240ms.
プロジェクトに追加
Pro メンバーはプロンプトをコピーし、コーディングエージェントが無料コンポーネントと同じ手順でソースを導入します。
IndexCardStack.jsxindex-card-stack.csstokens.cssREADME.md
2 つのファイルを一緒に導入します。スタイルは tokens.css の変数を読み、予備の値も持つため、単体でも表示できます。





