Inputs

Level Columns

A column cascader: three levels of the tree stand side by side, the chosen parent stays highlighted on the left, and an empty column holds its place with a hint.

  • cascader
  • columns
  • tree
  • select

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/cascader-002?lang=en

Catalogue section

Путь: Электроника / Ноутбуки

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 "cascader-002" (Level Columns) 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/cascader-002.json

Registry item: https://vibeui.ru/r/cascader-002.json
Installs to: components/vibeui/cascader-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 column cascader: three levels of the tree stand side by side, the chosen parent stays highlighted on the left, and an empty column holds its place with a hint.

A column cascader: three levels visible at once, the chosen path highlighted all the way down, a path line and a reset below. One file, zero dependencies, the only client state is the current path.

## 3. How to use it
import { Cascader002 } from "@/components/vibeui/cascader-002"

<Cascader002 heading="Catalogue section" accent="#4f46e5" />

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-cascader-002-* palette — do not swap it for your theme tokens
- the three permanent slots in the grid: if an empty column disappears, the panel jumps in width on every click
- the fixed grid height with scrolling inside a column — otherwise a long level stretches the whole panel
- trimming the path when a higher level is picked: without it stale columns from the previous branch stay on the right
- aria-current on the selected option — a colour highlight alone is not announced by a screen reader
- the panel's own light surface: dark text disappears on the dark catalogue card

## 6. You may change
- the panel heading through heading
- the accent colour through accent
- the shape and depth of the tree through tree
- the panel width through max-width on the root

## 7. Rules
- A tree deeper than three levels will not fit: a fourth column needs horizontal scrolling of the grid.
- The result is a path array, not a single node: the form logic has to be built around an array.
- At 360 px three 1fr columns get cramped — a stepwise cascader fits that width better.
- 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/cascader-002.json
https://vibeui.ru/r/cascader-002.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-cascader-002-*. Клиентский: путь выбора живёт в useState. Колонки считаются из дерева по текущему пути, но сетка всегда держит три слота — при коротком пути слот занимает подсказка, поэтому панель не меняет ширину на каждый клик. Выбор в колонке обрезает путь до её уровня, поэтому устаревшие правые колонки исчезают сами. Высота сетки фиксирована, прокрутка своя у каждой колонки: иначе длинный уровень растягивает всю панель.

Component source

The same file your agent installs. Here in case you would rather copy it by hand.

"use client"

import { useState } from "react"
import type { CSSProperties } from "react"

export type Cascader002Node = {
  label: string
  children?: Cascader002Node[]
}

export type Cascader002Props = {
  heading?: string
  tree?: Cascader002Node[]
  accent?: string
  className?: string
  style?: CSSProperties
}

// Идея компонента: все уровни дерева видны одновременно — три колонки рядом,
// как в файловом менеджере. Список не перерисовывается на месте, поэтому
// глазами видно, откуда пришёл выбор: родитель остаётся подсвеченным слева.
// Пустые колонки не исчезают, а держат место подсказкой: если колонка
// пропадает, панель прыгает по ширине на каждый клик.
const STYLES = `
:where([data-vibeui-block="cascader-002"]){
--vibeui-cascader-002-bg:oklch(1 0 0);
--vibeui-cascader-002-panel:oklch(0.98 0.003 265);
--vibeui-cascader-002-fg:oklch(0.24 0.014 265);
--vibeui-cascader-002-muted:oklch(0.56 0.014 265);
--vibeui-cascader-002-border:oklch(0.9 0.006 265);
--vibeui-cascader-002-accent:oklch(0.55 0.2 262);
--vibeui-cascader-002-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="cascader-002"]{
display:flex;flex-direction:column;gap:0.625rem;
width:100%;max-width:29rem;box-sizing:border-box;padding:0.875rem;
background:var(--vibeui-cascader-002-bg);color:var(--vibeui-cascader-002-fg);
border:1px solid var(--vibeui-cascader-002-border);border-radius:1rem;
font-family:var(--vibeui-cascader-002-font);
box-shadow:0 18px 40px -32px oklch(0.2 0.03 265 / 60%);
}
[data-vibeui-block="cascader-002"] *{box-sizing:border-box}
[data-vibeui-block="cascader-002"] [data-part="heading"]{
margin:0;font-size:0.8125rem;font-weight:650;letter-spacing:-0.01em;
}
[data-vibeui-block="cascader-002"] [data-part="grid"]{
display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:0.375rem;
height:11.5rem;
}
[data-vibeui-block="cascader-002"] [data-part="column"]{
display:flex;flex-direction:column;gap:0.125rem;margin:0;padding:0.25rem;
list-style:none;overflow:auto;overscroll-behavior:contain;
background:var(--vibeui-cascader-002-panel);
border:1px solid var(--vibeui-cascader-002-border);border-radius:0.75rem;
}
[data-vibeui-block="cascader-002"] [data-part="empty"]{
display:grid;place-items:center;padding:0.5rem;text-align:center;
font-size:0.6875rem;line-height:1.35;color:var(--vibeui-cascader-002-muted);
border:1px dashed var(--vibeui-cascader-002-border);border-radius:0.75rem;
}
[data-vibeui-block="cascader-002"] [data-part="option"]{
display:flex;align-items:center;gap:0.375rem;width:100%;
padding:0.3125rem 0.4375rem;border:0;border-radius:0.5rem;
background:transparent;color:inherit;font:inherit;font-size:0.8125rem;
text-align:left;cursor:pointer;
transition:background-color .14s ease,color .14s ease;
}
[data-vibeui-block="cascader-002"] [data-part="option"] span{
flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
[data-vibeui-block="cascader-002"] [data-part="option"]:hover{
background:color-mix(in oklab,var(--vibeui-cascader-002-accent) 10%,transparent);
}
[data-vibeui-block="cascader-002"] [data-part="option"]:focus-visible{
outline:2px solid var(--vibeui-cascader-002-accent);outline-offset:-2px;
}
[data-vibeui-block="cascader-002"] [data-part="option"][aria-current="true"]{
background:color-mix(in oklab,var(--vibeui-cascader-002-accent) 16%,transparent);
color:var(--vibeui-cascader-002-accent);font-weight:600;
}
[data-vibeui-block="cascader-002"] [data-part="arrow"]{
flex:0 0 auto;width:0.3125rem;height:0.3125rem;
border-right:1.5px solid currentColor;border-top:1.5px solid currentColor;
transform:rotate(45deg);opacity:.55;
}
[data-vibeui-block="cascader-002"] [data-part="footer"]{
display:flex;align-items:center;justify-content:space-between;gap:0.5rem;
padding-top:0.5rem;border-top:1px solid var(--vibeui-cascader-002-border);
}
[data-vibeui-block="cascader-002"] [data-part="path"]{
margin:0;min-width:0;font-size:0.75rem;line-height:1.35;
color:var(--vibeui-cascader-002-muted);
}
[data-vibeui-block="cascader-002"] [data-part="path"] b{
color:var(--vibeui-cascader-002-fg);font-weight:650;
}
[data-vibeui-block="cascader-002"] [data-part="reset"]{
flex:0 0 auto;padding:0.3125rem 0.625rem;border-radius:0.5rem;cursor:pointer;
border:1px solid var(--vibeui-cascader-002-border);
background:var(--vibeui-cascader-002-bg);color:var(--vibeui-cascader-002-muted);
font:inherit;font-size:0.75rem;
transition:color .14s ease,border-color .14s ease;
}
[data-vibeui-block="cascader-002"] [data-part="reset"]:hover{
color:var(--vibeui-cascader-002-fg);border-color:var(--vibeui-cascader-002-accent);
}
[data-vibeui-block="cascader-002"] [data-part="reset"]:focus-visible{
outline:2px solid var(--vibeui-cascader-002-accent);outline-offset:2px;
}
@media (prefers-reduced-motion:reduce){
[data-vibeui-block="cascader-002"] *{animation:none!important;transition:none!important}
}
`

const DEFAULT_TREE: Cascader002Node[] = [
  {
    label: "Электроника",
    children: [
      {
        label: "Ноутбуки",
        children: [
          { label: "До 14 дюймов" },
          { label: "15–16 дюймов" },
          { label: "Игровые" },
        ],
      },
      {
        label: "Смартфоны",
        children: [{ label: "Флагманы" }, { label: "Бюджетные" }],
      },
      {
        label: "Наушники",
        children: [{ label: "Полноразмерные" }, { label: "Вкладыши" }],
      },
    ],
  },
  {
    label: "Дом и сад",
    children: [
      {
        label: "Освещение",
        children: [{ label: "Люстры" }, { label: "Торшеры" }],
      },
      { label: "Текстиль", children: [{ label: "Шторы" }, { label: "Пледы" }] },
    ],
  },
  {
    label: "Инструменты",
    children: [
      {
        label: "Ручной инструмент",
        children: [{ label: "Отвёртки" }, { label: "Ключи" }],
      },
      {
        label: "Электроинструмент",
        children: [{ label: "Дрели" }, { label: "Шлифмашины" }],
      },
    ],
  },
]

function columnsFor(tree: Cascader002Node[], path: string[]) {
  const columns: Cascader002Node[][] = [tree]
  let nodes = tree

  for (const step of path) {
    const found = nodes.find((node) => node.label === step)

    if (!found?.children?.length) {
      break
    }

    columns.push(found.children)
    nodes = found.children
  }

  return columns
}

/**
 * Каскадный выбор колонками: все уровни дерева видны одновременно.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Cascader002({
  heading = "Раздел каталога",
  tree = DEFAULT_TREE,
  accent,
  className,
  style,
}: Cascader002Props) {
  const [path, setPath] = useState<string[]>(["Электроника", "Ноутбуки"])
  const columns = columnsFor(tree, path)
  const slots = [columns[0], columns[1], columns[2]]

  const palette = {
    ...(accent ? { "--vibeui-cascader-002-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-cascader-002" precedence="medium">
        {STYLES}
      </style>
      <div
        data-vibeui-block="cascader-002"
        className={className}
        style={palette}
      >
        <p data-part="heading">{heading}</p>
        <div data-part="grid">
          {slots.map((nodes, level) =>
            nodes ? (
              <ul
                key={level}
                data-part="column"
                aria-label={`Уровень ${level + 1}`}
              >
                {nodes.map((node) => (
                  <li key={node.label}>
                    <button
                      data-part="option"
                      type="button"
                      aria-current={
                        path[level] === node.label ? "true" : undefined
                      }
                      onClick={() =>
                        setPath([...path.slice(0, level), node.label])
                      }
                    >
                      <span>{node.label}</span>
                      {node.children?.length ? (
                        <i data-part="arrow" aria-hidden="true" />
                      ) : null}
                    </button>
                  </li>
                ))}
              </ul>
            ) : (
              <p key={level} data-part="empty">
                Выберите слева
              </p>
            ),
          )}
        </div>
        <div data-part="footer">
          <p data-part="path" aria-live="polite">
            Путь: <b>{path.length ? path.join(" / ") : "не выбран"}</b>
          </p>
          <button
            data-part="reset"
            type="button"
            onClick={() => setPath([])}
            disabled={path.length === 0}
          >
            Сбросить
          </button>
        </div>
      </div>
    </>
  )
}