Inputs
Details Tree
A cascader tree built on native details and radios: levels open without JavaScript, and the chosen branch is highlighted all the way up through :has().
- cascader
- details
- no-js
- form
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/cascader-008?lang=en
Уровни — нативные details, лист — radio с общим именем: дерево отправляется обычной формой даже без JavaScript.
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-008" (Details Tree) 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-008.json
Registry item: https://vibeui.ru/r/cascader-008.json
Installs to: components/vibeui/cascader-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 cascader tree built on native details and radios: levels open without JavaScript, and the chosen branch is highlighted all the way up through :has().
A cascading tree on details and radios: opening and picking work without client JS and submit with an ordinary form. One file, zero dependencies, a server component.
## 3. How to use it
import { Cascader008 } from "@/components/vibeui/cascader-008"
<Cascader008 name="destination" heading="Where to file it" />
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-008-* palette — do not swap it for your theme tokens
- one shared name across every radio: without it the form receives several values instead of one
- the path highlight through :has(input:checked) — with collapsed branches the tick is otherwise invisible
- the leaf value as a full path: a leaf name without its branch is ambiguous on the server
- the heading as a paragraph rather than a legend: a floated legend makes sibling flex children wrap around it
- the panel's own light surface: dark text disappears on the dark catalogue card
## 6. You may change
- the form field name through name
- the panel heading through heading
- the tree and its initially open branches through tree
- the accent colour through accent
## 7. Rules
- details cannot animate its height — the arrow rotation is the only animation here and it is disabled by prefers-reduced-motion.
- Open branches reset on a re-render: that state lives in the DOM, not in props.
- Only a leaf is selectable: allowing a branch to be picked needs a radio next to the summary.
- 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-008.jsonhttps://vibeui.ru/r/cascader-008.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-cascader-008-*. Серверный: хуков нет, раскрытие уровней ведёт нативный details, выбор — radio с общим именем, поэтому дерево уходит обычной формой даже без JavaScript. Правило details:has(input:checked) > summary подсвечивает всю цепочку родителей: при свёрнутых уровнях иначе не видно, где стоит отметка. Заголовок сделан абзацем, а не legend: legend с float ломает поток соседних flex-детей.
Component source
The same file your agent installs. Here in case you would rather copy it by hand.
import type { CSSProperties, ReactNode } from "react"
export type Cascader008Node = {
label: string
open?: boolean
children?: Cascader008Node[]
}
export type Cascader008Props = {
name?: string
heading?: string
tree?: Cascader008Node[]
accent?: string
className?: string
style?: CSSProperties
}
// Идея компонента: каскад, который переживёт выключенный JS. Ветки — нативные
// <details>, лист — radio с общим именем, поэтому дерево можно положить в
// обычную форму и отправить POST'ом. Выбранная ветка подсвечивается по всей
// глубине через :has(input:checked): без этого при свёрнутых уровнях
// непонятно, где именно стоит отметка.
const STYLES = `
:where([data-vibeui-block="cascader-008"]){
--vibeui-cascader-008-bg:oklch(1 0 0);
--vibeui-cascader-008-fg:oklch(0.23 0.014 160);
--vibeui-cascader-008-muted:oklch(0.54 0.012 160);
--vibeui-cascader-008-border:oklch(0.9 0.006 160);
--vibeui-cascader-008-accent:oklch(0.5 0.13 165);
--vibeui-cascader-008-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="cascader-008"]{
display:flex;flex-direction:column;gap:0.5rem;
width:100%;max-width:22rem;box-sizing:border-box;padding:0.875rem;
background:var(--vibeui-cascader-008-bg);color:var(--vibeui-cascader-008-fg);
border:1px solid var(--vibeui-cascader-008-border);border-radius:1rem;
font-family:var(--vibeui-cascader-008-font);
box-shadow:0 18px 40px -32px oklch(0.2 0.03 160 / 55%);
}
[data-vibeui-block="cascader-008"] *{box-sizing:border-box}
[data-vibeui-block="cascader-008"] [data-part="legend"]{
padding:0;margin:0 0 0.125rem;font-size:0.8125rem;font-weight:650;
letter-spacing:-0.01em;
}
[data-vibeui-block="cascader-008"] [data-part="set"]{
border:0;margin:0;padding:0;min-width:0;
}
[data-vibeui-block="cascader-008"] [data-part="node"]{
border-radius:0.5rem;
}
[data-vibeui-block="cascader-008"] summary{
display:flex;align-items:center;gap:0.5rem;
padding:0.3125rem 0.4375rem;border-radius:0.5rem;cursor:pointer;
font-size:0.8125rem;list-style:none;
transition:background-color .14s ease,color .14s ease;
}
[data-vibeui-block="cascader-008"] summary::-webkit-details-marker{display:none}
[data-vibeui-block="cascader-008"] summary:hover{
background:color-mix(in oklab,var(--vibeui-cascader-008-accent) 9%,transparent);
}
[data-vibeui-block="cascader-008"] summary:focus-visible{
outline:2px solid var(--vibeui-cascader-008-accent);outline-offset:-2px;
}
[data-vibeui-block="cascader-008"] [data-part="tw"]{
flex:0 0 auto;width:0.375rem;height:0.375rem;
border-right:1.5px solid var(--vibeui-cascader-008-muted);
border-top:1.5px solid var(--vibeui-cascader-008-muted);
transform:rotate(45deg);
transition:transform .16s ease;
}
[data-vibeui-block="cascader-008"] [data-part="node"][open] > summary [data-part="tw"]{
transform:rotate(135deg);
}
/* Отметка может лежать в свёрнутой ветке — подсвечиваем весь путь до неё. */
[data-vibeui-block="cascader-008"] [data-part="node"]:has(input:checked) > summary{
color:var(--vibeui-cascader-008-accent);font-weight:650;
}
[data-vibeui-block="cascader-008"] [data-part="branch"]{
display:flex;flex-direction:column;gap:0.0625rem;
margin:0.125rem 0 0.25rem 0.6875rem;padding:0 0 0 0.6875rem;
border-left:1px solid var(--vibeui-cascader-008-border);
}
[data-vibeui-block="cascader-008"] [data-part="leaf"]{
display:flex;align-items:center;gap:0.5rem;
padding:0.3125rem 0.4375rem;border-radius:0.5rem;cursor:pointer;
font-size:0.78125rem;
transition:background-color .14s ease;
}
[data-vibeui-block="cascader-008"] [data-part="leaf"]:hover{
background:color-mix(in oklab,var(--vibeui-cascader-008-accent) 9%,transparent);
}
[data-vibeui-block="cascader-008"] [data-part="leaf"]:has(input:focus-visible){
outline:2px solid var(--vibeui-cascader-008-accent);outline-offset:-2px;
}
[data-vibeui-block="cascader-008"] [data-part="leaf"]:has(input:checked){
color:var(--vibeui-cascader-008-accent);font-weight:600;
background:color-mix(in oklab,var(--vibeui-cascader-008-accent) 12%,transparent);
}
[data-vibeui-block="cascader-008"] input[type="radio"]{
flex:0 0 auto;width:0.875rem;height:0.875rem;margin:0;
accent-color:var(--vibeui-cascader-008-accent);
}
[data-vibeui-block="cascader-008"] [data-part="hint"]{
margin:0;padding-top:0.5rem;border-top:1px solid var(--vibeui-cascader-008-border);
font-size:0.6875rem;line-height:1.4;color:var(--vibeui-cascader-008-muted);
}
@media (prefers-reduced-motion:reduce){
[data-vibeui-block="cascader-008"] *{animation:none!important;transition:none!important}
}
`
const DEFAULT_TREE: Cascader008Node[] = [
{
label: "Документы",
open: true,
children: [
{
label: "Договоры",
open: true,
children: [
{ label: "Рамочные" },
{ label: "Дополнительные соглашения" },
],
},
{
label: "Бухгалтерия",
children: [{ label: "Счета" }, { label: "Акты" }],
},
],
},
{
label: "Материалы",
children: [
{
label: "Презентации",
children: [{ label: "Для клиентов" }, { label: "Внутренние" }],
},
{ label: "Медиа", children: [{ label: "Логотипы" }, { label: "Фото" }] },
],
},
]
/**
* Дерево на <details> и radio: каскадный выбор без единой строки клиентского JS.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Cascader008({
name = "vibeui-cascader-008",
heading = "Куда положить файл",
tree = DEFAULT_TREE,
accent,
className,
style,
}: Cascader008Props) {
const renderNodes = (nodes: Cascader008Node[], trail: string[]): ReactNode =>
nodes.map((node) => {
const path = [...trail, node.label]
if (!node.children?.length) {
return (
<label key={path.join("/")} data-part="leaf">
<input
type="radio"
name={name}
value={path.join("/")}
defaultChecked={path.join("/") === "Документы/Договоры/Рамочные"}
/>
{node.label}
</label>
)
}
return (
<details key={path.join("/")} data-part="node" open={node.open}>
<summary>
<i data-part="tw" aria-hidden="true" />
{node.label}
</summary>
<div data-part="branch">{renderNodes(node.children, path)}</div>
</details>
)
})
const palette = {
...(accent ? { "--vibeui-cascader-008-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-cascader-008" precedence="medium">
{STYLES}
</style>
<div
data-vibeui-block="cascader-008"
className={className}
style={palette}
>
<fieldset data-part="set">
<p data-part="legend">{heading}</p>
{renderNodes(tree, [])}
</fieldset>
<p data-part="hint">
Уровни — нативные details, лист — radio с общим именем: дерево
отправляется обычной формой даже без JavaScript.
</p>
</div>
</>
)
}