Buttons
Resend Countdown
A resend button with a cool-down: it stays locked, the ring drains, the time ticks in tabular figures, and at zero it unlocks itself.
- button
- countdown
- resend
- otp
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/button-027?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 "button-027" (Resend Countdown) 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/button-027.json
Registry item: https://vibeui.ru/r/button-027.json
Installs to: components/vibeui/button-027.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 resend button with a cool-down: it stays locked, the ring drains, the time ticks in tabular figures, and at zero it unlocks itself.
A resend-code button that shows the cool-down honestly. While the countdown runs the button is disabled: a draining ring on the left, ticking tabular figures on the right. At zero it unlocks and announces that to a screen reader; the next press starts the countdown again.
## 3. How to use it
import { Button027 } from "@/components/vibeui/button-027"
<Button027 seconds={30} onResend={sendCodeAgain} />
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 lock during the pause: it replaces the too-many-requests error that would otherwise follow the click
- the ring and the digits together — the fraction of time registers before the seconds are read
- tabular-nums and the min-width: without them the button twitches every second
- the live region only on unlocking: aria-live on ticking seconds turns the button into a chatterbox
- the countdown restarting after a press — the server-side pause begins again too
- the minutes:seconds format: past a minute bare seconds stop being readable
## 6. You may change
- the label and waitingLabel captions
- the pause length through the seconds prop
- the sending through the onResend prop
- the accent colour through the accent prop
- outer spacing through className
## 7. Rules
- The countdown lives in the browser: a page reload resets it. The real pause is still held by the server.
- Do not set seconds below the real backend limit — the button would unlock before the server agrees to accept the request.
- Do not show the countdown on an enabled button: the disabled state is the explanation for why it cannot be pressed.
- 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/button-027.jsonhttps://vibeui.ru/r/button-027.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-button-027-*. Клиентский: остаток секунд хранится в состоянии и уменьшается setTimeout'ом раз в секунду, начальное значение совпадает на сервере и клиенте. Доля остатка уходит в CSS-переменную --vibeui-button-027-left, по которой conic-gradient рисует кольцо. Живая область объявляет только момент разблокировки: секунды не зачитываются каждую секунду.
Component source
The same file your agent installs. Here in case you would rather copy it by hand.
"use client"
import { useEffect, useState } from "react"
import type { ComponentPropsWithoutRef, CSSProperties } from "react"
export type Button027Props = Omit<
ComponentPropsWithoutRef<"button">,
"children" | "onClick"
> & {
label?: string
/** Подпись во время ожидания: время подставляется после неё. */
waitingLabel?: string
/** Пауза до разблокировки, секунды. */
seconds?: number
onResend?: () => void
accent?: string
}
// Идея компонента: кнопка, которую нельзя нажать прямо сейчас. Повторная
// отправка кода упирается в паузу на стороне сервера, и вместо ошибки после
// клика кнопка честно показывает остаток: кольцо убывает, время идёт
// моноширинными цифрами. По нулю кнопка сама разблокируется, а следующее
// нажатие запускает отсчёт заново.
const STYLES = `
:where([data-vibeui-block="button-027"]){
--vibeui-button-027-bg:oklch(1 0 0);
--vibeui-button-027-fg:oklch(0.26 0.016 265);
--vibeui-button-027-muted:oklch(0.56 0.014 265);
--vibeui-button-027-border:oklch(0.9 0.006 265);
--vibeui-button-027-accent:oklch(0.55 0.17 265);
--vibeui-button-027-left:1;
--vibeui-button-027-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="button-027"]{
appearance:none;cursor:pointer;
display:inline-flex;align-items:center;justify-content:center;gap:0.5rem;
min-width:14rem;height:2.5rem;padding:0 1rem;box-sizing:border-box;
border:1px solid var(--vibeui-button-027-border);border-radius:0.625rem;
background:var(--vibeui-button-027-bg);color:var(--vibeui-button-027-accent);
font-family:var(--vibeui-button-027-font);font-size:0.875rem;font-weight:650;line-height:1;
transition:border-color .16s ease,color .16s ease;
}
[data-vibeui-block="button-027"]:hover:not(:disabled){border-color:var(--vibeui-button-027-accent)}
[data-vibeui-block="button-027"]:focus-visible{outline:2px solid var(--vibeui-button-027-accent);outline-offset:2px}
[data-vibeui-block="button-027"]:disabled{cursor:not-allowed;color:var(--vibeui-button-027-muted)}
/* Кольцо остатка: доля времени видна раньше, чем прочитаны цифры. */
[data-vibeui-block="button-027"] [data-part="ring"]{
flex:none;width:1rem;height:1rem;border-radius:9999px;
background:conic-gradient(currentColor calc(var(--vibeui-button-027-left) * 360deg),color-mix(in oklab,currentColor 18%,transparent) 0);
-webkit-mask:radial-gradient(closest-side,transparent 58%,#000 60%);
mask:radial-gradient(closest-side,transparent 58%,#000 60%);
}
[data-vibeui-block="button-027"] [data-part="time"]{font-variant-numeric:tabular-nums}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="button-027"] *{animation:none!important;transition:none!important}}
`
function clock(total: number) {
const minutes = Math.floor(total / 60)
const rest = total % 60
return `${minutes}:${String(rest).padStart(2, "0")}`
}
/**
* Кнопка повторной отправки с обратным отсчётом до разблокировки.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Button027({
label = "Отправить код ещё раз",
waitingLabel = "Повторно через",
seconds = 30,
onResend,
accent,
type = "button",
className,
style,
...props
}: Button027Props) {
const [left, setLeft] = useState(seconds)
useEffect(() => {
if (left <= 0) return
const id = setTimeout(() => setLeft(left - 1), 1000)
return () => clearTimeout(id)
}, [left])
const locked = left > 0
const palette = {
"--vibeui-button-027-left": String(seconds > 0 ? left / seconds : 0),
...(accent ? { "--vibeui-button-027-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-button-027" precedence="medium">
{STYLES}
</style>
<button
{...props}
type={type}
data-vibeui-block="button-027"
className={className}
style={palette}
disabled={locked}
onClick={() => {
onResend?.()
setLeft(seconds)
}}
>
{locked ? <span data-part="ring" aria-hidden="true" /> : null}
{/* Пока идёт отсчёт, живой области нет: секунды не стоит зачитывать
каждую секунду. Объявляется только момент разблокировки. */}
{locked ? (
<span>
{waitingLabel} <span data-part="time">{clock(left)}</span>
</span>
) : (
<span aria-live="polite">{label}</span>
)}
</button>
</>
)
}