Code Block

Scroll Hint

A code block with horizontal scrolling and an honest hint about it: the edge shade and the caption fade out as the reader scrolls.

  • code
  • scroll
  • hint
  • overflow

Preview

1440pxHost theme

Use it with AI

  1. 1. Copy the link.
  2. 2. Write to your agent in your own words and drop the link into the sentence.
  3. 3. The agent opens the link and installs the component from the registry.

put this in the header: https://vibeui.ru/c/codeblock-011?lang=en

table/columns.ts
const columns = [{ key: "name", title: "Название" }, { key: "price", title: "Цена, ₽" }, { key: "stock", title: "Остаток" }]
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-011" (Scroll Hint) 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-011.json

Registry item: https://vibeui.ru/r/codeblock-011.json
Installs to: components/vibeui/codeblock-011.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 horizontal scrolling and an honest hint about it: the edge shade and the caption fade out as the reader scrolls.

A code block with horizontal scrolling: the right edge is shaded and the hint fades away through a scroll-driven animation. Zero dependencies, no client JS.

## 3. How to use it
import { Codeblock011 } from "@/components/vibeui/codeblock-011"

<Codeblock011
  title="table/columns.ts"
  hint="Scroll right"
/>

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-011-* palette — do not swap it for your theme tokens
- tabIndex and role=region on the scroller: without them the code cannot be scrolled by keyboard
- the shade painted over the code rather than a mask on it — a mask eats the text itself
- the @supports wrapper: without it browsers lacking scroll-timeline lose the hint forever
- pointer-events:none on the hint and the shade — otherwise they intercept text selection
- the dark block surface: it defines the shade colour, and on another background the gradient shows

## 6. You may change
- the block code through code and the heading through title
- the hint text through hint
- the shade width and the animation-range span
- the maximum block width

## 7. Rules
- prefers-reduced-motion removes the animation: the hint stays visible, which is the right fallback.
- Horizontal scrolling on a phone competes with page scrolling: overscroll-behavior-x:contain settles it.
- If the code is shorter than the block, the hint still renders — hide it on the caller's side.
- 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-011.json
https://vibeui.ru/r/codeblock-011.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-codeblock-011-*. Серверный: хуков нет. Область прокрутки объявляет именованную scroll-timeline, корень открывает её через timeline-scope, и затенение с подсказкой гасятся анимацией, привязанной к этой таймлайн-линии — обработчиков прокрутки в JS нет. Всё завёрнуто в @supports (animation-timeline:scroll()): без поддержки подсказка просто остаётся видимой. Область прокрутки получает tabIndex и role=region, иначе с клавиатуры до неё не добраться.

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 Codeblock011Props = Omit<
  ComponentPropsWithoutRef<"figure">,
  "children" | "title"
> & {
  title?: string
  hint?: string
  code?: string
}

// Идея компонента: честная горизонтальная прокрутка. Правый край затенён, а
// подсказка «прокрутите» гаснет по мере прокрутки — за это отвечает
// scroll-driven анимация, привязанная к самой области прокрутки. Без
// поддержки подсказка просто остаётся на месте, ничего не ломая.
const STYLES = `
:where([data-vibeui-block="codeblock-011"]){
--vibeui-codeblock-011-bg:oklch(0.21 0.02 60);
--vibeui-codeblock-011-head:oklch(0.25 0.024 60);
--vibeui-codeblock-011-fg:oklch(0.93 0.008 60);
--vibeui-codeblock-011-muted:oklch(0.68 0.02 60);
--vibeui-codeblock-011-border:oklch(1 0 0 / 13%);
--vibeui-codeblock-011-accent:oklch(0.83 0.13 75);
--vibeui-codeblock-011-mono:ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace;
--vibeui-codeblock-011-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
timeline-scope:--vibeui-codeblock-011-track;
}
[data-vibeui-block="codeblock-011"]{
position:relative;display:flex;flex-direction:column;
width:100%;max-width:30rem;box-sizing:border-box;margin:0;overflow:hidden;
border:1px solid var(--vibeui-codeblock-011-border);border-radius:0.75rem;
background:var(--vibeui-codeblock-011-bg);color:var(--vibeui-codeblock-011-fg);
font-family:var(--vibeui-codeblock-011-font);
}
[data-vibeui-block="codeblock-011"] figcaption{
padding:0.5rem 0.875rem;
background:var(--vibeui-codeblock-011-head);
border-bottom:1px solid var(--vibeui-codeblock-011-border);
font-family:var(--vibeui-codeblock-011-mono);font-size:0.75rem;
color:var(--vibeui-codeblock-011-muted);
}
[data-vibeui-block="codeblock-011"] pre{
margin:0;padding:0.875rem 0.875rem 1.75rem;
overflow-x:auto;overscroll-behavior-x:contain;
scroll-timeline:--vibeui-codeblock-011-track inline;
}
[data-vibeui-block="codeblock-011"] pre:focus-visible{outline:2px solid var(--vibeui-codeblock-011-accent);outline-offset:-2px}
[data-vibeui-block="codeblock-011"] code{
display:block;min-width:max-content;
font-family:var(--vibeui-codeblock-011-mono);
font-size:0.8125rem;line-height:1.7;white-space:pre;
}
[data-vibeui-block="codeblock-011"] [data-part="edge"]{
position:absolute;top:2.125rem;right:0;bottom:0;width:3rem;pointer-events:none;
background:linear-gradient(to right,oklch(0.21 0.02 60 / 0%),var(--vibeui-codeblock-011-bg));
}
[data-vibeui-block="codeblock-011"] [data-part="hint"]{
position:absolute;right:0.625rem;bottom:0.4375rem;pointer-events:none;
display:inline-flex;align-items:center;gap:0.25rem;
padding:0.125rem 0.4375rem;border-radius:999px;
background:oklch(1 0 0 / 12%);color:var(--vibeui-codeblock-011-accent);
font-size:0.6875rem;font-weight:700;
}
@supports (animation-timeline:scroll()){
[data-vibeui-block="codeblock-011"] [data-part="hint"],
[data-vibeui-block="codeblock-011"] [data-part="edge"]{
animation:vibeui-codeblock-011-fade linear both;
animation-timeline:--vibeui-codeblock-011-track;
animation-range:0% 20%;
}
}
@keyframes vibeui-codeblock-011-fade{from{opacity:1}to{opacity:0}}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="codeblock-011"] *{animation:none!important;transition:none!important}}
`

const CODE = `const columns = [{ key: "name", title: "Название" }, { key: "price", title: "Цена, ₽" }, { key: "stock", title: "Остаток" }]`

/** Блок кода с горизонтальной прокруткой и подсказкой, гаснущей при прокрутке. */
export function Codeblock011({
  title = "table/columns.ts",
  hint = "Прокрутите вправо",
  code = CODE,
  className,
  style,
  ...props
}: Codeblock011Props) {
  return (
    <>
      <style href="vibeui-codeblock-011" precedence="medium">
        {STYLES}
      </style>
      <figure
        {...props}
        data-vibeui-block="codeblock-011"
        className={className}
        style={style as CSSProperties}
      >
        <figcaption>{title}</figcaption>
        <pre tabIndex={0} role="region" aria-label={`Код файла ${title}`}>
          <code>{code}</code>
        </pre>
        <span data-part="edge" aria-hidden="true" />
        <span data-part="hint" aria-hidden="true">
          {hint} →
        </span>
      </figure>
    </>
  )
}