@eluan/core 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -1
- package/dist/{action-popover-D6K9aVFk.cjs → action-popover-DrHKPGqw.cjs} +1 -1
- package/dist/{action-popover-BVJQBuky.js → action-popover-NkXDAHJT.js} +1 -1
- package/dist/action-popover.cjs +1 -1
- package/dist/action-popover.js +1 -1
- package/dist/{avatar-Co-k8KqV.cjs → avatar-B-t3ctR4.cjs} +1 -1
- package/dist/{avatar-CS5f1irF.js → avatar-kDEa0rjF.js} +1 -1
- package/dist/avatar.cjs +1 -1
- package/dist/avatar.js +1 -1
- package/dist/{badge-D9NYZFWH.js → badge-BLZ8V-KC.js} +10 -10
- package/dist/{badge-DXKWztL-.cjs → badge-D1A0Tc79.cjs} +1 -1
- package/dist/badge.cjs +1 -1
- package/dist/badge.js +1 -1
- package/dist/{banner-COlEFRuK.cjs → banner-CNdwDPqA.cjs} +1 -1
- package/dist/{banner-CyYFLZXw.js → banner-DzSp5WfQ.js} +9 -9
- package/dist/banner.cjs +1 -1
- package/dist/banner.js +1 -1
- package/dist/box-DG-tkaYi.cjs +1 -0
- package/dist/box-DKbNgGGG.js +17 -0
- package/dist/box.cjs +1 -0
- package/dist/box.d.ts +1 -0
- package/dist/box.js +5 -0
- package/dist/{breadcrumb-NWXeCH5q.cjs → breadcrumb-BuxXkm6O.cjs} +1 -1
- package/dist/{breadcrumb-Cm1nb9Xj.js → breadcrumb-C6qj-tDx.js} +1 -1
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/button--_WI-fM6.cjs +1 -0
- package/dist/{button-ANAPDrvs.js → button-DNSNShUc.js} +28 -26
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -1
- package/dist/{calendar-BpBsomy5.js → calendar-BA2tSwZD.js} +6 -6
- package/dist/{calendar-7LX5YGGT.cjs → calendar-DS5821-k.cjs} +3 -3
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.js +1 -1
- package/dist/{card-C88--zB4.cjs → card-BNdR5aDa.cjs} +1 -1
- package/dist/{card-BC_4C3ns.js → card-BSgN7WSe.js} +1 -1
- package/dist/card.cjs +1 -1
- package/dist/card.js +1 -1
- package/dist/{carousel-BfL7oy_q.cjs → carousel-4AERgboz.cjs} +1 -1
- package/dist/{carousel-DuP0hvF-.js → carousel-Bb7jpzep.js} +1 -1
- package/dist/carousel.cjs +1 -1
- package/dist/carousel.js +1 -1
- package/dist/{checkbox-Bi0Kmuut.js → checkbox-CGUTGery.js} +1 -1
- package/dist/{checkbox-M8DmWKiC.cjs → checkbox-Cq9sHU_S.cjs} +1 -1
- package/dist/{checkbox-group-KBwPhjmW.cjs → checkbox-group-DGXZ4o2-.cjs} +1 -1
- package/dist/{checkbox-group-CQMEJnhD.js → checkbox-group-Tkio3IhK.js} +1 -1
- package/dist/checkbox-group.cjs +1 -1
- package/dist/checkbox-group.js +1 -1
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.js +1 -1
- package/dist/{command-BCl0seLL.cjs → command-D02vvta9.cjs} +1 -1
- package/dist/{command-Chs5VlBL.js → command-sUMAxm8S.js} +1 -1
- package/dist/command.cjs +1 -1
- package/dist/command.js +1 -1
- package/dist/components/box.d.ts +12 -0
- package/dist/components/grid.d.ts +35 -0
- package/dist/components/hover-card.d.ts +14 -2
- package/dist/components/icon.d.ts +26 -0
- package/dist/components/layout-shared.d.ts +307 -0
- package/dist/components/multi-select.d.ts +1 -1
- package/dist/components/navigation-drawer.d.ts +25 -5
- package/dist/components/row.d.ts +18 -0
- package/dist/components/stack.d.ts +14 -0
- package/dist/components/tone-shared.d.ts +39 -0
- package/dist/components/tooltip.d.ts +14 -2
- package/dist/components/typography.d.ts +22 -2
- package/dist/components/visually-hidden.d.ts +11 -0
- package/dist/{credit-card-input-DN-8vaFj.js → credit-card-input-9VPlzvDm.js} +1 -1
- package/dist/{credit-card-input-CUqA9CX3.cjs → credit-card-input-DppPJBne.cjs} +1 -1
- package/dist/credit-card-input.cjs +1 -1
- package/dist/credit-card-input.js +1 -1
- package/dist/{date-picker-ni8td8Ru.js → date-picker-M5hLx_1s.js} +2 -2
- package/dist/{date-picker-DGBsfZXx.cjs → date-picker-hE7cDg2B.cjs} +1 -1
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.js +1 -1
- package/dist/{datetime-picker-C1d63MaA.cjs → datetime-picker-BeRUPJ7s.cjs} +1 -1
- package/dist/{datetime-picker-DsnHYRK-.js → datetime-picker-CIqBZYMH.js} +3 -3
- package/dist/datetime-picker.cjs +1 -1
- package/dist/datetime-picker.js +1 -1
- package/dist/{decimal-input-yTk35W_5.js → decimal-input-Bg2BPKIr.js} +38 -38
- package/dist/decimal-input-CkTEjo2J.cjs +1 -0
- package/dist/decimal-input.cjs +1 -1
- package/dist/decimal-input.js +1 -1
- package/dist/{dialog-B8eWKqzS.js → dialog-Bsfviqvy.js} +2 -2
- package/dist/dialog-DRAoumvB.cjs +1 -0
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +1 -1
- package/dist/{email-input-DFI4h_KN.cjs → email-input-CehmtNUq.cjs} +1 -1
- package/dist/{email-input-pX0hlYV3.js → email-input-DIiY9Q3S.js} +1 -1
- package/dist/email-input.cjs +1 -1
- package/dist/email-input.js +1 -1
- package/dist/{footer-DB0_-IwN.cjs → footer-fovIsy-0.cjs} +1 -1
- package/dist/{footer-B3KUIwXW.js → footer-jWaFq3qk.js} +9 -9
- package/dist/footer.cjs +1 -1
- package/dist/footer.js +1 -1
- package/dist/grid-BDz4Xs6M.cjs +1 -0
- package/dist/grid-BX5vZjDo.js +612 -0
- package/dist/grid.cjs +1 -0
- package/dist/grid.d.ts +1 -0
- package/dist/grid.js +5 -0
- package/dist/{header-CDOWlOAR.js → header-Dnf8AnIx.js} +2 -2
- package/dist/{header-CiZQY_7S.cjs → header-DzItWqW4.cjs} +1 -1
- package/dist/header.cjs +1 -1
- package/dist/header.js +1 -1
- package/dist/hover-card-C5KsTSZR.cjs +1 -0
- package/dist/hover-card-C_FCzE41.js +21 -0
- package/dist/hover-card.cjs +1 -1
- package/dist/hover-card.js +1 -1
- package/dist/icon-BmLOodCQ.cjs +1 -0
- package/dist/icon-BwDfkIdR.js +153 -0
- package/dist/icon.cjs +1 -0
- package/dist/icon.d.ts +1 -0
- package/dist/icon.js +5 -0
- package/dist/index.cjs +10 -5
- package/dist/index.d.ts +6 -0
- package/dist/index.js +612 -541
- package/dist/{input-BrGJn-D9.cjs → input-BcjL2oxv.cjs} +1 -1
- package/dist/{input-Cccufiqn.js → input-CPb9yVU5.js} +8 -8
- package/dist/input-otp-BhJ3ERrY.cjs +1 -0
- package/dist/{input-otp-DmEGB1nu.js → input-otp-CTvJztkH.js} +32 -32
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.js +1 -1
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/layout-shared-B_1iX4Hj.js +319 -0
- package/dist/layout-shared-CsBZcT4V.cjs +1 -0
- package/dist/multi-select-CVxkWW29.js +85 -0
- package/dist/multi-select-DBFINH3F.cjs +1 -0
- package/dist/multi-select.cjs +1 -1
- package/dist/multi-select.js +1 -1
- package/dist/navigation-drawer-BCBFtLEq.cjs +1 -0
- package/dist/navigation-drawer-BMyHXhhX.js +198 -0
- package/dist/navigation-drawer.cjs +1 -1
- package/dist/navigation-drawer.js +1 -1
- package/dist/{number-input-vICbRc2y.js → number-input-Cm9YPBOX.js} +1 -1
- package/dist/{number-input-Bc7jUsu-.cjs → number-input-Dr9MbuRV.cjs} +1 -1
- package/dist/number-input.cjs +1 -1
- package/dist/number-input.js +1 -1
- package/dist/{pagination-DTWRjiOm.js → pagination-D2tjMpVU.js} +2 -2
- package/dist/{pagination-4IuE_APs.cjs → pagination-yKmFlFMR.cjs} +1 -1
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.js +1 -1
- package/dist/{password-input-BwnlHPbX.cjs → password-input-CmHubHuU.cjs} +1 -1
- package/dist/{password-input-B9V45d3Q.js → password-input-ljwdGCO6.js} +2 -2
- package/dist/password-input.cjs +1 -1
- package/dist/password-input.js +1 -1
- package/dist/{phone-input-BQjZj5jI.cjs → phone-input-B8VksCer.cjs} +1 -1
- package/dist/{phone-input-CSBpGHvI.js → phone-input-qTL6K8rT.js} +2 -2
- package/dist/phone-input.cjs +1 -1
- package/dist/phone-input.js +1 -1
- package/dist/progress-BpdmBGaX.cjs +1 -0
- package/dist/{progress-Dz_it5I-.js → progress-ChFf9bIq.js} +1 -1
- package/dist/progress.cjs +1 -1
- package/dist/progress.js +1 -1
- package/dist/providers/create-theme.d.ts +10 -1
- package/dist/providers/eluan-provider.d.ts +2 -1
- package/dist/providers/portal-container.d.ts +1 -1
- package/dist/{radio-group-C--1neiq.cjs → radio-group-9gozRouT.cjs} +1 -1
- package/dist/{radio-group-CNMPZx_2.js → radio-group-Bs9933bk.js} +6 -6
- package/dist/radio-group.cjs +1 -1
- package/dist/radio-group.js +1 -1
- package/dist/{rich-text-BZSyuYSo.js → rich-text-DImwK9hN.js} +1 -1
- package/dist/{rich-text-DerWxzdn.cjs → rich-text-DzHLeG7W.cjs} +1 -1
- package/dist/rich-text.cjs +1 -1
- package/dist/rich-text.js +1 -1
- package/dist/row-BYAk7G5d.js +37 -0
- package/dist/row-Bjn-GQAC.cjs +1 -0
- package/dist/row.cjs +1 -0
- package/dist/row.d.ts +1 -0
- package/dist/row.js +5 -0
- package/dist/{search-input-Dmmo-BEL.cjs → search-input-BKTjebg7.cjs} +1 -1
- package/dist/{search-input-bFNW6oiE.js → search-input-Dgr9kT1a.js} +1 -1
- package/dist/search-input.cjs +1 -1
- package/dist/search-input.js +1 -1
- package/dist/select-Cdh991T-.cjs +1 -0
- package/dist/{select-DDSYjKtj.js → select-Dp5AJ6I-.js} +15 -15
- package/dist/select.cjs +1 -1
- package/dist/select.js +1 -1
- package/dist/sheet-CkXjinUG.cjs +1 -0
- package/dist/{sheet-D5HWF66e.js → sheet-uiyHNKEw.js} +6 -6
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.js +1 -1
- package/dist/{slider-CZQBAXup.js → slider-BQmbh0Nl.js} +1 -1
- package/dist/{slider-DdEOapYP.cjs → slider-DK2yk-YK.cjs} +1 -1
- package/dist/slider.cjs +1 -1
- package/dist/slider.js +1 -1
- package/dist/stack-Ck1w2iJu.cjs +1 -0
- package/dist/stack-D2btWM1t.js +27 -0
- package/dist/stack.cjs +1 -0
- package/dist/stack.d.ts +1 -0
- package/dist/stack.js +5 -0
- package/dist/{stepper-D5nDwJUz.cjs → stepper-ByYKX7qw.cjs} +1 -1
- package/dist/{stepper-BtlKiHtd.js → stepper-Copsj87A.js} +4 -4
- package/dist/stepper.cjs +1 -1
- package/dist/stepper.js +1 -1
- package/dist/styles.css +935 -59
- package/dist/{switch-KzBijHMJ.cjs → switch-C2OPCq5Z.cjs} +1 -1
- package/dist/{switch-C7EBLT5H.js → switch-CXBWUZcq.js} +3 -3
- package/dist/switch.cjs +1 -1
- package/dist/switch.js +1 -1
- package/dist/{tabs-DztJ2iVc.cjs → tabs-D8p6Tr5i.cjs} +1 -1
- package/dist/{tabs-C9NKBmH0.js → tabs-TV4_2wi1.js} +9 -9
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.js +1 -1
- package/dist/{textarea-Dl-daLHR.cjs → textarea-BnpQmE74.cjs} +1 -1
- package/dist/{textarea-DXUk1b_-.js → textarea-CJRmnazN.js} +1 -1
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.js +1 -1
- package/dist/{time-input-BPoFvoeM.js → time-input-A603mEFQ.js} +38 -38
- package/dist/time-input-qxljhdEb.cjs +1 -0
- package/dist/time-input.cjs +1 -1
- package/dist/time-input.js +1 -1
- package/dist/{toggle-Dv1VZ5Le.js → toggle-Bx3q15Pu.js} +6 -6
- package/dist/{toggle-Bvh1v32T.cjs → toggle-Z3t4jPdv.cjs} +1 -1
- package/dist/{toggle-group-SyHMwO90.cjs → toggle-group-BZIW4wJp.cjs} +1 -1
- package/dist/{toggle-group-DE8BPZih.js → toggle-group-LaZmOMx_.js} +7 -7
- package/dist/toggle-group.cjs +1 -1
- package/dist/toggle-group.js +1 -1
- package/dist/toggle.cjs +1 -1
- package/dist/toggle.js +1 -1
- package/dist/tooltip-DZqn4wKl.js +23 -0
- package/dist/tooltip-faf1dIXp.cjs +1 -0
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.js +1 -1
- package/dist/{tree-view-CyeJR7cW.js → tree-view-DRmm6oL6.js} +23 -23
- package/dist/tree-view-DVQyRQDg.cjs +1 -0
- package/dist/tree-view.cjs +1 -1
- package/dist/tree-view.js +1 -1
- package/dist/visually-hidden-BQMRYGxP.js +14 -0
- package/dist/visually-hidden-DzxxOswl.cjs +1 -0
- package/dist/visually-hidden.cjs +1 -0
- package/dist/visually-hidden.d.ts +1 -0
- package/dist/visually-hidden.js +5 -0
- package/package.json +8 -8
- package/skills/eluan/DESIGN.md +409 -0
- package/skills/eluan/SKILL.md +166 -0
- package/skills/eluan/components/accordion.md +212 -0
- package/skills/eluan/components/action-popover.md +266 -0
- package/skills/eluan/components/aspect-ratio.md +169 -0
- package/skills/eluan/components/avatar.md +277 -0
- package/skills/eluan/components/badge.md +190 -0
- package/skills/eluan/components/banner.md +247 -0
- package/skills/eluan/components/box.md +166 -0
- package/skills/eluan/components/breadcrumb.md +240 -0
- package/skills/eluan/components/button.md +214 -0
- package/skills/eluan/components/calendar.md +192 -0
- package/skills/eluan/components/card.md +270 -0
- package/skills/eluan/components/carousel.md +274 -0
- package/skills/eluan/components/checkbox-group.md +228 -0
- package/skills/eluan/components/checkbox.md +226 -0
- package/skills/eluan/components/code-block.md +193 -0
- package/skills/eluan/components/collapsible.md +240 -0
- package/skills/eluan/components/command.md +359 -0
- package/skills/eluan/components/context-menu.md +296 -0
- package/skills/eluan/components/credit-card-input.md +217 -0
- package/skills/eluan/components/date-picker.md +255 -0
- package/skills/eluan/components/date-time-picker.md +196 -0
- package/skills/eluan/components/decimal-input.md +232 -0
- package/skills/eluan/components/dialog.md +322 -0
- package/skills/eluan/components/drawer.md +292 -0
- package/skills/eluan/components/dropdown-menu.md +450 -0
- package/skills/eluan/components/email-input.md +200 -0
- package/skills/eluan/components/fieldset.md +219 -0
- package/skills/eluan/components/file-input.md +249 -0
- package/skills/eluan/components/footer.md +290 -0
- package/skills/eluan/components/form-label.md +254 -0
- package/skills/eluan/components/grid.md +192 -0
- package/skills/eluan/components/header.md +242 -0
- package/skills/eluan/components/hover-card.md +215 -0
- package/skills/eluan/components/icon.md +161 -0
- package/skills/eluan/components/input-otp.md +227 -0
- package/skills/eluan/components/input.md +249 -0
- package/skills/eluan/components/kbd.md +216 -0
- package/skills/eluan/components/media.md +244 -0
- package/skills/eluan/components/menubar.md +300 -0
- package/skills/eluan/components/multi-select.md +221 -0
- package/skills/eluan/components/navigation-drawer.md +297 -0
- package/skills/eluan/components/navigation-menu.md +291 -0
- package/skills/eluan/components/number-input.md +190 -0
- package/skills/eluan/components/pagination.md +262 -0
- package/skills/eluan/components/password-input.md +218 -0
- package/skills/eluan/components/phone-input.md +205 -0
- package/skills/eluan/components/popover.md +250 -0
- package/skills/eluan/components/progress.md +185 -0
- package/skills/eluan/components/radio-group.md +232 -0
- package/skills/eluan/components/rich-text.md +195 -0
- package/skills/eluan/components/row.md +174 -0
- package/skills/eluan/components/scroll-area.md +203 -0
- package/skills/eluan/components/search-input.md +281 -0
- package/skills/eluan/components/segmented-control.md +201 -0
- package/skills/eluan/components/select.md +296 -0
- package/skills/eluan/components/separator.md +179 -0
- package/skills/eluan/components/sheet.md +326 -0
- package/skills/eluan/components/skeleton.md +202 -0
- package/skills/eluan/components/slider.md +195 -0
- package/skills/eluan/components/spinner.md +187 -0
- package/skills/eluan/components/stack.md +158 -0
- package/skills/eluan/components/stepper.md +236 -0
- package/skills/eluan/components/switch.md +218 -0
- package/skills/eluan/components/table.md +348 -0
- package/skills/eluan/components/tabs.md +277 -0
- package/skills/eluan/components/textarea.md +202 -0
- package/skills/eluan/components/time-input.md +181 -0
- package/skills/eluan/components/toast.md +251 -0
- package/skills/eluan/components/toggle-group.md +241 -0
- package/skills/eluan/components/toggle.md +198 -0
- package/skills/eluan/components/tooltip.md +222 -0
- package/skills/eluan/components/tree-view.md +213 -0
- package/skills/eluan/components/typography.md +207 -0
- package/skills/eluan/components/visually-hidden.md +132 -0
- package/skills/eluan/foundations/colour.md +252 -0
- package/skills/eluan/foundations/elevation.md +57 -0
- package/skills/eluan/foundations/iconography.md +70 -0
- package/skills/eluan/foundations/motion.md +60 -0
- package/skills/eluan/foundations/radius.md +61 -0
- package/skills/eluan/foundations/spacing.md +98 -0
- package/skills/eluan/foundations/theming.md +197 -0
- package/skills/eluan/foundations/typography.md +163 -0
- package/skills/eluan/patterns/empty-states.md +84 -0
- package/skills/eluan/patterns/feedback.md +95 -0
- package/skills/eluan/patterns/forms.md +138 -0
- package/skills/eluan/patterns/navigation.md +95 -0
- package/skills/eluan/patterns/page-layout.md +101 -0
- package/dist/button-Ny6OF8Un.cjs +0 -1
- package/dist/decimal-input-BLmifKF2.cjs +0 -1
- package/dist/dialog-DWYtFhZl.cjs +0 -1
- package/dist/hover-card-BN7Ew2Y1.js +0 -16
- package/dist/hover-card-Dft-08Ha.cjs +0 -1
- package/dist/input-otp-DcZ7wyjs.cjs +0 -1
- package/dist/multi-select-DPoOHWSC.js +0 -74
- package/dist/multi-select-fX5FXYEY.cjs +0 -1
- package/dist/navigation-drawer-BbeDYPhu.js +0 -171
- package/dist/navigation-drawer-DOOHfbY3.cjs +0 -1
- package/dist/progress-DpQjGEyn.cjs +0 -1
- package/dist/select-1Eb3NSrR.cjs +0 -1
- package/dist/sheet-7NP1LuHy.cjs +0 -1
- package/dist/time-input-DR2snTgB.cjs +0 -1
- package/dist/tooltip-BlCQKhUE.js +0 -18
- package/dist/tooltip-Cyu7fWYZ.cjs +0 -1
- package/dist/tree-view-CNvEc1TT.cjs +0 -1
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: TreeView
|
|
3
|
+
use_when: Showing hierarchical data the user expands and picks from, such as a file explorer, a folder picker or a category tree.
|
|
4
|
+
instead_of: Accordion for stacked content sections; NavigationDrawer for app navigation; nested lists you build yourself.
|
|
5
|
+
source: packages/core/src/components/tree-view.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# TreeView
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
TreeView renders nested data as an expandable tree. You pass an array of `TreeNode` objects; parents expand and collapse, any node can be selected, and folder and file icons are added for you. Selection is always controlled by you; expansion can be controlled or left to the component.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- File and folder structures: a project explorer, an asset library.
|
|
17
|
+
- Picking one node from a hierarchy: a category, a folder to move items into.
|
|
18
|
+
- Org charts or taxonomies the user browses level by level.
|
|
19
|
+
|
|
20
|
+
### When not to use
|
|
21
|
+
|
|
22
|
+
- Stacked sections of content → use [Accordion](./accordion.md).
|
|
23
|
+
- App or site navigation → use [NavigationDrawer](./navigation-drawer.md) or [NavigationMenu](./navigation-menu.md); see [navigation.md](../patterns/navigation.md).
|
|
24
|
+
- Flat records with the same fields → use [Table](./table.md).
|
|
25
|
+
- Picking several items from a flat list → use [MultiSelect](./multi-select.md) or [CheckboxGroup](./checkbox-group.md).
|
|
26
|
+
- A single show/hide region → use [Collapsible](./collapsible.md).
|
|
27
|
+
|
|
28
|
+
## 3. Anatomy
|
|
29
|
+
|
|
30
|
+
1. **Tree**: the root `<div>`, a column of rows with a `--spacing-xxs` gap.
|
|
31
|
+
2. **Row**: one `<button>` per node, full width, `--font-size-sm`, `--curves-md` corners.
|
|
32
|
+
3. **Chevron**: on parent rows, points right when collapsed and down when expanded. Leaf rows reserve the same space so icons line up.
|
|
33
|
+
4. **Icon** (optional): a folder (closed or open) for parents, a file for leaves, or the node's own `icon`. Fills a `--size-xxs` box.
|
|
34
|
+
5. **Label**: the node's `name`, on one line with an ellipsis when it doesn't fit.
|
|
35
|
+
6. **Group**: the container for a parent's children, indented one chevron slot plus the row gap per level.
|
|
36
|
+
|
|
37
|
+
## 4. Variants
|
|
38
|
+
|
|
39
|
+
TreeView has no `variant` prop. `showIcons={false}` hides the folder, file and custom icons; chevrons stay.
|
|
40
|
+
|
|
41
|
+
## 5. Sizes
|
|
42
|
+
|
|
43
|
+
TreeView has no size prop. Rows use `--font-size-sm` and `--spacing-xs` vertical padding, and the indent is built from `--size-xxs` and `--spacing-sm`, so everything follows density. `indentSize` replaces the indent with a raw pixel value; leave it unset.
|
|
44
|
+
|
|
45
|
+
## 6. States
|
|
46
|
+
|
|
47
|
+
| State | Looks like | Notes |
|
|
48
|
+
| --- | --- | --- |
|
|
49
|
+
| Default | Transparent row, `--interactive-fg` text, muted icons | |
|
|
50
|
+
| Hover | `--interactive-bg-hover` row background | |
|
|
51
|
+
| Focus | 1px ring in `--focus-ring`, drawn with a shadow | Never remove or restyle the focus ring. |
|
|
52
|
+
| Selected | `--interactive-bg-selected` background, `--interactive-fg-selected` text and icons | A near-black row in the default theme. |
|
|
53
|
+
| Expanded | Chevron points down; parent icon becomes an open folder; children slide open | |
|
|
54
|
+
|
|
55
|
+
## 7. Content guidelines
|
|
56
|
+
|
|
57
|
+
- Use the item's real name as `name`: file names keep their extension and case ("README.md").
|
|
58
|
+
- Keep names short; long names are cut with an ellipsis and the full text isn't shown on hover.
|
|
59
|
+
- Order children the way users expect to scan them, for example folders first, then files, each alphabetical.
|
|
60
|
+
|
|
61
|
+
| Do | Don't |
|
|
62
|
+
| --- | --- |
|
|
63
|
+
| `components` | `Components Folder` |
|
|
64
|
+
| `button.tsx` | `button` (extension dropped) |
|
|
65
|
+
|
|
66
|
+
## 8. Rules
|
|
67
|
+
|
|
68
|
+
1. Give TreeView an `aria-label` that says what the tree holds: "Project files".
|
|
69
|
+
2. Keep `selectedId` in your state and update it from `onSelect`. TreeView has no internal selection, so without this nothing looks selected.
|
|
70
|
+
3. To open nodes on first render, control expansion with `expandedIds` and `onExpandChange`; there's no default-expanded prop.
|
|
71
|
+
4. Give every node a unique, stable `id`. Put your own payload in `data`; it comes back in `onSelect`.
|
|
72
|
+
5. An empty folder (`children: []`) renders as a leaf with a file icon. Pass `icon={<Folder />}` for it.
|
|
73
|
+
6. Pass custom icons as Lucide elements without sizing; TreeView sizes them to its icon box.
|
|
74
|
+
7. Leave `indentSize` unset. It's raw pixels and breaks density scaling.
|
|
75
|
+
8. Never pass `className` or `style`; they're dropped. Size and frame the tree with a wrapper.
|
|
76
|
+
|
|
77
|
+
## 9. Dos and don'ts
|
|
78
|
+
|
|
79
|
+
**Do:** control selection and name the tree.
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
const [selectedId, setSelectedId] = React.useState<string>();
|
|
83
|
+
|
|
84
|
+
<TreeView aria-label="Project files" data={files} selectedId={selectedId} onSelect={(node) => setSelectedId(node.id)} />
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Don't:** expect clicks to select on their own, or leave the tree unnamed.
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
<TreeView data={files} />
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Do:** let TreeView size custom icons.
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
const files: TreeNode[] = [{ id: "logo", name: "logo.svg", icon: <FileImage /> }];
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Don't:** size icons or the indent in pixels.
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
const files: TreeNode[] = [{ id: "logo", name: "logo.svg", icon: <FileImage size={16} /> }];
|
|
103
|
+
|
|
104
|
+
<TreeView data={files} indentSize={24} />
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## 10. Accessibility
|
|
108
|
+
|
|
109
|
+
- Role: the root is a `tree`, each row a `treeitem` with `aria-selected`, and each children container a `group`. Parent rows also get `aria-expanded` and `aria-controls`.
|
|
110
|
+
- Label: pass `aria-label` (or `aria-labelledby`) to TreeView; it has no name by default. Each row is named by its `name`; icons are `aria-hidden`.
|
|
111
|
+
- Keyboard: every visible row is a button in the Tab order. Enter or Space selects the row, and on a parent also toggles it. There's no arrow-key movement, roving focus or typeahead, which the WAI-ARIA tree pattern expects.
|
|
112
|
+
- Focus: stays on the row after selecting or toggling. Collapsing a parent hides its children, so focus never sits on a hidden row.
|
|
113
|
+
- Contrast: handled by the theme. Don't override colours.
|
|
114
|
+
|
|
115
|
+
## 11. Behaviour
|
|
116
|
+
|
|
117
|
+
- Clicking a parent selects it and toggles it in one action. If parents shouldn't be selectable, ignore parent nodes in `onSelect` (check `node.children?.length`).
|
|
118
|
+
- Responsive: TreeView fills its parent's width. Put it in a fixed-width panel and wrap that in [ScrollArea](./scroll-area.md) for long trees.
|
|
119
|
+
- Overflow and truncation: labels stay on one line and truncate with an ellipsis; there's no tooltip with the full name.
|
|
120
|
+
- Motion: chevrons turn over 150ms and children expand and collapse over 200ms; both animations drop to near zero under reduced motion. Don't add your own.
|
|
121
|
+
|
|
122
|
+
## 12. API
|
|
123
|
+
|
|
124
|
+
<!-- api:start -->
|
|
125
|
+
| Prop | Type | Default | Description |
|
|
126
|
+
| --- | --- | --- | --- |
|
|
127
|
+
| `data` | `TreeNode[]` | | Required. The nodes to render. `TreeNode` is `{ id: string; name: string; icon?: ReactNode; children?: TreeNode[]; data?: unknown }`. |
|
|
128
|
+
| `selectedId` | `string` | | The selected node's id. Controlled only. |
|
|
129
|
+
| `onSelect` | `(node: TreeNode) => void` | | Called when any row is clicked, parents included. |
|
|
130
|
+
| `expandedIds` | `string[]` | | Expanded node ids (controlled). Uncontrolled trees start fully collapsed. |
|
|
131
|
+
| `onExpandChange` | `(ids: string[]) => void` | | Called with the new list when a parent opens or closes. |
|
|
132
|
+
| `showIcons` | `boolean` | `true` | Shows folder, file and custom icons. |
|
|
133
|
+
| `indentSize` | `number` | | Pixel indent per level, replacing the token-based default. Avoid. |
|
|
134
|
+
| `aria-label` | `string` | | Names the tree. |
|
|
135
|
+
| `...props` | `HTMLAttributes<HTMLDivElement>` without `className`, `style`, `onSelect` | | Native div attributes on the root. |
|
|
136
|
+
<!-- api:end -->
|
|
137
|
+
|
|
138
|
+
## 13. Examples
|
|
139
|
+
|
|
140
|
+
A project file explorer with a folder open on first render.
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
import * as React from "react";
|
|
144
|
+
import { TreeView, Typography, type TreeNode } from "@eluan/core";
|
|
145
|
+
import { FileCode, FileJson, FileText, Folder } from "lucide-react";
|
|
146
|
+
|
|
147
|
+
const files: TreeNode[] = [
|
|
148
|
+
{
|
|
149
|
+
id: "src",
|
|
150
|
+
name: "src",
|
|
151
|
+
children: [
|
|
152
|
+
{
|
|
153
|
+
id: "src/components",
|
|
154
|
+
name: "components",
|
|
155
|
+
children: [
|
|
156
|
+
{ id: "src/components/button.tsx", name: "button.tsx", icon: <FileCode /> },
|
|
157
|
+
{ id: "src/components/card.tsx", name: "card.tsx", icon: <FileCode /> },
|
|
158
|
+
],
|
|
159
|
+
},
|
|
160
|
+
{ id: "src/hooks", name: "hooks", children: [], icon: <Folder /> },
|
|
161
|
+
{ id: "src/index.ts", name: "index.ts", icon: <FileCode /> },
|
|
162
|
+
],
|
|
163
|
+
},
|
|
164
|
+
{ id: "package.json", name: "package.json", icon: <FileJson /> },
|
|
165
|
+
{ id: "README.md", name: "README.md", icon: <FileText /> },
|
|
166
|
+
];
|
|
167
|
+
|
|
168
|
+
export function ProjectExplorer({ onOpenFile }: { onOpenFile: (path: string) => void }) {
|
|
169
|
+
const [selectedId, setSelectedId] = React.useState<string>("src/components/button.tsx");
|
|
170
|
+
const [expandedIds, setExpandedIds] = React.useState<string[]>(["src", "src/components"]);
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<div
|
|
174
|
+
style={{
|
|
175
|
+
display: "flex",
|
|
176
|
+
flexDirection: "column",
|
|
177
|
+
gap: "var(--spacing-sm)",
|
|
178
|
+
padding: "var(--spacing-sm)",
|
|
179
|
+
borderWidth: 1,
|
|
180
|
+
borderStyle: "solid",
|
|
181
|
+
borderColor: "var(--container-border)",
|
|
182
|
+
borderRadius: "var(--curves-lg)",
|
|
183
|
+
}}
|
|
184
|
+
>
|
|
185
|
+
<Typography id="explorer-heading" variant="label" tone="muted">
|
|
186
|
+
Files
|
|
187
|
+
</Typography>
|
|
188
|
+
<TreeView
|
|
189
|
+
aria-labelledby="explorer-heading"
|
|
190
|
+
data={files}
|
|
191
|
+
selectedId={selectedId}
|
|
192
|
+
onSelect={(node) => {
|
|
193
|
+
setSelectedId(node.id);
|
|
194
|
+
if (!node.children) onOpenFile(node.id);
|
|
195
|
+
}}
|
|
196
|
+
expandedIds={expandedIds}
|
|
197
|
+
onExpandChange={setExpandedIds}
|
|
198
|
+
/>
|
|
199
|
+
</div>
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## 14. Related components
|
|
205
|
+
|
|
206
|
+
- [Accordion](./accordion.md): expandable content sections rather than data.
|
|
207
|
+
- [Collapsible](./collapsible.md): the primitive TreeView uses for each parent.
|
|
208
|
+
- [ScrollArea](./scroll-area.md): scroll a long tree inside a fixed panel.
|
|
209
|
+
- [Table](./table.md): flat records with the same fields.
|
|
210
|
+
|
|
211
|
+
## 15. Common agent mistakes
|
|
212
|
+
|
|
213
|
+
_Filled from evals._
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Typography
|
|
3
|
+
use_when: Setting any app text (page titles, section headings, paragraphs, labels and captions) on the fluid type scale.
|
|
4
|
+
instead_of: Raw h1–h6, p or span with hand-set font sizes; Label for form labels; CodeBlock or Kbd for code.
|
|
5
|
+
source: packages/core/src/components/typography.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Typography
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
Typography is the front door to Eluan's fluid type scale. One `variant` picks a step (size, line height and letter spacing together), a font family, a weight and a semantic element. It renders that element, or its child with `asChild`, and drops `className` and `style`. Read [typography.md](../foundations/typography.md) for the scale itself.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- Page titles, section and group headings.
|
|
17
|
+
- Intro paragraphs, body copy, helper and meta text.
|
|
18
|
+
- Text inside your own layout elements and inside Card, Dialog or Sheet bodies.
|
|
19
|
+
- Styling a link or other element as a heading or label (`asChild`).
|
|
20
|
+
|
|
21
|
+
### When not to use
|
|
22
|
+
|
|
23
|
+
- A label for a form control → use [Label](./form-label.md).
|
|
24
|
+
- Code samples → use [CodeBlock](./code-block.md); keyboard keys → use [Kbd](./kbd.md).
|
|
25
|
+
- Text inside a Button, Badge, Banner or other component → pass plain text; the component sets its own type and colour.
|
|
26
|
+
- A card's title → use CardTitle inside [Card](./card.md), or `variant="subheading"` with a heading `as`.
|
|
27
|
+
- Rich, user-authored formatted text → use [RichText](./rich-text.md).
|
|
28
|
+
|
|
29
|
+
## 3. Anatomy
|
|
30
|
+
|
|
31
|
+
1. **Element**: the rendered tag, from the variant's default or `as` (`h1`–`h6`, `p`, `span`, `div`, `blockquote`, `figcaption`), or your child element with `asChild`.
|
|
32
|
+
2. **Text**: the children, with margin reset to 0 and `text-wrap: pretty`.
|
|
33
|
+
|
|
34
|
+
## 4. Variants
|
|
35
|
+
|
|
36
|
+
| Variant | Step | Family | Weight | Default element | Use for |
|
|
37
|
+
| --- | --- | --- | --- | --- | --- |
|
|
38
|
+
| `display` | 5 | heading | medium | `h1` | A hero or marketing headline. |
|
|
39
|
+
| `title` | 4 | heading | medium | `h2` | The page title (with `as="h1"`). |
|
|
40
|
+
| `heading` | 3 | heading | medium | `h3` | Section headings (usually `as="h2"`). |
|
|
41
|
+
| `subheading` | 2 | heading | medium | `h4` | Card, group or sub-section headings. |
|
|
42
|
+
| `lead` | 1 | body | normal | `p` | An intro line under a page title. |
|
|
43
|
+
| `body` (default) | 0 | body | normal | `p` | Paragraphs and general copy. |
|
|
44
|
+
| `label` | neg1 | body | medium | `span` | Short emphasised UI text: names in lists, small headers. Not form labels. |
|
|
45
|
+
| `caption` | neg2 | body | normal | `span` | Helper text, timestamps and meta. |
|
|
46
|
+
|
|
47
|
+
`tone` sets the colour:
|
|
48
|
+
|
|
49
|
+
- `default` (`--container-fg`), `muted` (`--container-fg-alt`), or `inverse` (`--container-fg-inverse`, only on a `--container-bg-inverse` surface).
|
|
50
|
+
- `positive` (`--positive-fg`) and `destructive` (`--destructive-fg`): status text such as "Payment received" or an error under a form. Both are held to 4.5:1.
|
|
51
|
+
- `interactive` (`--interactive-fg`) and `interactive-muted` (`--interactive-fg-alt`): text on a control you build yourself, such as a custom menu trigger. Text inside an Eluan control needs no tone.
|
|
52
|
+
- `inherit`: the parent's colour.
|
|
53
|
+
|
|
54
|
+
## 5. Sizes
|
|
55
|
+
|
|
56
|
+
The variant sets the size. `step` moves any variant to another of the ten steps (`"6"` to `"neg3"`) and swaps size, line height and letter spacing together, keeping the variant's family, weight and element. Sizes are fluid between 480px and 1024px viewports. Pick a variant first; reach for `step` only when no variant fits.
|
|
57
|
+
|
|
58
|
+
Steps don't change with the spacing density. For app UI text that should move with `data-spacing` like the controls beside it (table cells, form hints, toolbar labels), use `size` instead: `"xs"` to `"5xl"`, the `--font-size-*` aliases, one step lower in compact and one higher in wide. `size` takes precedence over `step`.
|
|
59
|
+
|
|
60
|
+
## 6. States
|
|
61
|
+
|
|
62
|
+
Typography has no interactive states. With `asChild` around a link or button, the child keeps its own behaviour, but its colour becomes the Typography tone.
|
|
63
|
+
|
|
64
|
+
## 7. Content guidelines
|
|
65
|
+
|
|
66
|
+
- Use sentence case for every heading and label: "Account settings", not "Account Settings".
|
|
67
|
+
- Don't end headings with a full stop.
|
|
68
|
+
- Keep a `lead` to one or two sentences.
|
|
69
|
+
- Keep captions short and factual: "Updated 2 hours ago".
|
|
70
|
+
|
|
71
|
+
| Do | Don't |
|
|
72
|
+
| --- | --- |
|
|
73
|
+
| Account settings | ACCOUNT SETTINGS |
|
|
74
|
+
| Billing history | Billing History. |
|
|
75
|
+
| Updated 2 hours ago | This information was last updated about 2 hours ago |
|
|
76
|
+
|
|
77
|
+
## 8. Rules
|
|
78
|
+
|
|
79
|
+
1. Set app text with Typography. Pick the `variant` for the role of the text, not its size.
|
|
80
|
+
2. Use `as` to fix the heading level for the document outline; keep the variant for the look.
|
|
81
|
+
3. Use one `title` or `display` per page.
|
|
82
|
+
4. Keep heading levels in order: one `h1`, then `h2` sections, then `h3`. Don't skip a level to get a smaller look; change the variant instead.
|
|
83
|
+
5. Use `tone="inverse"` only on a `--container-bg-inverse` surface.
|
|
84
|
+
6. Don't wrap other components' text in Typography. Typography always sets a colour, so it overrides the colour a Button, Badge or Banner gives its content.
|
|
85
|
+
7. If you style text yourself, apply all three tokens of one step together, for example `--font-size-step-1`, `--line-height-step-1` and `--letter-spacing-step-1` (or, density-aware, `--font-size-sm`, `--line-height-sm` and `--letter-spacing-sm`). Never write a font size, line height or letter spacing in px, rem or em.
|
|
86
|
+
8. Change fonts only in the theme. Use `family` to pick `heading`, `body` or `mono`, never a font name.
|
|
87
|
+
9. Don't pin `data-typeset` unless a region must not resize (for example a fixed-size canvas).
|
|
88
|
+
10. Never pass `className` or `style`; they're dropped, even through a cast.
|
|
89
|
+
|
|
90
|
+
## 9. Dos and don'ts
|
|
91
|
+
|
|
92
|
+
**Do:** pick variants by role and set the level with `as`.
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
<Typography variant="title" as="h1">Account settings</Typography>
|
|
96
|
+
<Typography variant="lead">Manage your profile, notifications and billing.</Typography>
|
|
97
|
+
<Typography variant="heading" as="h2">Notifications</Typography>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Don't:** size text by hand or pick a heading tag for its size.
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
<h1 style={{ fontSize: "32px", lineHeight: 1.1 }}>Account settings</h1>
|
|
104
|
+
<h4>Notifications</h4>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Do:** use muted tone for meta text.
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
<Typography variant="caption" tone="muted">Last updated 2 hours ago</Typography>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Don't:** colour text yourself.
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
<Typography variant="caption" style={{ color: "gray" }}>Last updated 2 hours ago</Typography>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Do:** pass plain text to components.
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
<Button type="submit">Save changes</Button>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Don't:** wrap a component's label in Typography.
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
<Button type="submit">
|
|
129
|
+
<Typography variant="label">Save changes</Typography>
|
|
130
|
+
</Button>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## 10. Accessibility
|
|
134
|
+
|
|
135
|
+
- Role: whatever the element is. `display` to `subheading` render real headings (`h1`–`h4`); `as` changes the level and `as="span"` or `asChild` removes the heading role (asserted in tests).
|
|
136
|
+
- Label: the text content. Typography forwards `id`, `lang` and `aria-*`, so a heading can label a region with `aria-labelledby`.
|
|
137
|
+
- Keyboard: none, unless `asChild` renders a link or button.
|
|
138
|
+
- Truncation: `truncate` cuts text to one line visually; screen readers still read all of it. Sighted users can't see the rest, so don't truncate text that matters, or show it in full elsewhere.
|
|
139
|
+
- Contrast: handled by the theme for each tone on its intended surface. Don't override colours.
|
|
140
|
+
|
|
141
|
+
## 11. Behaviour
|
|
142
|
+
|
|
143
|
+
- Responsive: every step is fluid between 480px and 1024px viewport widths, with no media queries. `data-typeset` on an ancestor pins the scale.
|
|
144
|
+
- Overflow and truncation: text wraps with `text-wrap: pretty`. `truncate` gives a single line with an ellipsis; it needs a width limit from its parent.
|
|
145
|
+
- Alignment: `align` takes logical values (`start`, `center`, `end`) and follows the writing direction.
|
|
146
|
+
- Motion: none.
|
|
147
|
+
|
|
148
|
+
## 12. API
|
|
149
|
+
|
|
150
|
+
<!-- api:start -->
|
|
151
|
+
| Prop | Type | Default | Description |
|
|
152
|
+
| --- | --- | --- | --- |
|
|
153
|
+
| `variant` | `"display" \| "title" \| "heading" \| "subheading" \| "lead" \| "body" \| "label" \| "caption"` | `"body"` | Picks the step, family, weight and default element. |
|
|
154
|
+
| `as` | `"h1" \| "h2" \| "h3" \| "h4" \| "h5" \| "h6" \| "p" \| "span" \| "div" \| "blockquote" \| "figcaption"` | variant's element | Element override; keeps the variant's look. |
|
|
155
|
+
| `asChild` | `boolean` | `false` | Renders the child element with the styles (Radix Slot). |
|
|
156
|
+
| `step` | `"6" \| "5" \| "4" \| "3" \| "2" \| "1" \| "0" \| "neg1" \| "neg2" \| "neg3"` | variant's step | Moves to another step; size, line height and letter spacing change together. |
|
|
157
|
+
| `size` | `"xs" \| "sm" \| "base" \| "lg" \| "xl" \| "2xl" \| "3xl" \| "4xl" \| "5xl"` | | Density-aware size: reads `--font-size-*` with its `--line-height-*` and `--letter-spacing-*`, so the text moves a step with `data-spacing`. Takes precedence over `step`. |
|
|
158
|
+
| `tone` | `"default" \| "muted" \| "inverse" \| "inherit" \| "positive" \| "destructive" \| "interactive" \| "interactive-muted"` | `"default"` | `--container-fg`, `--container-fg-alt` or `--container-fg-inverse`; `positive` and `destructive` for status text; `interactive` and `interactive-muted` for text on a control you build; `inherit` takes the parent's colour, for text inside a Banner, Button or link. |
|
|
159
|
+
| `weight` | `"thin" \| "extralight" \| "light" \| "normal" \| "medium" \| "semibold" \| "bold" \| "extrabold" \| "black"` | variant's weight | Weight override, 100 to 900. |
|
|
160
|
+
| `family` | `"heading" \| "body" \| "mono"` | variant's family | Reads `--font-heading`, `--font-body` or `--font-mono`. |
|
|
161
|
+
| `align` | `"start" \| "center" \| "end"` | | Logical text alignment. |
|
|
162
|
+
| `truncate` | `boolean` | `false` | One line with an ellipsis. |
|
|
163
|
+
| `tabular` | `boolean` | `false` | Tabular figures: every digit the same width, so numbers line up in columns. |
|
|
164
|
+
| `...props` | `HTMLAttributes<HTMLElement>` without `className`, `style` | | Native attributes: `id`, `lang`, `aria-*`. |
|
|
165
|
+
<!-- api:end -->
|
|
166
|
+
|
|
167
|
+
## 13. Examples
|
|
168
|
+
|
|
169
|
+
A page header with a section and meta text.
|
|
170
|
+
|
|
171
|
+
```tsx
|
|
172
|
+
import { Button, Typography } from "@eluan/core";
|
|
173
|
+
|
|
174
|
+
export function ProjectsHeader({ count, updated }: { count: number; updated: string }) {
|
|
175
|
+
return (
|
|
176
|
+
<header style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-md)" }}>
|
|
177
|
+
<div style={{ display: "flex", alignItems: "flex-start", justifyContent: "space-between", gap: "var(--spacing-md)" }}>
|
|
178
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-xs)" }}>
|
|
179
|
+
<Typography variant="title" as="h1">Projects</Typography>
|
|
180
|
+
<Typography variant="lead" tone="muted">
|
|
181
|
+
Everything your team is building, sorted by last activity.
|
|
182
|
+
</Typography>
|
|
183
|
+
</div>
|
|
184
|
+
<Button type="button">New project</Button>
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
<section aria-labelledby="active-projects" style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-xs)" }}>
|
|
188
|
+
<Typography id="active-projects" variant="heading" as="h2">Active</Typography>
|
|
189
|
+
<Typography variant="caption" tone="muted">
|
|
190
|
+
{count} projects · updated {updated}
|
|
191
|
+
</Typography>
|
|
192
|
+
</section>
|
|
193
|
+
</header>
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## 14. Related components
|
|
199
|
+
|
|
200
|
+
- [Label](./form-label.md): labels for form controls.
|
|
201
|
+
- [CodeBlock](./code-block.md) and [Kbd](./kbd.md): code and keys.
|
|
202
|
+
- [Card](./card.md): CardTitle and CardDescription for card headings.
|
|
203
|
+
- [Button](./button.md): `variant="link"` for inline text actions.
|
|
204
|
+
|
|
205
|
+
## 15. Common agent mistakes
|
|
206
|
+
|
|
207
|
+
_Filled from evals._
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: VisuallyHidden
|
|
3
|
+
use_when: Text should reach screen readers but not show, such as a heading sighted users infer from the layout, extra context on a link, or a status announced with a live region.
|
|
4
|
+
instead_of: aria-label on the control itself for an icon-only Button; Tooltip when sighted users need the text too; display none or the hidden attribute, which hide it from everyone.
|
|
5
|
+
source: packages/core/src/components/visually-hidden.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# VisuallyHidden
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
VisuallyHidden takes its content out of view and keeps it in the accessibility tree: a 1px clipped box that screen readers read like any other text. It renders a `span` by default; `as` picks another element (a heading, `p`, `label`) and `asChild` hides your own element. It drops `className` and `style`.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- A heading for a region that's visually obvious from layout, so screen-reader users can navigate to it.
|
|
17
|
+
- Context appended to a link or button label: "Edit *profile*", "Read more *about pricing*", "(opens in a new tab)".
|
|
18
|
+
- A live-region status message that sighted users already see expressed another way (a colour change, an icon).
|
|
19
|
+
- A visible-elsewhere label for a control whose purpose is clear from layout.
|
|
20
|
+
|
|
21
|
+
### When not to use
|
|
22
|
+
|
|
23
|
+
- Naming an icon-only Button → put `aria-label` on the [Button](./button.md); see [iconography](../foundations/iconography.md).
|
|
24
|
+
- Text sighted users also need on hover or focus → [Tooltip](./tooltip.md).
|
|
25
|
+
- Content that should be hidden from everyone → `hidden` or conditional rendering.
|
|
26
|
+
- A form field's label → a visible [FormLabel](./form-label.md); hidden labels make fields harder for everyone.
|
|
27
|
+
|
|
28
|
+
## 3. Anatomy
|
|
29
|
+
|
|
30
|
+
1. **Hidden element**: one element (`span` by default), positioned absolutely, 1px square, clipped, with no padding or border. Its text stays in the accessibility tree.
|
|
31
|
+
|
|
32
|
+
## 4. Variants
|
|
33
|
+
|
|
34
|
+
VisuallyHidden has no `variant`.
|
|
35
|
+
|
|
36
|
+
## 5. Sizes
|
|
37
|
+
|
|
38
|
+
VisuallyHidden has no size prop.
|
|
39
|
+
|
|
40
|
+
## 6. States
|
|
41
|
+
|
|
42
|
+
| State | Looks like | Notes |
|
|
43
|
+
| --- | --- | --- |
|
|
44
|
+
| Default | Nothing visible | Always hidden. It doesn't reveal on focus, so don't put focusable content (a skip link) in it. |
|
|
45
|
+
|
|
46
|
+
## 7. Content guidelines
|
|
47
|
+
|
|
48
|
+
- Write it as you'd say it: a full phrase, not a keyword.
|
|
49
|
+
- Appended context starts where the visible text leaves off: visible "Edit", hidden " profile".
|
|
50
|
+
- Keep it short. Screen-reader users hear it every time.
|
|
51
|
+
|
|
52
|
+
## 8. Rules
|
|
53
|
+
|
|
54
|
+
1. Prefer a visible label. Hide text only when the visual design already makes its meaning clear.
|
|
55
|
+
2. Don't hide focusable elements: a focused element that's invisible strands keyboard users.
|
|
56
|
+
3. For an icon-only Button, use `aria-label` on the Button, not VisuallyHidden inside it.
|
|
57
|
+
4. Use `as="h2"` (or the right level) for a hidden region heading, keeping heading levels in order.
|
|
58
|
+
5. Don't pass `className` or `style`; they're dropped.
|
|
59
|
+
|
|
60
|
+
## 9. Dos and don'ts
|
|
61
|
+
|
|
62
|
+
**Do:** give a region a heading screen readers can jump to.
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
<section aria-labelledby="filters-heading">
|
|
66
|
+
<VisuallyHidden as="h2" id="filters-heading">Filters</VisuallyHidden>
|
|
67
|
+
<Row wrap gap="sm">{filterControls}</Row>
|
|
68
|
+
</section>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Don't:** hide text with `display: none`; screen readers skip it too.
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
<h2 style={{ display: "none" }}>Filters</h2>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## 10. Accessibility
|
|
78
|
+
|
|
79
|
+
- Role: the element's own (`span` has none; `as="h2"` is a heading).
|
|
80
|
+
- Screen readers read the content in place, as part of its parent's text or accessible name.
|
|
81
|
+
- Keyboard: none. Never put a focusable element inside.
|
|
82
|
+
- Live regions: pair with `role="status"` or `aria-live="polite"` on the element for announcements.
|
|
83
|
+
|
|
84
|
+
## 11. Behaviour
|
|
85
|
+
|
|
86
|
+
- Layout: it's absolutely positioned, so it takes no space and never affects layout. Its nearest positioned ancestor contains it.
|
|
87
|
+
- Density: no effect.
|
|
88
|
+
- Motion: none.
|
|
89
|
+
|
|
90
|
+
## 12. API
|
|
91
|
+
|
|
92
|
+
<!-- api:start -->
|
|
93
|
+
| Prop | Type | Default | Description |
|
|
94
|
+
| --- | --- | --- | --- |
|
|
95
|
+
| `as` | `"span" \| "div" \| "p" \| "label" \| "h1" \| "h2" \| "h3" \| "h4" \| "h5" \| "h6"` | `"span"` | Element override. Defaults to `span`. |
|
|
96
|
+
| `asChild` | `boolean` | `false` | Hide the child element instead of wrapping it (Radix Slot). |
|
|
97
|
+
| `...props` | `HTMLAttributes<HTMLElement>` without `className`, `style` | | Native attributes: `id`, `role`, `aria-live`, `data-*`. |
|
|
98
|
+
<!-- api:end -->
|
|
99
|
+
|
|
100
|
+
## 13. Examples
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
import { Button, Row, Stack, Typography, VisuallyHidden } from "@eluan/core";
|
|
104
|
+
|
|
105
|
+
export function ProjectList({ projects }: { projects: { id: string; name: string }[] }) {
|
|
106
|
+
return (
|
|
107
|
+
<Stack as="section" gap="md" aria-labelledby="projects-heading">
|
|
108
|
+
<VisuallyHidden as="h2" id="projects-heading">
|
|
109
|
+
Your projects
|
|
110
|
+
</VisuallyHidden>
|
|
111
|
+
{projects.map((item) => (
|
|
112
|
+
<Row key={item.id} justify="between">
|
|
113
|
+
<Typography>{item.name}</Typography>
|
|
114
|
+
<Button variant="outline" size="sm">
|
|
115
|
+
Edit<VisuallyHidden> {item.name}</VisuallyHidden>
|
|
116
|
+
</Button>
|
|
117
|
+
</Row>
|
|
118
|
+
))}
|
|
119
|
+
</Stack>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## 14. Related components
|
|
125
|
+
|
|
126
|
+
- [Button](./button.md): icon-only Buttons take `aria-label` instead.
|
|
127
|
+
- [Icon](./icon.md): decorative icons beside hidden or visible text.
|
|
128
|
+
- [Tooltip](./tooltip.md): text sighted users see on hover or focus.
|
|
129
|
+
|
|
130
|
+
## 15. Common agent mistakes
|
|
131
|
+
|
|
132
|
+
_Filled from evals._
|