Inputs
Limited Textarea
A limited textarea that never truncates silently: the counter turns red and the person decides what to cut.
- input
- textarea
- limit
- counter
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/textarea-002?lang=en
Коротко и по делу87 / 180
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-002" (Limited 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-002.json
Registry item: https://vibeui.ru/r/textarea-002.json
Installs to: components/vibeui/textarea-002.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 limited textarea that never truncates silently: the counter turns red and the person decides what to cut.
A multiline field with a limit: a character counter, a red border past the limit and a line saying what to do. Zero dependencies, one file.
## 3. How to use it
import { Textarea002 } from "@/components/vibeui/textarea-002"
<Textarea002 limit={180} onChange={setText} />
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-002-* palette — do not swap it for your theme tokens
- avoiding maxlength: it silently stops accepting input and explains nothing
- the counter with role="status" tied to the field via aria-describedby
- aria-invalid past the limit rather than a red border alone
- vertical resizing
- the line beside the counter: what to do, not only how many are left
## 6. You may change
- limit — the character cap
- label and placeholder
- the onChange handler
- the accent through the accent prop
## 7. Rules
- Blocking submission past the limit is the form's job: the field only shows state.
- Characters are counted, not bytes: database limits often mean the latter.
- A soft limit suits descriptions; strict fields like SMS need another approach.
- 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-002.jsonhttps://vibeui.ru/r/textarea-002.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-textarea-002-*. Клиентский: "use client". Атрибут maxlength намеренно не используется: он молча запрещает ввод. Превышение выносится в data-over, поле помечается aria-invalid, счётчик объявлен role="status" и связан с полем через aria-describedby.
Component source
The same file your agent installs. Here in case you would rather copy it by hand.
"use client"
import { useId, useState } from "react"
import type { ComponentPropsWithoutRef, CSSProperties } from "react"
export type Textarea002Props = Omit<
ComponentPropsWithoutRef<"div">,
"children" | "onChange"
> & {
label?: string
placeholder?: string
limit?: number
onChange?: (value: string) => void
accent?: string
}
// Идея компонента: поле с ограничением, которое не обрезает текст молча.
// maxlength не стоит: он не даёт дописать даже пробел и не объясняет, почему
// клавиатура перестала работать. Вместо этого счётчик краснеет, а лишнее
// подсвечивается — человек сам решает, что сократить.
const STYLES = `
:where([data-vibeui-block="textarea-002"]){
--vibeui-textarea-002-bg:oklch(1 0 0);
--vibeui-textarea-002-fg:oklch(0.22 0.014 265);
--vibeui-textarea-002-muted:oklch(0.56 0.014 265);
--vibeui-textarea-002-border:oklch(0.9 0.006 265);
--vibeui-textarea-002-field:oklch(0.985 0.002 265);
--vibeui-textarea-002-accent:oklch(0.55 0.17 265);
--vibeui-textarea-002-danger:oklch(0.56 0.19 25);
--vibeui-textarea-002-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="textarea-002"]{
display:flex;flex-direction:column;gap:0.375rem;
width:100%;max-width:22rem;box-sizing:border-box;padding:0.875rem;
background:var(--vibeui-textarea-002-bg);
border:1px solid var(--vibeui-textarea-002-border);border-radius:0.875rem;
font-family:var(--vibeui-textarea-002-font);color:var(--vibeui-textarea-002-fg);
}
[data-vibeui-block="textarea-002"] label{font-size:0.8125rem;font-weight:600}
[data-vibeui-block="textarea-002"] textarea{
box-sizing:border-box;width:100%;min-height:5.5rem;resize:vertical;
padding:0.5rem 0.75rem;
border:1px solid var(--vibeui-textarea-002-border);border-radius:0.625rem;
background:var(--vibeui-textarea-002-field);color:inherit;
font:inherit;font-size:0.875rem;line-height:1.5;
}
[data-vibeui-block="textarea-002"] textarea:focus-visible{
outline:2px solid var(--vibeui-textarea-002-accent);outline-offset:1px;border-color:transparent;
}
[data-vibeui-block="textarea-002"][data-over="true"] textarea{border-color:var(--vibeui-textarea-002-danger)}
[data-vibeui-block="textarea-002"] [data-part="foot"]{
display:flex;align-items:baseline;justify-content:space-between;gap:0.5rem;
font-size:0.75rem;color:var(--vibeui-textarea-002-muted);
}
/* Счётчик краснеет, но текст не обрезается: сокращать решает человек. */
[data-vibeui-block="textarea-002"] [data-part="count"]{font-variant-numeric:tabular-nums}
[data-vibeui-block="textarea-002"][data-over="true"] [data-part="count"]{color:var(--vibeui-textarea-002-danger);font-weight:650}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="textarea-002"] *{animation:none!important;transition:none!important}}
`
/**
* Поле с ограничением: счётчик краснеет, но текст не обрезается молча.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Textarea002({
label = "Описание компонента",
placeholder = "Что делает компонент и в чём его идея",
limit = 180,
onChange,
accent,
className,
style,
...props
}: Textarea002Props) {
const id = useId()
const [value, setValue] = useState(
"Карточка товара с квадратным кадром: кнопка «в корзину» — отдельная цель поверх ссылки.",
)
const over = value.length > limit
const palette = {
...(accent ? { "--vibeui-textarea-002-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-textarea-002" precedence="medium">
{STYLES}
</style>
<div
{...props}
data-vibeui-block="textarea-002"
data-over={over}
className={className}
style={palette}
>
<label htmlFor={id}>{label}</label>
<textarea
id={id}
placeholder={placeholder}
value={value}
aria-describedby={`${id}-count`}
aria-invalid={over}
onChange={(event) => {
setValue(event.target.value)
onChange?.(event.target.value)
}}
/>
<p data-part="foot">
<span>
{over ? "Слишком длинно — сократите" : "Коротко и по делу"}
</span>
<span data-part="count" id={`${id}-count`} role="status">
{value.length} / {limit}
</span>
</p>
</div>
</>
)
}