本文へ移動
日本語
「ビームボーダー」は Pro に含まれます。解除するとプレビューが表示されます。

仕組み

A track is laid over the container: its padding equals the border width and a mask removes the content box, leaving a faint ring. The beam is 12 dots, each moving at constant speed along offset-path: rect(), so length stays constant and the beam bends around corners. A second, blurred copy of the dots runs the same path in a layer masked to the outside of the border, so the head casts a halo on the surface around the container without ever covering its content. Browsers without rect() fall back to a rotating conic gradient.

向いている場面

  • The input of an AI assistant or chat entry, to say “ready, start typing”.
  • The recommended plan on a pricing page.
  • The entry card of a new feature, to draw attention for a short time.

向かない場面

  • Several beams on one screen: attention is split, so use at most one.
  • Form errors and warnings: the beam is decorative and cannot express severity; use colour and text.
  • Workspaces people stay on for long: constant motion tires the eye; start it only on focus or hover.

使い方

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

export function PlanCard() {
  return (
    <BorderBeam radius={16} duration={6} colorFrom="#f97316" colorTo="#ec4899" style={{ padding: 20, background: '#fff' }}>
      <h3>Yearly plan</h3>
      <p>$198 / year · 4 free upgrades a month</p>
    </BorderBeam>
  )
}

プロパティ

プロパティ型既定値説明
durationnumber6Seconds per lap.
beamSizenumber90Beam length in px, measured along the border, whatever the container shape.
colorFromstring'#6366f1'Colour of the beam head.
colorTostring'#a855f7'Colour of the beam tail, which then fades to transparent.
borderWidthnumber1.5Border width in px. The container's inner padding must be larger.
radiusnumber16Corner radius in px, shared by the container and the beam track.
reversebooleanfalseCircles counter-clockwise.
delaynumber0Animation delay in seconds. With several beams on screen, use negative values to stagger the start.
glowbooleantrueAdds a soft halo outside the border that follows the beam head. It is masked to the outside of the container, so it never covers the content.
childrenReactNode—Container content. The container sets no background or shadow; use style or className.
...restHTMLAttributes<HTMLDivElement>—Other attributes go to the root <div>.

アクセシビリティ

  • The track, beam and glow are aria-hidden decoration with pointer-events: none, so clicks and screen readers are unaffected.
  • With reduced motion the beam and glow stop and a static gradient outline is shown, which still marks the element as emphasised.
  • No information depends on the animation.

モーション

One lap takes 6s by default at constant speed (linear, as a loop must). There is no enter or exit animation.

プロジェクトに追加

Pro メンバーはプロンプトをコピーし、コーディングエージェントが無料コンポーネントと同じ手順でソースを導入します。

BorderBeam.jsxborder-beam.csstokens.cssREADME.md

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

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