本文へ移動
日本語
「動く枠線カード」は Pro に含まれます。解除するとプレビューが表示されます。

仕組み

The border is the root's padding showing two background layers: a pointer light over a conic gradient that a registered angle turns, with no spinning oversized element. Most of the conic is the plain border colour and one long arc carries the palette, so at rest the card is calm and its edge only quietly alive. One window listener, throttled to animation frames, writes where on the edge the pointer is closest and how near it is (0 to 1); the border, a blurred glow underneath and a faint wash inside all brighten together as the pointer approaches.

向いている場面

  • The one recommended option among several, such as a plan or a template.
  • A featured card that should invite the pointer without shouting.

向かない場面

  • Every card in a grid: the highlight loses its meaning.
  • Error or warning states: use a plain coloured border.

使い方

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

export function RecommendedPlan() {
  return (
    <AnimatedBorderCard as="article" palette="aurora" speed={8} proximity={160}>
      <div style={{ padding: 24 }}>
        <h3>Studio</h3>
        <p>For small teams shipping every week.</p>
      </div>
    </AnimatedBorderCard>
  )
}

プロパティ

プロパティ型既定値説明
childrenReactNode—Card content; give it its own padding.
palette'aurora' | 'sunset' | 'mono''aurora'Colours of the travelling arc.
speednumber8Seconds per full turn (minimum 1).
borderWidthnumber1.5Border thickness in px.
proximitynumber160Distance in px at which the pointer starts to light the border; 0 turns it off.
glowbooleantrueSoft coloured glow under the card.
asElementType'div'Root element.

アクセシビリティ

  • Purely decorative: the border, glow and pointer light carry no information, and the card renders its children unchanged.
  • The pointer effect listens passively and only on devices that hover; keyboard and touch users see the turning border alone.
  • Forced-colors mode draws a solid border in the text colour.
  • Reduced motion stops the turn and parks the arc on the top-right edge; the pointer light still responds, without movement.

モーション

The arc turns linearly once every 8s (adjustable), which reads as a slow drift. The glow under the card eases between strengths over 360ms; the pointer light follows every animation frame.

プロジェクトに追加

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

AnimatedBorderCard.jsxanimated-border-card.csstokens.cssREADME.md

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

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