انتقل إلى المحتوى
TopClass UI

عرض شجري

عقد في مستويات تُفتح وتُغلق. الفروع المفتوحة تُسطَّح في قائمة واحدة تعرض ما يظهر فقط، فتبقى 10,000 عقدة سريعة.

client - الحجم لم يُقَس بعد

عرض شجري

client - الحجم لم يُقَس بعد

عقد في مستويات تُفتح وتُغلق. الفروع المفتوحة تُسطَّح في قائمة واحدة تعرض ما يظهر فقط، فتبقى 10,000 عقدة سريعة.

تثبيت

جرّبه

visibleRows
loadMoreThreshold
status

الشيفرة

tree-view.tsx
import { fileText } from 'topclassui/icons/file-text'
import { folder } from 'topclassui/icons/folder'
import { Svg } from 'topclassui/svg'
import { TreeView, type TreeViewDesignProps } from 'topclassui/tree-view'

<TreeView aria-label="Files" items={ITEMS} defaultExpanded={['src', 'app']} />

items بيانات عادية وأيقونة العقدة عنصر، فيمرّر مكوّن الخادم الشجرة كما هي، ولا يوجد getKey.

كل الحالات، بدون تمرير الفأرة

4 حالات
app
layout.tsx
page.tsx
docs
guide.md
faq.md
next.config.ts
next.config.ts
جارٍ تحميل المزيد
جارٍ التحميل
لا يوجد شيء بعد

أو استورده من الحزمة

topclassui/tree-view
import { TreeView } from 'topclassui/tree-view'

ثبّت مرة واحدة:npm i topclassui@beta zod

أمثلة

  • العقدة هي { id, label, icon?, disabled?, children? }. الـ id هو المفتاح، والعقدة التي تحمل children، ولو []، فرع.
  • لتحميل أبناء فرع، استمع إلى onExpandedChange ومرّرهم عبر items.
  • loadMore يطلب الصفحة التالية من العقد الجذرية، مرة لكل صفحة، ما دام hasMore. الشجرة لا تجلب البيانات أبدًا.
  • visibleRows يحدّد عدد الصفوف الظاهرة قبل أن تُمرَّر الشجرة، وإن لم يُمرَّر يُطبَّق المتغير --tc-list-rows. وvirtualize يعرض ما يظهر فقط فوق 200 صف ظاهر.
  • status يجعل الشجرة مشغولة في loading وloading-more، ويقول إنه لا يوجد شيء في empty.
  • className وstyle وref وكل خاصية أخرى تصل إلى العنصر الذي يحمل role="tree"، لا إلى الصندوق المحيط به.
basic
src
app
layout.tsx
page.tsx
package.json
README.md
selected
Project
app
layout.tsx
page.tsx
next.config.ts
load-more
Repository

Pages asked for: 0, loaded: 1

status
جارٍ التحميل
لا يوجد شيء بعد
ten-thousand
Folder 1
File 1.ts
File 2.ts
File 3.ts
File 4.ts
File 5.ts
File 6.ts
File 7.ts
File 8.ts
File 9.ts
File 10.ts
File 11.ts
File 12.ts
File 13.ts
File 14.ts
File 15.ts
File 16.ts
File 17.ts
File 18.ts
long-content
SupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilistic
تقرير report 2026 النهائي final version with a long name that goes on
Level 1
Level 2
Level 3
Level 4
Level 5
Level 6
Level 7
Level 8
Level 9
Level 10, SupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilisticSupercalifragilistic
Sixty items
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
Item 8
Item 9
Item 10
Item 11
Item 12
Item 13
Item 14
Item 15
Item 16
Item 17
Item 18
Item 19
Item 20
Item 21
Item 22
Item 23
Item 24
Item 25
Item 26
Item 27
Item 28
Item 29
Item 30
Item 31
Item 32
Item 33
Item 34
Item 35
Item 36
Item 37
Item 38
Item 39
Item 40
Item 41
Item 42
Item 43
Item 44
Item 45
Item 46
Item 47
Item 48
Item 49
Item 50
Item 51
Item 52
Item 53
Item 54
Item 55
Item 56
Item 57
Item 58
Item 59
Item 60
بالعربية، من اليمين إلى اليسار
المستندات
التقرير السنوي.pdf
الميزانية.xlsx
ملاحظات.txt

الخصائص

خصائص TreeView
الخاصيةالنوعالافتراضيالحدودالوصف
items*readonly TreeNode[]--The nodes, as plain data. Keep the array stable between renders.
aria-labelstring--The name read out when no visible text names the group.
aria-labelledbystring--The id of the visible text that names the group.
classNamestring--On the element with role tree, merged last.
defaultExpandedreadonly string[]--The ids open when the tree mounts.
defaultValuestring | null--The id selected when the tree mounts.
emptyFallbackReactNode--What status empty says, in place of labels.state.empty.
expandedreadonly string[]--The ids of the open branches. Use with onExpandedChange when controlled.
hasMoreboolean--More root nodes exist, so loadMore is called when the tree nears its end.
loadingFallbackReactNode--What status loading says, in place of labels.common.loading.
loadMore(() => void | Promise<void>)--Called with no argument for the next page of root nodes, once per page; never for a branch. Client-only, or a Server Action.
loadMoreThresholdinteger, min 0, max 20010min 0, max 200How many rows from the end loadMore is called, clamped.
onExpandedChange((ids: readonly string[]) => void)--Called with every open id after a branch opens or closes: load a branch's children here. Client-only.
onValueChange((id: string) => void)--Called with the id of the node Enter, Space or a press selects. Client-only.
statusidle | loading | loading-more | empty"idle"-loading and loading-more mark the tree busy and say so under it; empty says there is nothing.
valuestring | null--The selected node's id, or null for none. Use with onValueChange when controlled.
virtualizeunknown"auto"-auto windows the tree above 200 visible rows; true always, false never.
visibleRowsinteger, min 1, max 207min 1, max 20Rows the tree shows before it scrolls, clamped. Left out, the --tc-list-rows knob applies.

لوحة المفاتيح وإمكانية الوصول

لوحة مفاتيح TreeView
المفاتيحما يفعله
ArrowDownArrowUpالصف الظاهر التالي أو السابق، بلا التفاف.
ArrowRightيفتح فرعًا مغلقًا، وفي الفرع المفتوح ينتقل إلى أول أبنائه. وفي العربية ArrowLeft.
ArrowLeftيغلق فرعًا مفتوحًا، وفي غير ذلك ينتقل إلى الأب. وفي العربية ArrowRight.
HomeEndأول صف ظاهر، وآخر صف ظاهر.
Enterيحدّد الصف، ويفتح الفرع أو يغلقه، والضغط يفعل الشيء نفسه.
Spaceيحدّد الصف.
A–Zالصف التالي الذي يبدأ اسمه بما كُتب خلال آخر 500 ميلي ثانية.
  • الشجرة محطة Tab واحدة وتحتفظ بالتركيز، وaria-activedescendant يسمّي الصف الذي تعمل عليه المفاتيح، فلا يضيع التركيز مع العرض الجزئي.
  • الشجرة لا ترسم اسمًا لنفسها: الأنواع تشترط aria-label أو aria-labelledby.
  • كل صف يحمل مستواه وموضعه بين إخوته وهل هو مفتوح، فيقول قارئ الشاشة أين هو.

من اليمين إلى اليسار

المسافة البادئة على اليمين، والسهم المغلق يشير إلى اليسار. ArrowLeft يفتح الفرع وArrowRight يغلقه.

الخادم والمتصفح

مكوّن متصفح: يُعرض على الخادم ثم يُرطَّب في المتصفح.

الملفات: index.tsx, client.tsx.

على الشارة: client - الحجم لم يُقَس بعد.