Feedback
Timed Toast
A toast with a draining time bar and an Undo action: you can see how many seconds are left to change your mind.
- toast
- notification
- undo
- timer
Preview
Use it with AI
- 1. Copy the link.
- 2. Write to your agent in your own words and drop the link into the sentence.
- 3. The agent opens the link and installs the component from the registry.
put this in the header: https://vibeui.ru/c/toast-001?lang=en
Show the full instructions
What the link says, spelled out. Use it when your agent cannot open links — paste this text instead.
# Install and place "toast-001" (Timed Toast) from VibeUI
## 1. Install first — do not skip, do not recreate
Run this exact command before writing any code:
npx shadcn@latest add https://vibeui.ru/r/toast-001.json
Registry item: https://vibeui.ru/r/toast-001.json
Installs to: components/vibeui/toast-001.tsx (the exact path follows this project's components.json aliases).
npm dependencies: none.
Registry dependencies: none.
Install it from the registry. Do not recreate it from the description,
do not substitute a similar component from another library, and do not
rewrite it to match the project's existing style.
## 2. What it is
A toast with a draining time bar and an Undo action: you can see how many seconds are left to change your mind.
A dark toast: a tone dot, a title, a description, an Undo button and a close cross. A bar drains along the bottom, showing how long is left before it disappears, so the toast does not vanish out of nowhere and Undo stays visible while undoing is still possible. Three tones, duration as a prop. Zero dependencies, one file, its own palette.
## 3. How to use it
import { Toast001 } from "@/components/vibeui/toast-001"
<Toast001
tone="success"
title="Page published"
description="The changes are live at your project address."
duration={5}
onUndo={handleUndo}
onClose={dismiss}
/>
Read the installed file for the full prop list.
## 4. Where to place it
This is a small inline component. Put it exactly where the user asked,
inside the existing markup. Do not create a new page, section or
wrapper for it. If a similar control already sits in that spot,
replace it instead of adding a second one.
Placement: ___
(The user fills this line in. If it is still blank, ask where to put it
instead of guessing.)
## 5. Keep exactly as installed
- the local --vibeui-toast-001-* palette — the toast is deliberately dark and independent of the page theme
- the time bar as a CSS scaleX animation driven by a variable — a setInterval timer would re-render the component dozens of times
- keeping duration in sync with when the caller actually removes the toast: once they diverge, the bar starts lying
- the Undo action beside the text rather than below it: a toast lives for seconds and the action has to be seen at once
- picking the role from the tone: danger is role="alert", the rest are role="status"
- the aria-label on the close button: otherwise a screen reader announces "×"
- the prefers-reduced-motion rule that removes the bar instead of animating it
- the <style> block inside the component — it holds the palette, the tones and the animation
## 6. You may change
- the title and description copy and the undoLabel
- tone: success, danger or neutral
- duration — how many seconds the toast lives; 0 removes the bar
- the onUndo and onClose handlers — they are the logic: the component does not remove itself
- width and placement through className: the toast container is the caller's job
## 7. Rules
- The component neither shows nor hides itself. The queue, the stack and the removal timer belong to the calling code.
- Do not set duration below four seconds when Undo is present: nobody can read and click in time.
- Do not report an error that needs action in a toast — it leaves with the toast. Use an inline alert instead.
- Do not lift the CSS variables into globals.css: the component has to stay a single file.
## 8. Verify
- it renders with no console errors;
- it looks like the preview on the VibeUI page you copied this from;
- if it does not, you changed something listed in section 5 — put it back.For developers
npx shadcn@latest add https://vibeui.ru/r/toast-001.jsonhttps://vibeui.ru/r/toast-001.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-toast-001-*. Полоса времени — CSS-анимация scaleX, длительность приходит переменной --vibeui-toast-001-duration из пропа duration: таймер не считается в JS и не вызывает перерисовок. Сам компонент только показывает уведомление: появлением, очередью и удалением управляет вызывающий код через onClose. Роль выбирается по тону: danger — alert, остальные — status.
Component source
The same file your agent installs. Here in case you would rather copy it by hand.
import type { ComponentPropsWithoutRef, CSSProperties } from "react"
export type Toast001Tone = "neutral" | "success" | "danger"
export type Toast001Props = Omit<
ComponentPropsWithoutRef<"div">,
"title" | "children"
> & {
tone?: Toast001Tone
title?: string
description?: string
/** Подпись действия отмены. Пустая строка убирает кнопку. */
undoLabel?: string
/** Сколько секунд живёт полоса времени. 0 — полосы нет. */
duration?: number
onUndo?: () => void
onClose?: () => void
}
// Идея компонента: уведомление показывает, сколько ему осталось. Полоса
// внизу убывает ровно за отведённое время, поэтому исчезновение не выглядит
// внезапным, а действие «Отменить» видно, пока оно ещё возможно.
const STYLES = `
:where([data-vibeui-block="toast-001"]){
--vibeui-toast-001-fg:oklch(0.97 0.002 265);
--vibeui-toast-001-muted:oklch(0.78 0.008 265);
--vibeui-toast-001-bg:oklch(0.24 0.014 265);
--vibeui-toast-001-tone:oklch(0.72 0.15 152);
--vibeui-toast-001-radius:0.75rem;
--vibeui-toast-001-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="toast-001"]{
position:relative;display:flex;align-items:flex-start;gap:0.75rem;
width:100%;max-width:24rem;box-sizing:border-box;overflow:hidden;
padding:0.8125rem 0.875rem;
border-radius:var(--vibeui-toast-001-radius);
background:var(--vibeui-toast-001-bg);color:var(--vibeui-toast-001-fg);
font-family:var(--vibeui-toast-001-font);
box-shadow:0 18px 40px -20px oklch(0.15 0.02 265 / 60%);
}
[data-vibeui-block="toast-001"] [data-part="dot"]{
width:0.5rem;height:0.5rem;flex:none;margin-top:0.3125rem;border-radius:9999px;
background:var(--vibeui-toast-001-tone);
}
[data-vibeui-block="toast-001"] [data-part="text"]{display:flex;flex-direction:column;gap:0.125rem;flex:1 1 auto;min-width:0}
[data-vibeui-block="toast-001"] [data-part="title"]{font-size:0.875rem;font-weight:600;line-height:1.35}
[data-vibeui-block="toast-001"] [data-part="description"]{font-size:0.8125rem;line-height:1.45;color:var(--vibeui-toast-001-muted)}
[data-vibeui-block="toast-001"] [data-part="undo"],
[data-vibeui-block="toast-001"] [data-part="close"]{
appearance:none;border:0;background:transparent;cursor:pointer;
font:inherit;color:var(--vibeui-toast-001-fg);flex:none;
border-radius:0.375rem;transition:background-color .16s ease,color .16s ease;
}
[data-vibeui-block="toast-001"] [data-part="undo"]{
font-size:0.8125rem;font-weight:600;padding:0.25rem 0.5rem;
color:var(--vibeui-toast-001-tone);
}
[data-vibeui-block="toast-001"] [data-part="undo"]:hover{background:oklch(1 0 0 / 10%)}
[data-vibeui-block="toast-001"] [data-part="close"]{
display:flex;align-items:center;justify-content:center;
width:1.5rem;height:1.5rem;font-size:1rem;line-height:1;
color:var(--vibeui-toast-001-muted);
}
[data-vibeui-block="toast-001"] [data-part="close"]:hover{background:oklch(1 0 0 / 10%);color:var(--vibeui-toast-001-fg)}
[data-vibeui-block="toast-001"] [data-part="undo"]:focus-visible,
[data-vibeui-block="toast-001"] [data-part="close"]:focus-visible{outline:2px solid var(--vibeui-toast-001-tone);outline-offset:2px}
/* Полоса времени: видно, сколько уведомлению осталось. */
[data-vibeui-block="toast-001"] [data-part="timer"]{
position:absolute;left:0;bottom:0;height:2px;width:100%;
background:var(--vibeui-toast-001-tone);opacity:.55;
transform-origin:left center;
animation:vibeui-toast-001-drain linear forwards;
animation-duration:calc(var(--vibeui-toast-001-duration,5) * 1s);
}
@keyframes vibeui-toast-001-drain{from{transform:scaleX(1)}to{transform:scaleX(0)}}
[data-vibeui-block="toast-001"][data-tone="danger"]{--vibeui-toast-001-tone:oklch(0.68 0.19 25)}
[data-vibeui-block="toast-001"][data-tone="neutral"]{--vibeui-toast-001-tone:oklch(0.8 0.02 265)}
@media (prefers-reduced-motion:reduce){
[data-vibeui-block="toast-001"] *{animation:none!important;transition:none!important}
[data-vibeui-block="toast-001"] [data-part="timer"]{display:none}
}
`
/**
* Уведомление с полосой оставшегося времени и действием отмены.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Toast001({
tone = "success",
title = "Страница опубликована",
description = "Изменения уже видны по адресу проекта.",
undoLabel = "Отменить",
duration = 5,
onUndo,
onClose,
className,
style,
...props
}: Toast001Props) {
const palette = {
"--vibeui-toast-001-duration": duration,
...style,
} as CSSProperties
return (
<>
<style href="vibeui-toast-001" precedence="medium">
{STYLES}
</style>
<div
{...props}
data-vibeui-block="toast-001"
data-tone={tone}
role={tone === "danger" ? "alert" : "status"}
className={className}
style={palette}
>
<span data-part="dot" aria-hidden="true" />
<span data-part="text">
<span data-part="title">{title}</span>
{description ? (
<span data-part="description">{description}</span>
) : null}
</span>
{undoLabel ? (
<button data-part="undo" type="button" onClick={onUndo}>
{undoLabel}
</button>
) : null}
<button
data-part="close"
type="button"
onClick={onClose}
aria-label="Закрыть уведомление"
>
×
</button>
{duration > 0 ? <span data-part="timer" aria-hidden="true" /> : null}
</div>
</>
)
}