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

Cómo funciona

One card surface: the balance with a caption on top, the pile below. Each card's slot (0 is the front) becomes translate (one strip up per slot) and scale (5% smaller per slot, from the top edge), both transitioned for 420ms on a light spring curve, so a new pick mid-move retargets from wherever the cards are. The chosen card goes on top at once, plays a lift (up 12px, scale 1.02, a deeper shadow) on the way down and lands in front; the cards it passed step back one slot each and darken slightly. The pile keeps the order of the last picks, and arrow keys or swipes walk the list order, which always pulls the card at the back forward. The balance is formatted with Intl.NumberFormat; every digit is an odometer column that rolls up when the amount grows and down when it shrinks, right-most first, with a light blur while moving. Card art is CSS and inline SVG, no pictures: each material is two gradient stops and an ink under one light from the upper left, with a fine grain, hairline brushing, a 1px inner highlight on the top edge and layered soft shadows for thickness. The card is about 1.586:1 like a bank card; its strip carries the name, the last four digits and the type, so a card behind is still recognizable. The chip is a brushed-gold plate with engraved pads, the number is set in monospaced figures pressed into the card, and an original geometric mark sits bottom right.

Úsalo para

  • Banking and wallet apps that switch between a few accounts or cards.
  • A dashboard widget where the chosen account drives the figures around it.
  • Mobile screens where a vertical swipe is the natural way to flip through cards.

Busca otra opción cuando

  • More than about five cards: the strips get crowded; use a list or a carousel.
  • Choices that are not money or cards: a segmented control is plainer.

Uso

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

const cards = [
  { id: 'daily', name: 'Day-to-day', type: 'debit', balance: 2486.3, last4: '4821', tone: 'graphite' },
  { id: 'trips', name: 'Getaway', type: 'credit', balance: 1092.75, last4: '0937', tone: 'navy' },
  { id: 'saved', name: 'Nest egg', type: 'debit', balance: 8615.04, last4: '5562', tone: 'champagne' },
]

export function Wallet() {
  const [card, setCard] = useState('daily')
  return <WalletStack cards={cards} value={card} onChange={setCard} currency="USD" locale="en-US" />
}

Propiedades

PropiedadTipoPor defectoQué hace
cards{ id, name, type, balance, last4?, note?, tone? }[]—The cards, in the order arrow keys and swipes walk through them. type 'debit' or 'credit' is shown through labels.types (any other string is shown as is). tone is the card's material: 'graphite', 'navy', 'champagne' or 'sage' (by default the cards take them in that order); a chart colour 1-8, 'accent', 'secondary', 'tertiary' or a CSS colour is pressed into the same finish, keeping its hue but mixed far toward graphite. last4 shows beside the name on the card's strip and ends the printed number. note is a short line on the front card's bottom row, opposite the mark (a budget, a due date), ellipsized when long and part of the card's spoken name.
value / defaultValue / onChangestring / string / (id, card) => void- / first card / -The card in front, controlled or uncontrolled, by id.
currency / localestring / string'USD' / 'en-US'Currency and locale of the balance, formatted with Intl.NumberFormat.
formatBalance(balance, card) => string—Replaces the built-in currency format. Digits in the result roll; other characters stay put.
peeknumber44Height in px of the strip each card behind shows (at least 40, so it stays a touch target).
labelsobject—Replaces built-in text: title, group, available(name), types { debit, credit }, card(card, type), announce(amount, name). Shallow-merged over the English defaults; pass title: '' to hide the heading.
...restHTMLAttributes—Other attributes go to the root <div>.

Accesibilidad

  • The pile is a radiogroup and each card a radio with aria-checked and an accessible name built from labels.card (name, type, last four digits).
  • Roving tabindex: Tab reaches the front card; arrow keys pick the next or previous card and move focus with it, Home and End jump to the first and last, Enter and Space pick a focused card.
  • The rolling digits and the caption are aria-hidden; a polite live region announces the new balance and card once per change, never the in-between digits.
  • The strip of each card behind is at least 40px tall, so it stays a touch target; a vertical swipe on the pile changes the card, and the click after a swipe is ignored.
  • A focus ring (a 2px outline 3px outside the card) shows on :focus-visible. Each material sets its own ink: light text on graphite, navy and sage, dark text on champagne; names, digits, type and note keep at least 4.5:1 against the face, sheen included.
  • With reduced motion the cards change places instantly, digits and the caption change without rolling, sliding or blur.

Movimiento

Cards move with translate and scale over 420ms on cubic-bezier(0.32, 1.22, 0.5, 1); the lift (transform and a shadow layer's opacity) peaks at about a third of the way on the ease-out curve. Digits roll for 420ms with an 18ms stagger from the right and blur up to 1.2px. The caption enters in 360ms from 20px below (or above when the balance falls) while the old one leaves in 160ms. Only transform, opacity and filter animate. The front card's sheen leans toward a mouse pointer over the pile (translate only, one update per frame while the pointer moves, a 900ms ease back when it leaves); it does not move on touch, under reduced motion, or when no pointer is moving, so nothing runs at rest or off screen.

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.

WalletStack.jsxwallet-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.

Tarjetas
Tarjeta con borde animado viene con Pro. La vista previa aparece al desbloquearlo.
Borde con haz de luz viene con Pro. La vista previa aparece al desbloquearlo.
Tarjeta con hoja de datos viene con Pro. La vista previa aparece al desbloquearlo.