本文へ移動
日本語

仕組み

Progress lives in one registered custom property animated with Web Animations: a quick jump to 10%, then a long ease-out towards 92% that keeps moving more and more slowly. On completion it continues from its current value to 100% in 260ms and fades over 360ms. No timers run per frame, and the bar is clipped rather than moved, so it never sticks out of its container.

向いている場面

  • Client-side route changes and other whole-page loads.
  • Inside an app window or panel (position="absolute") when only that area reloads.

向かない場面

  • One button or row is busy: use a spinner there.
  • A long task with real steps: use a progress bar with a value and text.

使い方

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

// In your app shell: true while a route is loading
export function Shell({ navigating, children }) {
  return (
    <>
      <TopLoader loading={navigating} />
      {children}
    </>
  )
}

プロパティ

プロパティ型既定値説明
loadingboolean—true starts (or keeps) the bar; false completes it and fades it out.
progressnumber—0 to 1. When set, the bar follows this value instead of trickling (for uploads with real progress).
tricklenumber9000Milliseconds the trickle takes to approach 92%; it slows down all the way.
heightnumber3Thickness in px.
position'fixed' | 'absolute''fixed'fixed pins it to the viewport; absolute pins it to the nearest positioned parent (a panel or window).
labelstring'Loading page'Accessible name of the progress bar.
...restHTMLAttributes<HTMLDivElement>—Passed to the root. Colour: --ds-toploader-color (accent); layer: --ds-toploader-z (1000).

アクセシビリティ

  • The bar is role="progressbar" with a label and aria-busy while loading; it is aria-hidden when idle. With progress set it also exposes aria-valuenow.
  • It is decorative motion on top of the page: also mark the content that is changing with aria-busy.
  • Reduced motion: no trickle or sheen; the bar shows full width and breathes in opacity until done.

モーション

Start: 0 to 10% in the first 4% of the trickle on an ease-out, then cubic-bezier(0.05, 0.7, 0.1, 1) towards 92%. Complete: 260ms to 100%, then a 360ms fade after 220ms. A light sheen sweeps the bar every 1.8s.

プロジェクトに追加

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

TopLoader.jsxtop-loader.csstokens.cssREADME.md

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

読み込み
「画像リビール」は Pro に含まれます。解除するとプレビューが表示されます。
「オービットローダー」は Pro に含まれます。解除するとプレビューが表示されます。