Components / Feedback
Island Toast
A black pill that morphs open to show a message, then shrinks back to rest.
Installation
Requires React 18+ and Tailwind CSS.
- 1
Install dependencies
$ npm install motion - 2
Add the component
Copy the code from the Code tab above into
components/ui/island-toast.tsx. - 3
Use it
example.tsx"use client"; import { useState } from "react"; import { IslandToast, type IslandMessage } from "@/components/ui/island-toast"; const messages: { label: string; message: IslandMessage }[] = [ { label: "Headphones", message: { icon: "π§", title: "Headphones connected", description: "Battery 87%" } }, { label: "Payment", message: { icon: "π³", title: "Payment sent", description: "$42.00 to Sam" } }, { label: "Silent", message: { icon: "π", title: "Silent mode on" } }, ]; export default function IslandToastDemo() { const [message, setMessage] = useState<IslandMessage | null>(null); return ( <div className="flex flex-col items-center gap-10"> <IslandToast message={message} onDismiss={() => setMessage(null)} /> <div className="flex flex-wrap justify-center gap-2"> {messages.map((m) => ( <button key={m.label} type="button" onClick={() => setMessage(m.message)} className="rounded-lg border border-white/10 bg-zinc-900 px-3 py-1.5 text-sm text-zinc-200 transition hover:bg-zinc-800 hover:text-white" > {m.label} </button> ))} </div> </div> ); }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| message | { title; description?; icon? } | null | β | Message to show; null shows the idle pill. |
| onDismiss | () => void | β | Called when the message should close. Set message to null here. |
| duration | number | 3000 | Milliseconds the message stays open. |