Inputs
Readonly Copy Textarea
A read-only field with a copy button: the text can be selected and read, and when the clipboard is unavailable it is simply selected in full.
- textarea
- readonly
- clipboard
- snippet
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/textarea-008?lang=en
The field is readable and selectable, but not editable
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 "textarea-008" (Readonly Copy Textarea) 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/textarea-008.json
Registry item: https://vibeui.ru/r/textarea-008.json
Installs to: components/vibeui/textarea-008.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 text can be selected and read, and when the clipboard is unavailable it is simply selected in full.
A read-only field with clipboard copying and a selection fallback. One file, zero dependencies, a client component.
## 3. How to use it
import { Textarea008 } from "@/components/vibeui/textarea-008"
<Textarea008
label="Install command"
copyText="Copy"
copiedText="Copied"
/>
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-textarea-008-* palette — do not swap it for your theme tokens
- readOnly rather than disabled: a disabled field cannot be selected or read by a screen reader, and here the text is the content
- the fallback that selects the text — without a secure connection the clipboard is unavailable and the button would fail silently
- the "Copied" confirmation as text, not only an icon swap: a silent copy looks like no reaction at all
- the button in the header rather than over the text: an overlaid button covers the first line and blocks manual selection
- the component's own light surface — without it the dark text disappears on a dark page
## 6. You may change
- the caption through label and the explanation through hint
- the button caption through copyText
- the confirmation caption through copiedText
- the accent colour through accent
## 7. Rules
- The content is a constant in the file: when substituting your own watch the line length — the field is monospaced and wraps commands badly.
- The confirmation lasts under two seconds: a screen reader has to announce it within that window.
- Selecting everything on focus helps mouse users but hinders reading the field piece by piece from the keyboard.
- 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/textarea-008.jsonhttps://vibeui.ru/r/textarea-008.jsonКлиентский компонент: useRef на поле, useState на признак «скопировано». Поле помечено readOnly, а не disabled: выключенное поле нельзя выделить и прочитать скринридером, а здесь текст и есть содержимое. Копирование идёт через navigator.clipboard с запасным путём — без защищённого соединения API недоступен, и тогда текст выделяется целиком. Значок кнопки превращается в галочку правилом по data-copied на корне. Палитра в --vibeui-textarea-008-*.
Component source
The same file your agent installs. Here in case you would rather copy it by hand.
"use client"
import { useId, useRef, useState } from "react"
import type { ComponentPropsWithoutRef, CSSProperties } from "react"
export type Textarea008Props = Omit<
ComponentPropsWithoutRef<"div">,
"children" | "onChange"
> & {
label?: string
hint?: string
copyText?: string
copiedText?: string
accent?: string
}
// Идея компонента: поле только для чтения — ключ, сниппет, инструкция для
// агента. readOnly, а не disabled: выключенное поле нельзя выделить и
// прочитать скринридером, а здесь текст и есть содержимое. Копирование идёт
// через буфер обмена, но с запасным путём: без защищённого соединения
// clipboard недоступен, и тогда текст просто выделяется целиком.
const STYLES = `
:where([data-vibeui-block="textarea-008"]){
--vibeui-textarea-008-bg:oklch(1 0 0);
--vibeui-textarea-008-fg:oklch(0.22 0.014 265);
--vibeui-textarea-008-muted:oklch(0.55 0.014 265);
--vibeui-textarea-008-border:oklch(0.9 0.006 265);
--vibeui-textarea-008-field:oklch(0.97 0.004 265);
--vibeui-textarea-008-accent:oklch(0.5 0.16 250);
--vibeui-textarea-008-ok:oklch(0.52 0.14 155);
--vibeui-textarea-008-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
--vibeui-textarea-008-mono:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
}
[data-vibeui-block="textarea-008"]{
display:flex;flex-direction:column;gap:0.375rem;
width:100%;max-width:23rem;box-sizing:border-box;padding:0.875rem;
background:var(--vibeui-textarea-008-bg);
border:1px solid var(--vibeui-textarea-008-border);border-radius:0.875rem;
font-family:var(--vibeui-textarea-008-font);color:var(--vibeui-textarea-008-fg);
}
[data-vibeui-block="textarea-008"] [data-part="head"]{
display:flex;align-items:center;justify-content:space-between;gap:0.75rem;
}
[data-vibeui-block="textarea-008"] label{font-size:0.8125rem;font-weight:600}
/* Кнопка стоит в шапке, а не поверх текста: наложенная кнопка перекрывает
первую строку и мешает выделять текст руками. */
[data-vibeui-block="textarea-008"] button{
appearance:none;cursor:pointer;flex:none;
display:inline-flex;align-items:center;gap:0.375rem;
height:1.75rem;padding:0 0.625rem;border-radius:0.5rem;
border:1px solid var(--vibeui-textarea-008-border);
background:var(--vibeui-textarea-008-bg);color:inherit;
font:inherit;font-size:0.75rem;font-weight:600;
transition:border-color .16s ease,color .16s ease;
}
[data-vibeui-block="textarea-008"] button:hover{border-color:var(--vibeui-textarea-008-accent)}
[data-vibeui-block="textarea-008"] button:focus-visible{outline:2px solid var(--vibeui-textarea-008-accent);outline-offset:2px}
[data-vibeui-block="textarea-008"][data-copied="true"] button{
border-color:var(--vibeui-textarea-008-ok);color:var(--vibeui-textarea-008-ok);
}
/* Две квадратные рамки со сдвигом — значок «копировать» без иконочного пакета. */
[data-vibeui-block="textarea-008"] [data-part="mark"]{
position:relative;width:0.75rem;height:0.75rem;
border:1.5px solid currentColor;border-radius:0.1875rem;
}
[data-vibeui-block="textarea-008"] [data-part="mark"]::after{
content:"";position:absolute;left:-0.3125rem;top:-0.3125rem;
width:0.5rem;height:0.5rem;
border:1.5px solid currentColor;border-right:0;border-bottom:0;
border-radius:0.1875rem 0 0 0;
}
[data-vibeui-block="textarea-008"][data-copied="true"] [data-part="mark"]{
width:0.375rem;height:0.6875rem;border-radius:0;
border:0;border-right:2px solid currentColor;border-bottom:2px solid currentColor;
transform:rotate(45deg) translate(-0.0625rem,-0.0625rem);
}
[data-vibeui-block="textarea-008"][data-copied="true"] [data-part="mark"]::after{content:none}
[data-vibeui-block="textarea-008"] textarea{
box-sizing:border-box;width:100%;min-height:5.5rem;resize:vertical;
margin:0;padding:0.625rem 0.75rem;
border:1px dashed var(--vibeui-textarea-008-border);border-radius:0.625rem;
background:var(--vibeui-textarea-008-field);color:inherit;
font-family:var(--vibeui-textarea-008-mono);font-size:0.75rem;line-height:1.6;
cursor:text;
}
[data-vibeui-block="textarea-008"] textarea:focus-visible{
outline:2px solid var(--vibeui-textarea-008-accent);outline-offset:1px;border-color:transparent;
}
[data-vibeui-block="textarea-008"] [data-part="hint"]{
margin:0;font-size:0.75rem;color:var(--vibeui-textarea-008-muted);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="textarea-008"] *{animation:none!important;transition:none!important}}
`
const CONTENT = `npx shadcn@latest add https://vibeui.dev/r/textarea-008.json
# Поле только для чтения: текст можно выделить,
# скопировать кнопкой и прочитать скринридером.`
/**
* Поле только для чтения с кнопкой копирования и запасным выделением текста.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Textarea008({
label = "Команда установки",
hint = "Поле доступно для чтения и выделения, но не для правки",
copyText = "Копировать",
copiedText = "Скопировано",
accent,
className,
style,
...props
}: Textarea008Props) {
const id = useId()
const field = useRef<HTMLTextAreaElement>(null)
const [copied, setCopied] = useState(false)
const copy = async () => {
const element = field.current
if (!element) {
return
}
try {
await navigator.clipboard.writeText(element.value)
setCopied(true)
setTimeout(() => setCopied(false), 1800)
} catch {
// Без защищённого соединения clipboard недоступен: тогда выделяем
// текст целиком, чтобы копирование осталось в один жест.
element.focus()
element.select()
}
}
const palette = {
...(accent ? { "--vibeui-textarea-008-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-textarea-008" precedence="medium">
{STYLES}
</style>
<div
{...props}
data-vibeui-block="textarea-008"
data-copied={copied}
className={className}
style={palette}
>
<div data-part="head">
<label htmlFor={id}>{label}</label>
<button type="button" onClick={copy}>
<span data-part="mark" aria-hidden="true" />
<span>{copied ? copiedText : copyText}</span>
</button>
</div>
<textarea
id={id}
ref={field}
readOnly
spellCheck={false}
defaultValue={CONTENT}
onFocus={(event) => event.currentTarget.select()}
/>
<p data-part="hint" role="status">
{copied ? copiedText : hint}
</p>
</div>
</>
)
}