How to create a toast notification sequence トースト通知シーケンスの作り方
Remotion video template: Success / Warning / Error toasts stack in sequence and auto-dismiss. 1920×1080 / 30fps / 8s. Success / Warning / Error の3種トーストが順番にスタックし自動消去される Remotion 動画テンプレ。1920×1080 / 30fps / 8秒。
ライブデモ Live Demo
Changes saved
Your profile has been updated successfully.
Session expiring
Your session will expire in 5 minutes.
Upload failed
Could not reach the server. Please retry.
概要・用途・特徴Overview, Usage & Features
何ができるかWhat it does
Remotion video template: Success / Warning / Error toasts stack in sequence and auto-dismiss. 1920×1080 / 30fps / 8s.
Success / Warning / Error の3種トーストが順番にスタックし自動消去される Remotion 動画テンプレ。1920×1080 / 30fps / 8秒。
どこで使うかWhere to use
social media content, product demo, marketing video
プロダクトデモ動画、UI紹介、マーケティング素材、機能ショーケース
特徴Key features
Remotion video template showing a sequence of toast notifications appearing one by one. Smooth spring animation entry. Staggered timing across multiple notifications. 1920×1080 / 30fps.
トースト通知が1つずつ順番に表示されるRemotionビデオテンプレート。スムーズなスプリングアニメーション入場。複数通知のスタッガータイミング。1920×1080・30fps。
調整可能パラメータ Adjustable Parameters
| Parameter | Default | Description |
|---|
実装コード Implementation Code
import React from 'react';
import { interpolate, spring } from 'remotion';
import type { ToastDef, ToastType } from '../compositions/ToastDemo';
interface Theme {
text: string;
radius: number;
}
interface ToastProps {
def: ToastDef;
frame: number;
fps: number;
toastWidth: number;
toastY: number;
theme: Theme;
}
// ── Per-type visual config ───────────────────────────────────────────────────
const TYPE_CFG: Record<ToastType, {
bg: string; border: string; iconBg: string;
icon: string; label: string; symbol: string; progress: string;
}> = {
success: {
bg: '#f0fdf4', border: '#86efac', iconBg: '#dcfce7',
icon: '#16a34a', label: '#15803d', symbol: '✓', progress: '#22c55e',
},
warning: {
bg: '#fffbeb', border: '#fde68a', iconBg: '#fef3c7',
icon: '#d97706', label: '#92400e', symbol: '!', progress: '#f59e0b',
},
error: {
bg: '#fef2f2', border: '#fca5a5', iconBg: '#fee2e2',
icon: '#dc2626', label: '#991b1b', symbol: '✕', progress: '#ef4444',
},
};
export const Toast: React.FC<ToastProps> = ({
def, frame, fps, toastWidth, toastY, theme,
}) => {
const { appearFrame, exitFrame, type, title, message } = def;
const cfg = TYPE_CFG[type];
// ── Entrance: spring slide from right ────────────────────────────────────
const entranceSpring = spring({
frame: frame - appearFrame,
fps,
config: { damping: 22, stiffness: 100, mass: 0.9 },
});
// ── Exit: spring slide back right ────────────────────────────────────────
const isExiting = frame >= exitFrame;
const exitSpring = isExiting
? spring({ frame: frame - exitFrame, fps,
config: { damping: 18, stiffness: 120, mass: 0.7 } })
: 0;
const slideX = interpolate(entranceSpring, [0, 1], [toastWidth + 60, 0])
+ interpolate(exitSpring, [0, 1], [0, toastWidth + 80]);
const opacity = interpolate(entranceSpring, [0, 0.4], [0, 1], { extrapolateRight: 'clamp' })
* interpolate(exitSpring, [0, 0.6], [1, 0], { extrapolateLeft: 'clamp' });
// ── Auto-dismiss progress bar ────────────────────────────────────────────
const duration = exitFrame - appearFrame;
const elapsed = Math.max(0, Math.min(frame - appearFrame, duration));
const barWidth = (1 - elapsed / duration) * toastWidth;
return (
<div style={{
position: 'absolute',
top: toastY,
right: 60,
width: toastWidth,
opacity,
transform: `translateX(${slideX}px)`,
background: cfg.bg,
border: `2px solid ${cfg.border}`,
borderRadius: theme.radius,
padding: '20px 22px 16px',
display: 'flex',
gap: 16,
alignItems: 'flex-start',
boxShadow: '0 8px 40px rgba(0,0,0,0.10)',
overflow: 'hidden',
}}>
{/* Icon bubble */}
<div style={{
width: 44, height: 44,
borderRadius: '50%',
background: cfg.iconBg,
display: 'flex', alignItems: 'center', justifyContent: 'center',
fontSize: 22, fontWeight: 800, color: cfg.icon,
flexShrink: 0,
}}>
{cfg.symbol}
</div>
{/* Text */}
<div style={{ flex: 1, minWidth: 0 }}>
<p style={{ fontSize: 20, fontWeight: 700, color: cfg.label, margin: 0, lineHeight: 1.3 }}>
{title}
</p>
<p style={{ fontSize: 16, color: '#374151', margin: '5px 0 0', lineHeight: 1.5 }}>
{message}
</p>
</div>
{/* Dismiss icon (decorative) */}
<div style={{ fontSize: 18, color: '#9ca3af', flexShrink: 0 }}>✕</div>
{/* Auto-dismiss progress bar */}
<div style={{
position: 'absolute',
bottom: 0, left: 0,
height: 4,
width: barWidth,
background: cfg.progress,
}} />
</div>
);
};
/* Global reset for Remotion canvas */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
/*
* Font strategy
* ──────────────────────────────────────────────────────────────────────────
* Default: system-ui — no network dependency, safe for Lambda / CI rendering.
*
* To use Inter in local Remotion Studio, uncomment the @import below.
* For Lambda / serverless rendering, use @remotion/google-fonts or place
* Inter.woff2 in public/ and reference it via staticFile().
*
* @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap');
*/
仕組みとカスタマイズHow It Works & Customization
仕組みHow it works
Each toast is a React component that uses Remotion's spring() to animate opacity and translateY based on frame offset. A sequence array defines each notification's content, type (success/error/info), and start frame. The composition duration is calculated from the last notification's end frame.
各トーストはRemotionのspring()を使用してフレームオフセットに基づいてopacityとtranslateYをアニメーションするReactコンポーネントです。シーケンス配列が各通知のコンテンツ・タイプ(success/error/info)・開始フレームを定義。コンポジションの長さは最後の通知の終了フレームから計算されます。
カスタマイズ方法Customization
Edit the notifications array to change messages, types, and timing. Adjust the spring config (stiffness, damping) for different animation feels. Add an exit animation by reversing the spring on the out-frame.
notificationsArrayを編集してメッセージ・タイプ・タイミングを変更。異なるアニメーション感触のためにspring config(stiffness、damping)を調整。out-frameでspringを逆転させて退場アニメーションを追加。
注意点Caveats
Ensure all text in the animation has sufficient contrast against the background for the video to be readable when shared on social media. Add captions or subtitles for accessibility when sharing the final video.
ソーシャルメディアで共有した際に動画が読めるようにアニメーション内の全テキストが背景に対して十分なコントラストを持つことを確認してください。最終動画を共有する際にアクセシビリティのためにキャプションや字幕を追加してください。
よくある質問 Frequently Asked Questions
How to customize the toast notification sequence? Toast Notification Sequenceをカスタマイズするには?
Modify the CSS custom properties and class styles defined in the code section. Key adjustable values include colors, sizes, durations, and spacing. See the Adjustable Parameters section for specific variables.
コードセクションで定義されているCSSカスタムプロパティとクラススタイルを変更してください。色、サイズ、時間、間隔が主な調整可能値です。具体的な変数は調整可能パラメータセクションを参照してください。
How to use the toast notification sequence in React? ReactでToast Notification Sequenceを使うには?
Import the provided React component and its CSS file. The component accepts props for customization. Check the React code section for the full implementation and available props.
提供されているReactコンポーネントとCSSファイルをインポートしてください。コンポーネントのpropsでカスタマイズできます。完全な実装と利用可能なpropsはReactコードセクションを参照してください。
What are the performance implications of toast notification sequence? Toast Notification Sequenceのパフォーマンスへの影響は?
This implementation uses CSS transforms and opacity for animations, which are GPU-accelerated. It's lightweight and doesn't cause layout thrashing. Consider using prefers-reduced-motion for accessibility.
この実装はCSSのtransformとopacityを使用しており、GPUアクセラレーションされます。軽量でレイアウトスラッシングを引き起こしません。アクセシビリティのためにprefers-reduced-motionの使用を検討してください。
AIへの指示テンプレート AI Prompt Template
以下をAIに貼り付けると実装を依頼できます。 Paste the following into your AI assistant to request implementation.