Ir al contenido
Español

Cómo funciona

A soft cover band tinted from a stable hue derived from the name, an avatar overlapping it inside a surface-coloured ring, a tight name and role, stats split by hairlines and the follow button. Pressing Follow flips the button and any stat marked follows at once; if the Promise from onFollowChange rejects, both roll back and a short error appears. The two button faces share one grid cell, so the width never jumps; the check draws in; and right after following, hovering does not offer Unfollow until the pointer has left once.

Úsalo para

  • Author, creator or teammate cards in feeds, directories and sidebars.
  • Any follow, subscribe or connect action that should feel instant.

Busca otra opción cuando

  • Actions that must be confirmed by the server before showing success, such as payments.
  • Full profile pages: use a page layout.

Uso

import { ProfileCard } from './ProfileCard.jsx'

export function AuthorCard({ author }) {
  return (
    <ProfileCard
      name={author.name}
      role={author.role}
      avatar={author.photoUrl}
      status="online"
      defaultFollowing={author.isFollowed}
      stats={[
        { label: 'Projects', value: author.projects },
        { label: 'Followers', value: author.followers, follows: true },
      ]}
      // Return a Promise: a rejection rolls the button and the count back
      onFollowChange={(next) => api.setFollow(author.id, next)}
    />
  )
}

Propiedades

PropiedadTipoPor defectoQué hace
namestring—Display name; also gives the initials and the avatar hue.
roleReactNode—One line under the name.
avatarstring—Image URL; without it the initials show on a gradient.
status'online' | 'busy' | 'away'—Presence dot on the avatar.
statsArray<{ label, value, format?, follows? }>[]Figures in a row. follows: true moves that number by one with the button.
followingboolean—Controlled state.
defaultFollowingbooleanfalseInitial state when uncontrolled.
onFollowChange(next: boolean) => void | Promise—Called with the new state; the card has already flipped. A rejected Promise rolls back and shows labels.error.
actionsReactNode—Extra buttons beside Follow.
layout'vertical' | 'horizontal''vertical'Centred with cover, or avatar beside the name.
coverbooleantrueShows the tinted cover band.
labelsobject—follow, following, unfollow, error, followed(name), unfollowed(name). Shallow-merged over English.

Accesibilidad

  • The card is an <article> with the name as an <h3>; stats are a description list.
  • Follow is a native button with a constant name and aria-pressed; the visible faces are hidden from screen readers.
  • Every change is announced through a polite live region, including the rollback message.
  • The button is 44px tall; focus-visible shows a ring outside a surface-colour gap.
  • Reduced motion keeps only fades: no face slide, press scale or checkmark drawing.

Movimiento

Faces cross over in 240ms ease-out with a 6px rise; the check draws in 360ms; pressing scales to 97% for 100ms and springs back. While saving, the changed count is tinted with the accent and fades back in 360ms.

Añádelo a tu proyecto

Copia la instrucción en Codex o Claude Code. El agente lee el código publicado, te muestra lo que va a escribir y añade el componente junto a los tuyos.

ProfileCard.jsxprofile-card.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.