Code Block
Error Range
A code block with a highlighted range of lines: a bar on the left, a wavy underline and a callout that says plainly what is wrong.
- code
- error
- highlight
- debug
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/codeblock-007?lang=en
const cart = useCart() const total = cart.items.reduce((sum, item) => { return sum + item.prise * item.count}, 0)Typo: the item field is price, not prise
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 "codeblock-007" (Error Range) 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/codeblock-007.json
Registry item: https://vibeui.ru/r/codeblock-007.json
Installs to: components/vibeui/codeblock-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 code block with a highlighted range of lines: a bar on the left, a wavy underline and a callout that says plainly what is wrong.
A listing with a highlighted line range and an error note underneath: a bar, a tint and a wavy underline plus a callout. Zero dependencies, no client JS.
## 3. How to use it
import { Codeblock007 } from "@/components/vibeui/codeblock-007"
<Codeblock007
path="hooks/use-total.ts"
errorFrom={4}
errorTo={4}
message="Typo: the item has price"
/>
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-codeblock-007-* palette — do not swap it for your theme tokens
- all three error cues at once: bar, tint and underline — colour alone reads poorly
- the callout text: highlighting without an explanation leaves the reader guessing
- the line number in ::before so it does not travel to the clipboard with the code
- the range chip in the header: in a long listing it says where to scroll
- the dark block surface — red on a light background reads as a link, not an error
## 6. You may change
- the listing rows through the lines array
- the range bounds through errorFrom and errorTo
- the callout text through message and the file through path
- the error hue to match your palette
## 7. Rules
- The whole range is highlighted: this block does not point at a column inside a line.
- text-decoration-skip-ink is disabled on purpose — otherwise the wave breaks under descenders.
- A range outside the list of rows simply highlights nothing: bounds are the caller's job.
- 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/codeblock-007.jsonhttps://vibeui.ru/r/codeblock-007.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-codeblock-007-*. Серверный: хуков нет. Диапазон задаётся числами errorFrom и errorTo, номер строки печатается ::before через content:attr(data-line), а сама ошибка отмечена тремя независимыми признаками: полосой слева, подложкой и text-decoration:underline wavy. Под листингом стоит абзац с role=note и стрелкой вверх в псевдоэлементе — он связывает подсветку с текстом объяснения.
Component source
The same file your agent installs. Here in case you would rather copy it by hand.
import type { ComponentPropsWithoutRef, CSSProperties } from "react"
export type Codeblock007Props = Omit<
ComponentPropsWithoutRef<"figure">,
"children"
> & {
path?: string
message?: string
errorFrom?: number
errorTo?: number
lines?: string[]
}
// Идея компонента: не просто подсветить строку, а сказать, что с ней не так.
// Диапазон помечен полосой слева и волнистым подчёркиванием, а под ним стоит
// выноска с текстом ошибки — читатель не ищет, куда смотреть.
const STYLES = `
:where([data-vibeui-block="codeblock-007"]){
--vibeui-codeblock-007-bg:oklch(0.2 0.014 30);
--vibeui-codeblock-007-head:oklch(0.24 0.018 30);
--vibeui-codeblock-007-fg:oklch(0.93 0.006 30);
--vibeui-codeblock-007-muted:oklch(0.66 0.014 30);
--vibeui-codeblock-007-gutter:oklch(0.5 0.02 30);
--vibeui-codeblock-007-border:oklch(1 0 0 / 13%);
--vibeui-codeblock-007-bad:oklch(0.72 0.19 25);
--vibeui-codeblock-007-bad-bg:oklch(0.55 0.18 25 / 20%);
--vibeui-codeblock-007-mono:ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace;
--vibeui-codeblock-007-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="codeblock-007"]{
display:flex;flex-direction:column;
width:100%;max-width:34rem;box-sizing:border-box;margin:0;overflow:hidden;
border:1px solid var(--vibeui-codeblock-007-border);border-radius:0.75rem;
background:var(--vibeui-codeblock-007-bg);color:var(--vibeui-codeblock-007-fg);
font-family:var(--vibeui-codeblock-007-font);
}
[data-vibeui-block="codeblock-007"] figcaption{
display:flex;align-items:center;justify-content:space-between;gap:0.75rem;
padding:0.5rem 0.875rem;
background:var(--vibeui-codeblock-007-head);
border-bottom:1px solid var(--vibeui-codeblock-007-border);
font-family:var(--vibeui-codeblock-007-mono);font-size:0.75rem;
color:var(--vibeui-codeblock-007-muted);
}
[data-vibeui-block="codeblock-007"] [data-part="badge"]{
padding:0.125rem 0.4375rem;border-radius:999px;
background:var(--vibeui-codeblock-007-bad-bg);color:var(--vibeui-codeblock-007-bad);
font-family:var(--vibeui-codeblock-007-font);font-weight:700;
}
[data-vibeui-block="codeblock-007"] pre{margin:0;padding:0.625rem 0;overflow-x:auto}
[data-vibeui-block="codeblock-007"] code{
display:block;min-width:max-content;
font-family:var(--vibeui-codeblock-007-mono);
font-size:0.8125rem;line-height:1.7;white-space:pre;
}
[data-vibeui-block="codeblock-007"] [data-part="row"]{
display:block;position:relative;padding:0 0.875rem 0 3.25rem;
border-left:3px solid transparent;
}
[data-vibeui-block="codeblock-007"] [data-part="row"]::before{
content:attr(data-line);position:absolute;left:0.5rem;width:2rem;
text-align:right;color:var(--vibeui-codeblock-007-gutter);
font-variant-numeric:tabular-nums;
user-select:none;-webkit-user-select:none;
}
[data-vibeui-block="codeblock-007"] [data-part="row"][data-bad="true"]{
background:var(--vibeui-codeblock-007-bad-bg);
border-left-color:var(--vibeui-codeblock-007-bad);
}
[data-vibeui-block="codeblock-007"] [data-part="row"][data-bad="true"]::before{color:var(--vibeui-codeblock-007-bad)}
[data-vibeui-block="codeblock-007"] [data-part="row"][data-bad="true"] span{
text-decoration:underline wavy var(--vibeui-codeblock-007-bad);
text-underline-offset:0.25em;text-decoration-skip-ink:none;
}
[data-vibeui-block="codeblock-007"] [data-part="callout"]{
display:flex;gap:0.5rem;align-items:flex-start;
margin:0;padding:0.625rem 0.875rem 0.75rem 3.25rem;
font-size:0.75rem;line-height:1.45;color:var(--vibeui-codeblock-007-bad);
}
[data-vibeui-block="codeblock-007"] [data-part="callout"]::before{
content:"↑";flex:none;font-weight:700;
}
`
const LINES = [
"const cart = useCart()",
"",
"const total = cart.items.reduce((sum, item) => {",
" return sum + item.prise * item.count",
"}, 0)",
]
/** Блок кода с подсвеченным диапазоном строк и подписью об ошибке. */
export function Codeblock007({
path = "hooks/use-total.ts",
message = "Опечатка: у товара поле price, а не prise",
errorFrom = 4,
errorTo = 4,
lines = LINES,
className,
style,
...props
}: Codeblock007Props) {
return (
<>
<style href="vibeui-codeblock-007" precedence="medium">
{STYLES}
</style>
<figure
{...props}
data-vibeui-block="codeblock-007"
className={className}
style={style as CSSProperties}
>
<figcaption>
<span>{path}</span>
<span data-part="badge">
строка {errorFrom}
{errorTo > errorFrom ? `–${errorTo}` : ""}
</span>
</figcaption>
<pre>
<code>
{lines.map((line, index) => {
const number = index + 1
const bad = number >= errorFrom && number <= errorTo
return (
<span
key={index}
data-part="row"
data-line={number}
data-bad={bad || undefined}
>
<span>{line === "" ? " " : line}</span>
</span>
)
})}
</code>
</pre>
<p data-part="callout" role="note">
{message}
</p>
</figure>
</>
)
}