goey-toast

repository·main·Indexed 22 days ago

https://github.com/anl331/goey-toast

A highly animated React toast notification library built on Sonner and Framer Motion, featuring organic blob morphing animations. It supports various toast types, promise-based transitions, and a customizable <GooeyToaster /> container. The library includes a shadcn/ui wrapper and a dedicated CLI for installing AI agent skills.

Tokens
10.4K
Snippets
41
Records
59
Agent score
75%

What's inside goey-toast

  1. Install the shadcn/ui component

    main

    You can install a thin wrapper component at components/ui/goey-toaster.tsx using the shadcn CLI. This command automatically installs goey-toast and framer-motion as dependencies.

    npx shadcn@latest add https://goey-toast.vercel.app/r/goey-toaster.json
  2. Configure peer dependencies for goey-toast

    main

    Ensure you have the following peer dependencies installed in your project:

    PackageVersion
    react>= 18.0.0
    react-dom>= 18.0.0
    framer-motion>= 10.0.0

    Install them using:

    npm install react react-dom framer-motion
  3. Quick Start: Setup and Rendering Toasts

    main

    To use goey-toast, you must complete two required steps:

    1. Mount <GooeyToaster /> once: Place this component near your application root.
    2. Import the stylesheet: You must import goey-toast/styles.css at your application entry point. Failure to do this will result in unstyled toasts.

    Note: While aliases like GoeyToaster and goeyToast exist for backward compatibility with v0.2.x, you should use the double-o versions (GooeyToaster, gooeyToast) in all new code.

    import { GooeyToaster, gooeyToast } from 'goey-toast'
    import 'goey-toast/styles.css' // REQUIRED — import once at app entry
    
    function App() {
      return (
        <>
          <GooeyToaster position="bottom-right" />
          <button onClick={() => gooeyToast.success('Saved!')}>Save</button>
        </>
      )
    }
  4. Install goey-toast Agent Skill for AI coding agents

    main

    To help AI coding agents (like Claude Code or Cursor) understand how to use goey-toast correctly, you can install a bundled Agent Skill. This provides the agent with knowledge about the <GooeyToaster /> mount, the required CSS import, and the full API.

    Install from the skills.sh registry:

    npx skills add anl331/goey-toast

    Alternatively, you can copy the skill directly into your project using the goey-toast CLI:

    • To .claude/skills/goey-toast/SKILL.md: npx goey-toast add-skill
    • To include an AGENTS.md pointer: npx goey-toast add-skill --agents
    • To .cursor/skills/goey-toast: npx goey-toast add-skill --dir .cursor/skills/goey-toast
  5. Quick Start with goey-toast

    main

    To get started, mount the <GooeyToaster /> component in your app and use the gooeyToast object to trigger notifications.

    1. Import GooeyToaster, gooeyToast, and the required CSS.
    2. Add <GooeyToaster /> to your component tree (e.g., in App.tsx).
    3. Call gooeyToast methods (like .success()) to show toasts.
    import { GooeyToaster, gooeyToast } from 'goey-toast'
    import 'goey-toast/styles.css'
    
    function App() {
      return (
        <>
          <GooeyToaster position="bottom-right" />
          <button onClick={() => gooeyToast.success('Saved!')}>
            Save
          </button>
        </>
      )
    }
  6. Import the required CSS stylesheet

    main

    You must import the goey-toast stylesheet in your application's entry point (e.g., main.tsx or App.tsx) for the components to render correctly. Without this import, toasts will appear unstyled.

    import 'goey-toast/styles.css'
  7. Customize GooeyToast animations with presets and spring settings

    main

    You can control the 'gooey' feel of the toast using preset, spring, and bounce props.

    • preset: Uses a predefined animation configuration (e.g., from animationPresets).
    • spring: A boolean to enable/disable spring-based physics animations.
    • bounce: A numeric value (typically 0.0 to 0.8) to control the bounciness of the spring. A value of 0.0 is heavily damped (subtle), while 0.8 is very bouncy (dramatic).
  8. Visual behavior and accessibility of GooeyToast

    main

    The GooeyToast component provides a highly animated, morphing toast UI. Key visual and accessibility features include:

    • Morphing Transitions: The toast morphs between a 'pill' shape and a 'blob' shape when expanding to show body content.
    • Elastic Header: The header undergoes an elastic 'squish' animation during expansion and collapse.
    • Accessibility (ARIA):
      • Toasts with error or warning phases use role="alert" and aria-live="assertive".
      • Other phases use role="status" and aria-live="polite".
      • All toasts use aria-atomic="true".
    • Reduced Motion Support: If the user prefers reduced motion, animations (morphing, squishing, icon transitions) are bypassed or significantly shortened to prevent motion sickness.
    • Swipe-to-Dismiss: Supports touch gestures where swiping horizontally beyond a threshold (SWIPE_THRESHOLD = 100) dismisses the toast.
    • Progress Bar: An optional progress bar can be displayed, which pauses when the user hovers over the toast or its container.
  9. Use GooeyPromiseData for promise-based toasts

    main

    When using promise-based toast functionality, GooeyPromiseData<T> defines how the toast transitions through its lifecycle.

    • loading: A string or ReactNode to display while the promise is pending.
    • success: A string or a function (data: T) => string that resolves when the promise succeeds.
    • error: A string or a function (error: unknown) => string that resolves when the promise fails.
    • description: Can provide specific loading, success, or error ReactNodes.
    • action: Can provide specific GooeyToastAction objects for the success or error states.
    export interface GooeyPromiseData<T> {
      loading: string
      success: string | ((data: T) => string)
      error: string | ((error: unknown) => string)
      description?: {
        loading?: ReactNode
        success?: ReactNode | ((data: T) => ReactNode)
        error?: ReactNode | ((error: unknown) => ReactNode)
      }
      action?: {
        success?: GooeyToastAction
        error?: GooeyToastAction
      }
      // ... other styling/lifecycle props
    }