Buttons
Copy Button
The copy button reports inside itself: the label turns into "Copied" and returns a couple of seconds later.
- button
- copy
- clipboard
- feedback
Preview
1440pxHost theme
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-015?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-015" (Copy Button) 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-015.json
Registry item: https://vibeui.ru/r/button-015.json
Installs to: components/vibeui/button-015.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
The copy button reports inside itself: the label turns into "Copied" and returns a couple of seconds later.
A copy button: it writes a string to the clipboard and swaps its label and glyph for two seconds. If the clipboard refuses, nothing changes. Zero dependencies, one file.
## 3. How to use it
import { Button015 } from "@/components/vibeui/button-015"
<Button015 value="npm i vibeui" label="Copy" />
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-button-015-* palette — do not swap it for your theme tokens
- the try/catch around clipboard: a false "copied" is worse than silence
- the report inside the button rather than a toast in another corner
- aria-live="polite" on the label — the change has to be heard
- clearing the timer on unmount
- returning to the idle state: otherwise a second copy is invisible
## 6. You may change
- value — what gets copied
- label and doneLabel
- hold — how long the report stays
- the success colour
## 7. Rules
- navigator.clipboard only works in a secure context (https or localhost): over http the button stays silent.
- Copying data the person cannot see is a bad idea: copy what is on screen.
- Two seconds is the compromise: less is unreadable, more looks stuck.
- 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-015.jsonhttps://vibeui.ru/r/button-015.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-button-015-*. Клиентский: "use client". Запись в буфер идёт через navigator.clipboard в try/catch: при отказе состояние не меняется, потому что ложное «скопировано» хуже молчания. Таймер возврата снимается при размонтировании. Подпись объявлена aria-live="polite".
Component source
The same file your agent installs. Here in case you would rather copy it by hand.
"use client"
import { useEffect, useRef, useState } from "react"
import type { ComponentPropsWithoutRef, CSSProperties } from "react"
export type Button015Props = Omit<
ComponentPropsWithoutRef<"button">,
"children" | "value"
> & {
value?: string
label?: string
doneLabel?: string
/** Сколько держать состояние «скопировано», мс. */
hold?: number
}
// Идея компонента: кнопка копирования, которая честно отчитывается. Успех
// показан сменой подписи и галочкой, а не всплывающим сообщением: оно
// появляется в другом углу экрана, и глаз его не находит. Состояние живёт
// пару секунд и само возвращается — иначе непонятно, копировалось ли снова.
const STYLES = `
:where([data-vibeui-block="button-015"]){
--vibeui-button-015-fg:oklch(0.3 0.014 265);
--vibeui-button-015-bg:oklch(1 0 0);
--vibeui-button-015-border:oklch(0.9 0.006 265);
--vibeui-button-015-hover:oklch(0.96 0.004 265);
--vibeui-button-015-done:oklch(0.55 0.15 152);
--vibeui-button-015-accent:oklch(0.55 0.17 265);
--vibeui-button-015-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="button-015"]{
appearance:none;cursor:pointer;
display:inline-flex;align-items:center;gap:0.4375rem;
height:2.25rem;padding:0 0.875rem;box-sizing:border-box;
border:1px solid var(--vibeui-button-015-border);border-radius:0.625rem;
background:var(--vibeui-button-015-bg);color:var(--vibeui-button-015-fg);
font-family:var(--vibeui-button-015-font);font-size:0.8125rem;font-weight:600;line-height:1;
transition:color .16s ease,border-color .16s ease;
}
[data-vibeui-block="button-015"]:hover{background:var(--vibeui-button-015-hover)}
[data-vibeui-block="button-015"]:focus-visible{outline:2px solid var(--vibeui-button-015-accent);outline-offset:2px}
[data-vibeui-block="button-015"][data-done="true"]{color:var(--vibeui-button-015-done);border-color:color-mix(in oklab,var(--vibeui-button-015-done) 40%,oklch(1 0 0))}
/* Два листа бумаги: один со сдвигом — знак копирования без пакета иконок. */
[data-vibeui-block="button-015"] [data-part="copy"]{position:relative;flex:none;width:0.875rem;height:0.875rem}
[data-vibeui-block="button-015"] [data-part="copy"]::before{
content:"";position:absolute;left:0;bottom:0;width:0.625rem;height:0.625rem;
border:1.5px solid currentColor;border-radius:0.1875rem;
}
[data-vibeui-block="button-015"] [data-part="copy"]::after{
content:"";position:absolute;right:0;top:0;width:0.625rem;height:0.625rem;
border:1.5px solid currentColor;border-radius:0.1875rem;
background:var(--vibeui-button-015-bg);
}
[data-vibeui-block="button-015"] [data-part="tick"]{
flex:none;width:0.3125rem;height:0.5625rem;margin:0 0.125rem 0.125rem 0.125rem;
border-right:2px solid currentColor;border-bottom:2px solid currentColor;
transform:rotate(45deg);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="button-015"] *{animation:none!important;transition:none!important}}
`
/**
* Кнопка копирования с честным отчётом прямо в подписи.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Button015({
value = "npx shadcn@latest add https://vibeui.ru/r/button-015.json",
label = "Скопировать",
doneLabel = "Скопировано",
hold = 2000,
type = "button",
className,
style,
...props
}: Button015Props) {
const [done, setDone] = useState(false)
const timer = useRef<ReturnType<typeof setTimeout> | null>(null)
useEffect(
() => () => {
if (timer.current) clearTimeout(timer.current)
},
[],
)
const copy = async () => {
try {
await navigator.clipboard.writeText(value)
} catch {
// Буфер недоступен (нет доступа или небезопасный контекст) — молча
// выходим: ложное «скопировано» хуже отсутствия отклика.
return
}
setDone(true)
if (timer.current) clearTimeout(timer.current)
timer.current = setTimeout(() => setDone(false), hold)
}
return (
<>
<style href="vibeui-button-015" precedence="medium">
{STYLES}
</style>
<button
{...props}
type={type}
data-vibeui-block="button-015"
data-done={done}
className={className}
style={style as CSSProperties}
onClick={copy}
>
{done ? (
<span data-part="tick" aria-hidden="true" />
) : (
<span data-part="copy" aria-hidden="true" />
)}
<span aria-live="polite">{done ? doneLabel : label}</span>
</button>
</>
)
}