HextaUI

Tree (UI SDK): Lines and small size

variant="lines" draws an indent guide for each open group, and size="sm" makes the rows shorter.

src
components
header.tsx
footer.tsx
main.tsx
vite.config.ts
import { Tree, type TreeItemData } from "@/components/ui/ui-sdk-tree"

const items: TreeItemData[] = [
  {
    value: "src",
    label: "src",
    children: [
      {
        value: "src/components",
        label: "components",
        children: [
          { value: "src/components/header.tsx", label: "header.tsx" },
          { value: "src/components/footer.tsx", label: "footer.tsx" },
        ],
      },
      { value: "src/main.tsx", label: "main.tsx" },
    ],
  },
  { value: "vite.config.ts", label: "vite.config.ts" },
]

function UiSdkTreeLines() {
  return (
    <Tree
      aria-label="Source"
      items={items}
      variant="lines"
      size="sm"
      defaultExpanded={["src", "src/components"]}
      className="max-w-xs"
    />
  )
}

export { UiSdkTreeLines }

This adds the example as components/examples/ui-sdk-tree/lines.tsx, together with the Tree component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/ui-sdk-tree-lines.json

To add only the component, follow the Tree installation.

Props in this example

The Tree props this example sets, from the API reference.

PropTypeDefault
itemsThe whole hierarchy. Without children, the tree renders styled rows from it.
TreeItemData[]–
defaultExpanded
string[]–
variant
"default" | "lines""default"
size
"default" | "sm""default"

Every prop is in the Tree API reference.

See them all, with keyboard support and accessibility notes, on the Tree page.