本文へ移動
日本語

仕組み

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.

向いている場面

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

向かない場面

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

使い方

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

プロパティ

プロパティ型既定値説明
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.

アクセシビリティ

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

モーション

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.

プロジェクトに追加

プロンプトを Codex または Claude Code に貼り付けます。エージェントが公開ソースを読み、書き込む内容を示したうえで、既存のコンポーネントの隣に追加します。

ProfileCard.jsxprofile-card.csstokens.cssREADME.md

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

カード
「動く枠線カード」は Pro に含まれます。解除するとプレビューが表示されます。
「ビームボーダー」は Pro に含まれます。解除するとプレビューが表示されます。
「カード詳細とロック」は Pro に含まれます。解除するとプレビューが表示されます。