UI/Components/Card elements/Toast Card

Toast Card

A Remotion video component that animates a toast notification with customizable entry, visible, and exit phases, and flexible positioning.

Notification?

Could be used as an interview notification.

0:00 / 0:07

Installation

CLI

COMING SOON

Installation via npx shadcnui install clipkittt@toast-card isn't quite ready yet. For now, please follow the manual installation instructions.

Eventually users will be able to run the following command:

npx shadcn@latest add "https://clippkit/r/toast-card"

Manual

Create a new file, for example, at src/components/toast-card.tsx (or your preferred location) and paste the code from apps/docs/registry/default/ui/toast-card.tsx into it.

Update the import paths in your Remotion compositions if you placed the file in a different location than shown in the usage examples.

Usage

Once the ToastCard component is added to your project, you can integrate it into your Remotion project by importing it and using it within a Composition or directly with the @remotion/player.

Prerequisite

Ensure you have a Remotion project set up. If not, please refer to the Remotion documentation to get started.

Example with Player:

This example shows how to use ToastCard with @remotion/player for a quick preview or standalone use. You can adapt the inputProps to customize the toast.

src/MyToastPlayer.tsx (or equivalent)
import { Player } from "@remotion/player";

import ToastCard from "../ui/toast-card"; // Adjust path as necessary

export default function MyToastPlayer() {
  const toastProps = {
    title: "Update Available",
    message: "A new version of the software is ready to install.",
    backgroundColor: "oklch(0.7 0.15 250)", // A nice blue
    titleColor: "#FFFFFF",
    messageColor: "#F0F0F0",
    positionPreset: "top-right" as const,
    entryDurationInFrames: 30,
    visibleDurationInFrames: 180, // Show for 6 seconds at 30 FPS
    exitDurationInFrames: 30,
    width: "350px",
  };

  const totalDuration =
    toastProps.entryDurationInFrames +
    toastProps.visibleDurationInFrames +
    toastProps.exitDurationInFrames +
    60; // Extra 60 frames buffer

  return (
    <Player
      component={ToastCard}
      inputProps={toastProps}
      durationInFrames={totalDuration}
      compositionWidth={1280} // Typical video width
      compositionHeight={720} // Typical video height
      fps={30}
      style={{
        width: "100%",
        height: "100%",
        backgroundColor: "var(--background-alt)", // A slightly different background
      }}
      autoPlay
      controls
      loop
    />
  );
}

API Reference

The component exported as ToastCard (e.g., from apps/docs/registry/default/ui/toast-card.tsx or your project's component path) accepts the following props to customize its animation and appearance:

PropTypeDefault ValueDescription
titlestring"Success!"The main title text for the toast.
messagestring"Your action was completed."The secondary message text for the toast.
titleColorstring"var(--card-foreground)"CSS color for the title text.
messageColorstring"var(--card-foreground)"CSS color for the message text.
backgroundColorstring"var(--card)"CSS background for the toast card.
titleFontSizestring"1.1rem"CSS font size for the title.
messageFontSizestring"0.9rem"CSS font size for the message.
widthstring"300px"CSS width of the toast card.
paddingstring"15px 20px"CSS padding inside the toast card.
borderRadiusstring"10px"CSS border radius of the toast card.
borderColorstring"var(--border)"CSS border color of the toast card.
borderWidthstring"1px"CSS border width of the toast card.
borderStyle"solid" | "dashed" | "dotted""solid"CSS border style of the toast card.
boxShadowstring"0 4px 12px rgba(0,0,0,0.1)"CSS box shadow for the toast card.
positionPresetPositionPreset"bottom-left"Predefined position: "bottom-left", "bottom-right", "top-left", "top-right", "center".
marginstring"20px"Outer margin for the toast when not centered (e.g., distance from screen edges).
entryDurationInFramesnumber30Duration of the entry animation (slide-in, fade-in) in frames.
visibleDurationInFramesnumber120Duration the toast remains fully visible on screen in frames.
exitDurationInFramesnumber30Duration of the exit animation (slide-out, fade-out) in frames.
dampingnumber15Damping for the spring animations. Controls how quickly oscillations die down.
massnumber0.8Mass for the spring animations.
stiffnessnumber120Stiffness for the spring animations.
fontFamilystring"Inter, sans-serif"CSS font family for the text in the toast.
slideOffsetnumber50The distance (in pixels) the toast slides during entry/exit animations (for non-center positions).

Type Definition for PositionPreset

type PositionPreset =
  | "bottom-left"
  | "bottom-right"
  | "top-left"
  | "top-right"
  | "center";

On this page