「ボトムシート」は Pro に含まれます。解除するとプレビューが表示されます。
仕組み
The card is placed in layout pixels against the closest element marked data-ds-boundary, or the viewport: it flips above when there is no room below, shifts sideways to stay inside, and moves its arrow by the same amount so it still points at the trigger. A transparent bridge covers the gap so the pointer can reach the card.
向いている場面
- Previewing a person, a link or a record without leaving the page.
- Optional context that sighted pointer users benefit from.
向かない場面
- Essential information or actions: they must also be reachable another way, since touch has no hover.
- Short text labels: use a tooltip.
使い方
import { HoverCard } from './HoverCard.jsx'
export function Mention() {
return (
<HoverCard label="Profile of Mara Lin" content={<ProfilePreview id="mara" />}>
<a href="/people/mara">@mara.lin</a>
</HoverCard>
)
}プロパティ
| プロパティ | 型 | 既定値 | 説明 |
|---|---|---|---|
children | ReactElement | — | The trigger, usually a link; it receives aria-describedby while the card is open. |
content | ReactNode | — | The card body. Use inline elements (span) when the trigger sits inside a paragraph. |
label | string | — | Accessible name of the card. |
openDelay | number | 500 | Pointer rest time in ms before opening; keyboard focus waits at most 300. |
closeDelay | number | 220 | Grace period in ms after the pointer leaves. |
side | 'bottom' | 'top' | 'bottom' | Preferred side; flips when there is no room. |
defaultOpen | boolean | false | Open on first render. |
アクセシビリティ
- The card opens on keyboard focus as well as hover, and the trigger gets aria-describedby pointing at it.
- The card is a non-modal role dialog placed right after the trigger, so Tab moves into its buttons; leaving the card closes it.
- Escape closes the card and returns focus to the trigger.
- Touch input does not open it; the link keeps working as a link.
- With reduced motion the card only fades and the delay underline appears without animating.
モーション
Open after 500ms with a linear underline fill; enter 220ms cubic-bezier(0.32, 1.2, 0.5, 1) from 0.96 scale and 4px, scaled from the arrow; leave 130ms.
プロジェクトに追加
プロンプトを Codex または Claude Code に貼り付けます。エージェントが公開ソースを読み、書き込む内容を示したうえで、既存のコンポーネントの隣に追加します。
HoverCard.jsxhover-card.csstokens.cssREADME.md
2 つのファイルを一緒に導入します。スタイルは tokens.css の変数を読み、予備の値も持つため、単体でも表示できます。

