使い方
import { ResultPage } from './ResultPage.jsx'
// After the action has finished on the server, show its result on its own page:
<ResultPage
locale="en"
variant={payment.ok ? 'success' : 'failure'}
title={payment.ok ? 'Invoice INV-2041 paid' : 'Payment for INV-2041 failed'}
details={[{ label: 'Amount', value: '$4,800.00' }, { label: 'Reference', value: 'INV-2041', copy: true }]}
continueIn={payment.ok ? 8 : 0} // seconds; 0 turns the countdown off
onContinue={() => router.push('/invoices/2041')}
onAction={async (which, variant) => {
if (which === 'primary' && variant === 'failure') return await payment.retry()
if (which === 'secondary') router.push('/invoices')
}}
/>プロパティ
| プロパティ | 型 | 既定値 | 説明 |
|---|---|---|---|
locale | 'en' | 'zh-CN' | 'es' | 'ja' | 'en' | 組み込みの文言の言語。 |
variant | 'success' | 'failure' | 'success' | 表示する結果。自動で次へ進むのは成功のときだけです。 |
loading | boolean | false | 処理中。スピナーとひとことを表示し、スクリーンリーダーにも伝えます。 |
title / text / details | string / string / Array<{ label, value, copy? }> | — | 表示中の結果の見出し・説明・情報を置き換えます。見出しは「対象+操作+結果」で。 |
continueIn | number | 8 | 成功後に自動で進むまでの秒数。0 でオフ。操作部分にポインタやフォーカスがあると一時停止し、「このページに留まる」で止まります。 |
onAction | (which: 'primary' | 'secondary', variant) => Promise<any> | void | — | 次の操作が押されたとき。Promise の間はボタンが待機表示になります。 |
onContinue | () => void | — | カウントダウンが 0 になったとき。未指定ならメインの操作を実行します。 |
labels | object | — | 組み込みの文言を置き換えます(キーは copy.js と同じ)。 |
プロジェクトに追加
プロンプトを Codex や Claude Code に貼り付けます。エージェントが公開ソースを読み、書き込むファイルを示してから、使っているコンポーネントと一緒にブロックを追加します。
ResultPage.jsxresult-page.csscopy.jskit.jsxkit.cssui/base-button/ui/copy-button/ui/success-check/ui/spinner/tokens.cssREADME.md
ブロック本体、スタイルと文言、共通の kit、使っているコンポーネント、tokens.css が 1 つのフォルダにまとめて入ります。