AI Toast提示生成器。

描述你的通知行为,MeDo即可生成完整的Toast系统 — 四种语义类型、堆叠队列、悬停时暂停的自动消失计时器、触摸滑动关闭,以及为每种类型配置正确的aria-live播报级别。

轻提示
轻提示

Toast本质上是一个伪装成小方块的计时器、队列和live region

Toast的视觉部分几分钟就能做完,底层的东西却不然。Toast必须决定停留多久、三条同时到达时怎么办、用户正在填表途中怎么办,以及屏幕阅读器如何在不被打断的情况下播报它。不太明显的后果是:Toast的缺陷会表现为信任的缺陷 — 保存确认还没读完就消失,或者用户正在看对应字段时错误提示就不见了,这会让人学会不再相信界面。把计时规则、队列上限和live region播报级别一起生成,能让这些决策保持一致,而不是散落在每个触发通知的调用点上。

6 个模板

可以生成的 轻提示 模板

每个模板都是真实的提示词,而不是截图。复制到任意 AI 编辑器,或在 MeDo 中运行,直接拿到 React + Tailwind 代码。

BasicFour Tones

Success, Error, Warning, Info Stack

The baseline set, and the only one where per-type rules matter more than styling. Errors that auto-dismiss are the single most common toast bug in production.

Create a toast system with four semantic types — success with a check icon and green accent, error with an alert icon and red accent, warning with a triangle and amber accent, info with a circle and blue accent. Each toast is 360px wide with a 12px radius, 16px padding, a semibold title, an optional description and a close button with an accessible label. Stack in the bottom-right with 8px gaps, newest on top, three visible at once and the rest queued. Auto-dismiss success, info and warning after 5000ms; keep errors until the user closes them. Wrap non-error toasts in role="status" with aria-live="polite" and give errors role="alert". Slide in 16px from the right and fade out; under prefers-reduced-motion, fade only.

在 MeDo 中尝试
TimingPausable Timer

Countdown Bar That Freezes on Hover

A visible progress bar plus a timer that stops while the pointer or keyboard focus is on the toast. Without the pause, a toast can vanish while the user is reaching for its own action button.

Create a toast with a visible dismiss countdown: a 2px progress bar along the bottom edge animating from full to zero over the toast duration. Pause the timer and freeze the bar on pointerenter and on focusin anywhere inside the toast, then resume from the remaining time on pointerleave and focusout — track elapsed time explicitly rather than restarting the interval, or the toast will live longer every time the pointer crosses it. Reset to the full duration when the toast content is updated in place. Under prefers-reduced-motion, replace the animated bar with a static severity stripe and keep the timer behaviour unchanged. Keep the toast in a role="status" region with aria-live="polite".

在 MeDo 中尝试
UndoAction Toast

Toast With an Undo or Retry Action

The moment a toast carries a button, it stops being decoration and becomes the only route to a reversible operation — so it must not auto-dismiss while the action is still valid.

Create a toast variant with a single inline action button — Undo or Retry — beside the close control. Do not auto-dismiss while an action is present unless the caller passes an explicit duration, and never dismiss on a timer shorter than the window in which the action is still valid server-side. Move keyboard focus nowhere on mount; instead expose the toast region via a landmark and make the action reachable through a documented shortcut plus normal tab order, so a toast never steals focus from a form the user is typing in. Announce the toast with role="status" and aria-live="polite", and include the action label in the announced text so the option is heard, not just seen.

在 MeDo 中尝试
AsyncPromise Toast

One Toast That Updates in Place

Pending, then success or error, on the same node. Firing a second toast when a request resolves stacks two notifications about one event and doubles the screen reader announcement.

Create a promise-driven toast that mounts in a pending state with a spinner and a loading title, then updates the same toast node to success or error when the promise settles rather than mounting a second toast. Keep the toast ID stable across the transition so the stack position does not change, swap the icon and accent, and start the auto-dismiss timer only once the promise resolves. On rejection, switch the container to role="alert" and cancel auto-dismiss. Because the live region content changes in place, debounce the announcement so a request that resolves in under 400ms announces the final state only. Cap the pending state with a timeout that converts to an error toast rather than spinning forever.

在 MeDo 中尝试
MobileSwipe Toast

Top-Center Toast With Swipe Dismiss

On a phone the bottom corner is under the thumb and the home indicator. Top-center with a horizontal drag threshold is the only placement that does not fight the platform.

Create a mobile-first toast pinned to the top-center with a safe-area inset using env(safe-area-inset-top), full width minus 16px gutters, capped at a single line of title text with the description truncated to two lines. Add horizontal swipe-to-dismiss with a 60px or 40% drag threshold, translating with the pointer and springing back below the threshold; suppress the pointer handlers while the user is scrolling the page underneath. Keep the close button hit area at 44px even though the glyph is 16px. Show one toast at a time and replace rather than stack, since a stack on a 375px viewport covers the content. Use role="status" with aria-live="polite" and disable the spring under prefers-reduced-motion.

在 MeDo 中尝试
SnackbarCompact Snackbar

Single-Line Bar With No Icon

One line, no title, no icon — for low-stakes confirmations like "Link copied" where a 360px card with an icon block is more furniture than the message deserves.

Create a compact snackbar toast: a single line of 14px text on a dark surface, 8px radius, 12px vertical and 16px horizontal padding, no icon and no separate title, with an optional text-only action on the right. Anchor it bottom-center with a 24px offset and allow only one at a time — a new snackbar replaces the current one and resets its 4000ms timer instead of queueing, because these fire from rapid interactions like copy and toggle. Announce via role="status" with aria-live="polite", and when the text is identical to the previous message, force re-announcement by clearing the live region for one frame. Fade and lift 8px on entry; fade only under prefers-reduced-motion.

在 MeDo 中尝试

如何自定义你的 轻提示

给错误类型设置不同于其他类型的规则

要求success、info和warning自动消失,而错误提示保留到用户手动关闭。错误通常需要用户采取行动,一条在被理解之前就自行消失的消息,比没有消息更糟。

设定堆叠上限并说明溢出如何处理

明确同时可见的Toast数量 — 三条是合理的上限 — 以及超出的部分是排队等待还是替换最旧的一条。没有上限时,逐条触发通知的循环会把整个视口糊满。

要求计时器在悬停和聚焦时暂停

在提示词中要求:只要指针停留在Toast上,或其内部控件获得键盘焦点,消失倒计时就冻结。否则Toast可能在用户正要点击它自己的操作按钮时消失。

指明摆放的角落和安全区域

选定一个位置并描述清楚:右下角远离大多数主导航,顶部居中最容易被快速读到。移动端请要求加上env(safe-area-inset-bottom)内边距,避免Toast落到主屏指示条或固定标签栏下面。

谁在使用 轻提示 组件

SaaS产品

用简短的成功提示确认自动保存和邀请发送,后台同步失败时用带"重试"操作的常驻错误提示。右下角的位置可避开应用侧边栏。

电商店铺

带缩略图和"查看购物车"链接的"已加入购物车"提示,五秒后消失。库存和支付失败使用错误类型并保持显示,让购物者能读清出了什么问题。

仪表盘或管理后台

批量操作只发出一条汇总提示,而不是每条记录一条;长时间运行的任务在原位把同一条Toast从处理中更新为成功,而不是在上面再叠一条通知。

移动端Web应用

顶部居中的Toast,支持滑动关闭并适配安全区域内边距,尺寸控制在单行,确保绝不遮挡用户正在输入的字段。

不同网站的 轻提示 方案

同一个 轻提示 组件,针对它所在网站的类型做调整。

01 / 06

SaaS Product Toasts

Autosave confirmations and invite receipts, bottom-right so they clear the sidebar. The rule that matters most here is that background-sync failures get persistent error toasts with a Retry action — a sync error that dismisses itself is indistinguishable from a sync that worked.

轻提示 的风格与变体

挑选与页面其余部分匹配的变体,然后生成它。

01 / 06

Card Toast With Icon and Accent

The full anatomy: icon, semibold title, description, close button, colored accent. Worth the vertical space when the message has a subject and a detail. It is overkill for "Copied" — use the snackbar for those.

在 React、Next.js、Vue 与 Svelte 中使用 轻提示

React、Next.js、Vue 3、SvelteKit、Astro 或纯 HTML —— 同一个 轻提示,六种接入方式。

01 / 06

React Toast

A context provider holding the queue plus a portal for the container. Mount the provider once above the router so navigating between routes does not unmount the toast that was just fired.

src/components/ToastProvider.tsx

export function ToastProvider({ children }) {
  const [toasts, setToasts] = useState([])
  const push = (t) => setToasts((prev) => [...prev, { id: uid(), ...t }])

  return (
    <ToastContext.Provider value={{ push }}>
      {children}
      {createPortal(<ToastStack toasts={toasts} />, document.body)}
    </ToastContext.Provider>
  )
}

如何把 轻提示 加入项目

四个步骤,从挑选 轻提示 模板到上线生产环境。

01~30s

Pick a Toast Pattern

Choose by the event, not the look: the four-tone stack for general notifications, the promise toast for async jobs, the action toast for anything reversible, the swipe variant for phone-first surfaces.

02~10s

Copy the Prompt

Take it into MeDo, Lovable, Bolt, v0 or Cursor. Set the duration and the stack limit before you run it, and decide there whether errors auto-dismiss — that is the decision you will otherwise relitigate at every call site.

03~1min

Generate and Refine

You get the provider, the queue and the toast back with a live preview. Follow up in plain English — "pause the timer on hover", "move it to top-center on mobile", "cap the stack at two" — instead of hand-editing timer logic.

04~2min

Mount the Provider Once

Put it above the router in your root layout so a toast fired just before a navigation survives it, then fire one from a real form submit and confirm a screen reader announces it without cutting off the page.

关于 轻提示 的常见问题

如何用AI生成Toast提示组件?

在一段提示词里描述语义类型、位置和计时 — 例如"success、error、warning和info提示堆叠在右下角,除错误外5秒后自动消失" — MeDo会生成Provider、队列和Toast本体。你拿到的是触发函数加标记,而不是一个还需要自己接线的静态方块。

Toast应该在屏幕上停留多久?

简短的确认信息四到六秒即可,5000ms是合理的默认值。较长的消息需要更多时间,决定下限的是阅读速度而非美观。错误以及任何带操作按钮的提示都不应自动消失。

Alert和Toast有什么区别?

Toast是短暂的,浮在页面固定角落,适合确认用户刚刚完成的操作。内联Alert是文档流的一部分,会一直存在直到条件改变,因此适合表达比单次操作更持久的状态 — 失效的付款方式、维护窗口、表单级错误。如果用户需要能回来重新阅读,就用Alert。

Toast应该用role="status"还是role="alert"?

成功和信息类Toast用role="status"配合aria-live="polite",让播报等到语音停顿处再进行。role="alert"隐含assertive会打断当前朗读,应只留给需要立即关注的错误和警告。把每条Toast都标记为alert会让屏幕阅读器不断抢在用户前面说话。

可以堆叠多条Toast而不互相重叠吗?

可以。让MeDo提供一个Toast容器,以固定间隔渲染数量受限的堆叠,超出上限的进入队列,每关闭一条就释放下一条。加入退出过渡,并在动画结束前保留离场元素的高度,就能避免剩余的Toast跳动。

Toast在触摸设备上能用吗?

只要你要求手势支持就能用。指定带拖拽阈值的横向滑动关闭,保持关闭按钮的可点击区域至少44px,并加上安全区域内边距,让Toast避开主屏指示条和任何固定底栏。