Inputs
Copy Field
A read-only field with a copy button: the value lives in a real input, and if the clipboard is refused it simply gets selected in full.
- field
- readonly
- copy
- clipboard
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/field-007?lang=en
Shown once — save it now.
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 "field-007" (Copy Field) 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/field-007.json
Registry item: https://vibeui.ru/r/field-007.json
Installs to: components/vibeui/field-007.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 read-only field with a copy button: the value lives in a real input, and if the clipboard is refused it simply gets selected in full.
A read-only field with a copy button: a key, an invite link, an identifier. The value sits in a real readOnly input, the button selects it first and then tries the clipboard, and the outcome is stated in words. Zero dependencies, one file, its own palette.
## 3. How to use it
import { Field007 } from "@/components/vibeui/field-007"
<Field007
label="Registry access key"
value="vibeui_live_8f3c21a7b904e6d5"
/>
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-field-007-* palette — do not swap it for your theme tokens (bg-muted, border-input and the like)
- a real readOnly input instead of <code>: the value has to be selectable, scrollable and reachable by a password manager
- selecting the text before reaching for the clipboard — that is the fallback when the clipboard is unavailable outside HTTPS
- readOnly rather than disabled: a disabled field can be neither focused nor selected
- the spoken confirmation through role="status": a colour change on the button is not read aloud
- the monospaced value — in a key it matters that 0 differs from O and 1 from l
- the <style> block inside the component — it holds the palette, the geometry and the copy glyph
## 6. You may change
- the label copy and the hint line
- the value content — a key, a link or an identifier
- the accent through the accent prop — it colours the border and the button
- the button captions for both states
- width and outer spacing through className
## 7. Rules
- navigator.clipboard needs HTTPS and can be blocked by settings: that is why the selection always happens, not only on failure.
- The "Done" state does not reset itself. Add a timer in the caller if you want it to.
- A secret shown once deserves a line saying so: it cannot be recovered after the page closes.
- 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/field-007.jsonhttps://vibeui.ru/r/field-007.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-field-007-*. Клиентский: "use client" ради буфера обмена. Значение живёт в readOnly-поле, а не в <code>: его выделяют, прокручивают и отдают менеджеру паролей. Кнопка сначала выделяет текст через ref, затем пробует navigator.clipboard.writeText — выделение остаётся запасным путём при отказе. Успех поднимает data-copied и объявляется через role="status".
Component source
The same file your agent installs. Here in case you would rather copy it by hand.
"use client"
import { useRef, useState } from "react"
import type { ComponentPropsWithoutRef, CSSProperties } from "react"
export type Field007Props = Omit<
ComponentPropsWithoutRef<"div">,
"children" | "defaultValue"
> & {
label?: string
value?: string
hint?: string
accent?: string
}
// Идея компонента: поле, которое не редактируют, а забирают. Ключ, ссылка
// приглашения, идентификатор — их печатают глазами и ошибаются. Значение
// лежит в настоящем readOnly-поле, а не в <code>: его можно выделить,
// прокрутить и отдать менеджеру паролей. Кнопка копирования сначала пробует
// буфер обмена, а при отказе просто выделяет текст — так работает везде.
const STYLES = `
:where([data-vibeui-block="field-007"]){
--vibeui-field-007-bg:oklch(0.975 0.004 265);
--vibeui-field-007-surface:oklch(1 0 0);
--vibeui-field-007-fg:oklch(0.24 0.014 265);
--vibeui-field-007-muted:oklch(0.55 0.014 265);
--vibeui-field-007-border:oklch(0.88 0.008 265);
--vibeui-field-007-shell:oklch(0.91 0.006 265);
--vibeui-field-007-accent:oklch(0.5 0.16 250);
--vibeui-field-007-ok:oklch(0.5 0.13 155);
--vibeui-field-007-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
--vibeui-field-007-mono:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;
}
/* Своя светлая подложка: поле показывают поверх любого фона. */
[data-vibeui-block="field-007"]{
display:flex;flex-direction:column;gap:0.4375rem;
width:100%;max-width:23rem;box-sizing:border-box;padding:0.875rem;
background:var(--vibeui-field-007-surface);
border:1px solid var(--vibeui-field-007-shell);border-radius:0.875rem;
font-family:var(--vibeui-field-007-font);color:var(--vibeui-field-007-fg);
}
[data-vibeui-block="field-007"] *{box-sizing:border-box}
[data-vibeui-block="field-007"] label{font-size:0.8125rem;font-weight:600}
[data-vibeui-block="field-007"] [data-part="frame"]{
display:flex;align-items:center;gap:0.375rem;
padding:0.25rem 0.25rem 0.25rem 0.625rem;
background:var(--vibeui-field-007-bg);
border:1px dashed var(--vibeui-field-007-border);border-radius:0.75rem;
}
[data-vibeui-block="field-007"] [data-part="frame"]:focus-within{
border-style:solid;border-color:var(--vibeui-field-007-accent);
box-shadow:0 0 0 3px color-mix(in oklab,var(--vibeui-field-007-accent) 16%,transparent);
}
/* Настоящее readOnly-поле, а не <code>: значение выделяется и прокручивается. */
[data-vibeui-block="field-007"] input{
flex:1;min-width:0;height:2rem;padding:0;
border:0;background:none;color:inherit;cursor:text;
font-family:var(--vibeui-field-007-mono);font-size:0.8125rem;
text-overflow:ellipsis;
}
[data-vibeui-block="field-007"] input:focus{outline:none}
[data-vibeui-block="field-007"] button{
appearance:none;flex:none;cursor:pointer;
display:inline-flex;align-items:center;gap:0.375rem;
height:2rem;padding:0 0.75rem;border-radius:0.5rem;
border:1px solid var(--vibeui-field-007-border);
background:oklch(1 0 0);color:inherit;
font:inherit;font-size:0.75rem;font-weight:650;line-height:1;
transition:border-color .16s ease,color .16s ease;
}
[data-vibeui-block="field-007"] button:hover{border-color:var(--vibeui-field-007-accent);color:var(--vibeui-field-007-accent)}
[data-vibeui-block="field-007"] button:focus-visible{outline:2px solid var(--vibeui-field-007-accent);outline-offset:2px}
[data-vibeui-block="field-007"][data-copied="true"] button{border-color:var(--vibeui-field-007-ok);color:var(--vibeui-field-007-ok)}
/* Две пластины из бордюров: значок копии без иконочной библиотеки. */
[data-vibeui-block="field-007"] [data-part="mark"]{
position:relative;width:0.75rem;height:0.75rem;flex:none;
}
[data-vibeui-block="field-007"] [data-part="mark"]::before,
[data-vibeui-block="field-007"] [data-part="mark"]::after{
content:"";position:absolute;width:0.5rem;height:0.5rem;border-radius:0.125rem;
border:1.5px solid currentColor;
}
[data-vibeui-block="field-007"] [data-part="mark"]::before{left:0;top:0;opacity:.45}
[data-vibeui-block="field-007"] [data-part="mark"]::after{right:0;bottom:0}
[data-vibeui-block="field-007"] [data-part="hint"]{
margin:0;font-size:0.75rem;line-height:1.4;color:var(--vibeui-field-007-muted);
}
[data-vibeui-block="field-007"][data-copied="true"] [data-part="hint"]{color:var(--vibeui-field-007-ok);font-weight:600}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="field-007"] *{animation:none!important;transition:none!important}}
`
/**
* Поле только для чтения с кнопкой копирования и откатом на выделение.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Field007({
label = "Ключ доступа к registry",
value = "vibeui_live_8f3c21a7b904e6d5",
hint = "Ключ показывается один раз — сохраните его сейчас.",
accent,
className,
style,
...props
}: Field007Props) {
const input = useRef<HTMLInputElement>(null)
const [copied, setCopied] = useState(false)
const palette = {
...(accent ? { "--vibeui-field-007-accent": accent } : null),
...style,
} as CSSProperties
const copy = async () => {
// Выделение — не украшение, а запасной путь: буфер недоступен без
// защищённого соединения и при отказе в разрешении.
input.current?.select()
try {
await navigator.clipboard.writeText(value)
setCopied(true)
} catch {
setCopied(false)
}
}
return (
<>
<style href="vibeui-field-007" precedence="medium">
{STYLES}
</style>
<div
{...props}
data-vibeui-block="field-007"
data-copied={copied ? "true" : undefined}
className={className}
style={palette}
>
<label htmlFor="field-007-input">{label}</label>
<div data-part="frame">
<input
id="field-007-input"
ref={input}
type="text"
readOnly
value={value}
spellCheck={false}
onFocus={(event) => event.target.select()}
/>
<button type="button" onClick={copy}>
<span data-part="mark" aria-hidden="true" />
{copied ? "Готово" : "Копировать"}
</button>
</div>
<p data-part="hint" role="status">
{copied ? "Скопировано в буфер обмена" : hint}
</p>
</div>
</>
)
}