效能
需注意幀率: 平均 60 fps,p5 59.5 · 長任務: 0 個,共 0 毫秒,最長 0 毫秒 · 原始碼 gzip 6.2 KB · 執行時 276 KB
Toast stackMIT通知Bencho
由 Lorenzo Cabra 製作的通知 React 元件。依據 MIT 授權從 Bencho 原樣收錄,此處為即時預覽。
品質報告
等級和分數來自建置或測試時跑過的自動檢查。沒跑過的項目會標成「未檢測」,不會填假資料。
幀率: 平均 60 fps,p5 59.5 · 長任務: 0 個,共 0 毫秒,最長 0 毫秒 · 原始碼 gzip 6.2 KB · 執行時 276 KB
問題 1 · 讀屏: 通過
沒有持續動效
無溢出
幀率和長任務是在無介面的 Chromium 裡用軟體 WebGL 測的,只適合在本站元件之間比較,不代表實機表現。
不適用:靜止時沒有可見動畫;由懸停觸發的動畫沒有測試。

檢測於 2026年11月15日 · 資料來自自動腳本,不是手工填寫。
以實際尺寸顯示。
複製內容以授權聲明開頭,使用程式碼時請保留。
<div id="root"></div>:root{--bg:#f6f4f0;--ink:#17181a;--background:40 20% 96%;--foreground:24 10% 8%;--card:0 0% 100%}html,body{min-height:100%;margin:0;background:var(--bg);color:var(--ink)}html,body{height:100%;overflow:hidden}body{display:grid;place-items:center}#root{display:grid;place-items:center;max-width:100%;max-height:100%;box-sizing:border-box;padding:16px;color:hsl(var(--foreground))}#root.full{width:100%;height:100%;padding:0}@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation-play-state:paused!important;transition-duration:0s!important}}
/*
MIT License
Copyright (c) 2026 Lorenzo Cabra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Not covered by this licence: the Bencho name and the goat mark, and the
photographs shown on bencho.dev (none are included here). Third-party
material keeps its own licence; see THIRD_PARTY.md.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
Sample photographs were replaced with Incidental AI assets. The Bencho name and goat mark are not licensed for marketing use.
*/
/* ── Bencho tokens ─────────────────────────────────────────
The custom properties the free blocks read, at the values
bencho.dev draws them with. Light by default; dark under
[data-theme="dark"] on any ancestor, or automatically with
the system setting unless [data-theme="light"] says otherwise.
Map these to your own theme rather than keeping two: a block
only ever reads the names, never the values. */
:root {
--font-ui: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
--bg: #ffffff;
--board: #ffffff;
--card: #f7f7f6;
--surface: #f7f7f6;
--surface-2: #f1f1f0;
--surface-3: #ecebe7;
--ink: #17181a;
--ink-rgb: 23, 24, 26;
--ink-2: #3c3b37;
--ink-3: #5c5b56;
--ink-4: #6f6e68;
--ink-5: #85847e;
--on-ink: #ffffff;
--on-ink-rgb: 255, 255, 255;
--slab: #17181a;
--on-slab: #ffffff;
--slab-dark: #0e0f11;
--fill-slab: #ffffff;
--fill-on: #17181a;
--fill-on-rgb: 23, 24, 26;
--pane: var(--fill-slab);
--pane-edge: rgba(23, 24, 26, 0.08);
--pane-thumb: rgba(23, 24, 26, 0.07);
--inlay: rgba(255, 255, 255, 0.55);
--inlay-hi: rgba(23, 24, 26, 0.09);
--elev-rgb: 255, 255, 255;
--glass-rgb: 255, 255, 255;
--shadow-rgb: 23, 24, 26;
--wash: 0.06;
--pick: #0d99ff;
--signal: #2231dd;
--focus: #2231dd;
--ok: #15803d;
--ember: #b8431c;
color-scheme: light;
}
[data-theme="dark"] {
--bg: #000000;
--board: #1a1a1a;
--card: #0a0a0a;
--surface: #0f0f0f;
--surface-2: #181818;
--surface-3: #202020;
--ink: #ffffff;
--ink-rgb: 255, 255, 255;
--ink-2: #b4b4b4;
--ink-3: #9a9a9a;
--ink-4: #828282;
--ink-5: #6b6b6b;
--on-ink: #000000;
--on-ink-rgb: 0, 0, 0;
--slab: #1a1a1a;
--on-slab: #ffffff;
--slab-dark: #262626;
--fill-slab: #262626;
--fill-on: #ffffff;
--fill-on-rgb: 255, 255, 255;
--pane-edge: rgba(255, 255, 255, 0.08);
--pane-thumb: rgba(255, 255, 255, 0.07);
--inlay: rgba(255, 255, 255, 0.1);
--inlay-hi: rgba(255, 255, 255, 0.09);
--elev-rgb: 32, 32, 32;
--shadow-rgb: 0, 0, 0;
--wash: 0.09;
--pick: #3aa9ff;
--ok: #34d17a;
color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) {
--bg: #000000;
--board: #1a1a1a;
--card: #0a0a0a;
--surface: #0f0f0f;
--surface-2: #181818;
--surface-3: #202020;
--ink: #ffffff;
--ink-rgb: 255, 255, 255;
--ink-2: #b4b4b4;
--ink-3: #9a9a9a;
--ink-4: #828282;
--ink-5: #6b6b6b;
--on-ink: #000000;
--on-ink-rgb: 0, 0, 0;
--slab: #1a1a1a;
--on-slab: #ffffff;
--slab-dark: #262626;
--fill-slab: #262626;
--fill-on: #ffffff;
--fill-on-rgb: 255, 255, 255;
--pane-edge: rgba(255, 255, 255, 0.08);
--pane-thumb: rgba(255, 255, 255, 0.07);
--inlay: rgba(255, 255, 255, 0.1);
--inlay-hi: rgba(255, 255, 255, 0.09);
--elev-rgb: 32, 32, 32;
--shadow-rgb: 0, 0, 0;
--wash: 0.09;
--pick: #3aa9ff;
--ok: #34d17a;
color-scheme: dark;
}
}
/* ToastStack.css */
/*
MIT License
Copyright (c) 2026 Lorenzo Cabra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Not covered by this licence: the Bencho name and the goat mark, and the
photographs shown on bencho.dev (none are included here). Third-party
material keeps its own licence; see THIRD_PARTY.md.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
Sample photographs were replaced with Incidental AI assets. The Bencho name and goat mark are not licensed for marketing use.
*/
/* ══ Toast stack (lab/ToastStack.tsx) ══════════════════════════
Three toasts stacked, fanning into a list on hover. Tones are the
reference's: the front one white, the tucked ones a barely-there
2% grey — both the same, so they read as paper behind paper rather
than a darkening ramp. Where the reference separates them with a
soft shadow, this uses a faint hairline (no drop shadows on the
bench). Status icons are their own solid colours, never faded. */
.tst {
position: relative;
font-family: var(--font-ui);
color: var(--fill-on, var(--ink));
--tst-mute: color-mix(in srgb, var(--fill-on, #17181a) 52%, var(--fill-slab, #ffffff));
--tst-wash: color-mix(in srgb, var(--fill-on, #17181a) 6%, var(--fill-slab, #ffffff));}
.tst-toast {
position: absolute;
left: 0;
top: 0;
width: 100%;
box-sizing: border-box;
display: flex;
align-items: center;
gap: 12px;
padding: 0 12px 0 16px;
border-radius: var(--tst-r);
background: var(--fill-slab, #ffffff);
transform-origin: 50% 0;
transition: background-color 220ms ease, box-shadow 220ms ease;}
/* tucked: the same near-white for both, and a faint edge so each
sliver has a line to read by */
.tst:not([data-open]) .tst-toast:not([data-front]) {
background: color-mix(in srgb, var(--fill-on, #17181a) 6%, var(--fill-slab, #ffffff));
box-shadow: 0 0 0 1px color-mix(in srgb, var(--fill-on, #17181a) 6%, transparent);}
[data-stroke="on"] .tst-toast { box-shadow: 0 0 0 1px var(--pane-edge); }
/* only the front one is read while stacked; the rest are slivers */
.tst-toast > * { transition: opacity 220ms ease; }
.tst:not([data-open]) .tst-toast:not([data-front]) > * { opacity: 0; }
.tst-icon { flex: none; display: grid; place-items: center; }
.tst-toast[data-kind="success"] .tst-icon { color: #1f9d55; }
.tst-toast[data-kind="error"] .tst-icon { color: #e5484d; }
.tst-toast[data-kind="warning"] .tst-icon { color: #e09a12; }
.tst-toast[data-kind="info"] .tst-icon { color: var(--tst-mute); }
.tst-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tst-text b { font-size: 14px; font-weight: 500; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.01em; }
.tst-text span { font-size: 13px; line-height: 17px; color: var(--tst-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0em; }
.tst-act {
flex: none;
height: 28px;
padding: 0 12px;
border: 0;
border-radius: 999px;
background: var(--tst-wash);
color: inherit;
font: inherit;
font-size: 13px;
font-weight: 500;
cursor: pointer;
transition: scale 160ms cubic-bezier(0.22, 1, 0.36, 1);
letter-spacing: 0em;}
.tst-act:active { scale: 0.96; }
.tst-x {
flex: none;
width: 28px;
height: 28px;
display: grid;
place-items: center;
border: 0;
border-radius: 999px;
background: none;
color: var(--tst-mute);
cursor: pointer;
transition: background-color 160ms ease, color 160ms ease;}
.tst-x:hover { background: var(--tst-wash); color: var(--fill-on, var(--ink)); }
.tst-act:focus-visible, .tst-x:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--signal, #2231dd); }
// bencho source (MIT). npm i @tabler/icons-react motion react · Tailwind CSS v4
// ── blocks/toast-stack/ToastStack.tsx (https://github.com/cabralorenzo/bencho/blob/c65992417427bb09e661674ffa800bef29adef49/blocks/toast-stack/ToastStack.tsx)
/*
MIT License
Copyright (c) 2026 Lorenzo Cabra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Not covered by this licence: the Bencho name and the goat mark, and the
photographs shown on bencho.dev (none are included here). Third-party
material keeps its own licence; see THIRD_PARTY.md.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
Sample photographs were replaced with Incidental AI assets. The Bencho name and goat mark are not licensed for marketing use.
*/
import { type CSSProperties, useRef, useState } from "react";
import { motion } from "motion/react";
import { IconCircleCheck as CircleCheck, IconCircleX as CircleX, IconInfoCircle as Info, IconAlertTriangle as TriangleAlert, IconX as X } from "@tabler/icons-react";
/* ══ Toast stack ══════════════════════════════════════════
Three toasts, always: the newest in front, the two before it
tucked behind with a sliver of each showing above it, a step
smaller each and a barely-there grey (the reference's tones). Point at the stack and it
fans out into a list; move away and it gathers back up.
── ONE SPRING, THREE PLACES ────────────────────────────
A toast's place is worked out from how far back it is and
whether the stack is open, and Framer springs it there. Opening,
closing, a toast leaving and the next arriving are all the same
move — every toast heading for its new place on the same spring,
a touch under critical so it settles with a hint of give.
── HOVER IS THE WHOLE FRAME ────────────────────────────
The stack opens about its middle, so the front toast moves when
it opens. Hovering the toasts themselves would let the list slide
out from under the pointer and close again; the frame is the
list's own size, so hovering it is hovering the list. Pointer
over/out with a containment test rather than enter/leave, so the
wall's demonstration — which dispatches its own pointer events,
and leaves with no relatedTarget — opens and closes it too (the
tilt card's note has the long version).
── IT NEVER RUNS OUT ───────────────────────────────────
Dismiss one and it slides away; a new one rises in at the front
from the pool, so there are always three. Retry on the failed
payment turns that toast into the payment going through, in
place. */
type Kind = "success" | "info" | "error" | "warning";
type Toast = { id: number; kind: Kind; title: string; body: string; action?: string };
const ICON: Record<Kind, LucideIcon> = {
success: CircleCheck,
info: Info,
error: CircleX,
warning: TriangleAlert,
};
const POOL: Omit<Toast, "id">[] = [
{ kind: "error", title: "Payment declined", body: "Try another card.", action: "Retry" },
{ kind: "info", title: "Kai joined your bench", body: "They can comment and copy." },
{ kind: "success", title: "brand-kit.zip uploaded", body: "Saved to Launch week." },
{ kind: "warning", title: "Storage is 92% full", body: "Exports pause at the limit." },
{ kind: "success", title: "Block saved", body: "Swipe deck is in Favourites." },
];
const W = 300;
const H = 64;
const SHOWN = 3;
/* a touch under critical: it settles with a hint of give, no wobble */
const SPRING = { type: "spring", stiffness: 380, damping: 34, mass: 1 } as const;
export function ToastStack({
peek = 14,
gap = 10,
corner = 20,
}: {
peek?: number;
gap?: number;
corner?: number;
}) {
/* front first; ids count up so a returning toast is a new element */
const next = useRef(SHOWN);
const [stack, setStack] = useState<Toast[]>(() =>
POOL.slice(0, SHOWN).map((t, i) => ({ ...t, id: i })),
);
const [leaving, setLeaving] = useState<number | null>(null);
const [open, setOpen] = useState(false);
const root = useRef<HTMLDivElement | null>(null);
/* the frame is the open list's size; both states sit in its middle */
const listH = SHOWN * H + (SHOWN - 1) * gap;
const stackH = H + (SHOWN - 1) * peek;
const FH = listH;
const place = (k: number) => {
if (open) {
/* the list: front at the bottom, the rest above it */
const top = (FH - listH) / 2;
return { y: top + (SHOWN - 1 - k) * (H + gap), scale: 1 };
}
/* the stack: front at the bottom, each one behind a peek higher
and a step smaller, hanging from its top edge */
const top = (FH - stackH) / 2;
const d = Math.min(k, SHOWN - 1);
return { y: top + (SHOWN - 1 - d) * peek, scale: 1 - d * 0.05 };
};
const dismiss = (id: number) => {
if (leaving !== null) return;
setLeaving(id);
window.setTimeout(() => {
setStack((s) => {
const rest = s.filter((t) => t.id !== id);
const n = next.current++;
const fresh = { ...POOL[n % POOL.length], id: n };
return [fresh, ...rest];
});
setLeaving(null);
}, 220);
};
const retry = (id: number) => {
setStack((s) => s.map((t) => (t.id === id
? { ...t, kind: "success", title: "Payment complete", body: "Your card was charged.", action: undefined }
: t)));
};
return (
<div
ref={root}
className="tst"
role="region"
aria-label="Notifications"
data-open={open || undefined}
style={{ width: W, height: FH, ["--tst-r" as string]: `${corner}px` } as CSSProperties}
onPointerOver={() => setOpen(true)}
onPointerOut={(e) => {
const to = e.relatedTarget as Node | null;
if (!to || !root.current?.contains(to)) setOpen(false);
}}
onFocus={() => setOpen(true)}
onBlur={(e) => { if (!root.current?.contains(e.relatedTarget as Node | null)) setOpen(false); }}
>
{stack.map((t, k) => {
const Icon = ICON[t.kind];
const out = leaving === t.id;
const p = place(k);
const front = k === 0;
return (
<motion.div
key={t.id}
className="tst-toast"
data-kind={t.kind}
data-front={front || undefined}
style={{ height: H, zIndex: SHOWN - k }}
/* a new one rises in from below the front */
initial={{ y: place(0).y + 24, scale: 1, opacity: 0, x: 0 }}
animate={out
? { y: p.y, scale: p.scale, opacity: 0, x: 60 }
: { y: p.y, scale: p.scale, opacity: 1, x: 0 }}
transition={out ? { duration: 0.22, ease: [0.4, 0, 1, 1] } : SPRING}
aria-hidden={!open && !front ? true : undefined}
>
<span className="tst-icon"><Icon size={18} strokeWidth={2} aria-hidden="true" /></span>
<span className="tst-text">
<b>{t.title}</b>
<span>{t.body}</span>
</span>
{t.action && (
<button type="button" className="tst-act" tabIndex={open || front ? 0 : -1} onClick={() => retry(t.id)}>
{t.action}
</button>
)}
<button
type="button"
className="tst-x"
aria-label={`Dismiss ${t.title}`}
tabIndex={open || front ? 0 : -1}
onClick={() => dismiss(t.id)}
>
<X size={16} strokeWidth={2} aria-hidden="true" />
</button>
</motion.div>
);
})}
</div>
);
}控制項 · HTML · CSS · JS
直接改程式碼,再用控制項微調,預覽會隨輸入即時更新。

線上編輯每個元件,用控制項微調,下載完整原始碼,複製進階提示詞。
一次性 $49暫定價格
測試模式:不會真的扣款。
免費:預覽、複製按鈕和課程說明。
一個圖示、一句話和清楚的顏色,告訴人發生了什麼。
儲存提示、錯誤、警告和簡短確認。
按狀態改顏色,調圓角和入場動效。
把 Bencho (github.com/cabralorenzo/bencho)(MIT)中的「疊式提示」元件加入我的 React + Tailwind CSS 應用程式。原始檔:https://github.com/cabralorenzo/bencho/blob/c65992417427bb09e661674ffa800bef29adef49/blocks/toast-stack/ToastStack.tsx。一個圖示、一句話和清楚的顏色,告訴人發生了什麼。 適用情境:儲存提示、錯誤、警告和簡短確認。 可調參數:按狀態改顏色,調圓角和入場動效。 支援淺色與深色主題,遵循 prefers-reduced-motion。保留 MIT 授權聲明。
更完整的提示詞,包含調參、無障礙和接入步驟。