Ir al contenido
Español
Fichero de tarjetas viene con Pro. La vista previa aparece al desbloquearlo.

Cómo funciona

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.

Úsalo para

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

Busca otra opción cuando

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

Uso

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

Propiedades

PropiedadTipoPor defectoQué hace
items{ id, tab, content }[]—The folders from back to front: the tab label and the content of its card. Five to eight read best.
valueid | null—The id of the card that is out (controlled), or null for none.
defaultValueid | nullnullThe 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.
headerReactNode—Shown in the headroom above the folders; it fades away while a card is out.
footerReactNode—Text on the front of the box, such as a count.
stepnumber26Vertical step between folders in pixels.
cardHeightnumber150Height of each card; the headroom above the folders follows, so the back card has room to rise.
labelstring—Accessible name of the group.
...restHTMLAttributes—Other attributes go to the root element.

Accesibilidad

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

Movimiento

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.

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.

IndexCardStack.jsxindex-card-stack.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.
Carrusel cilíndrico viene con Pro. La vista previa aparece al desbloquearlo.