@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,203 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ScrollArea
|
|
3
|
+
use_when: A bounded box needs its own scrolling region with themed scrollbars, such as a long list in a fixed-height panel.
|
|
4
|
+
instead_of: Letting the page scroll for page-length content; Accordion or Collapsible to shorten secondary content; the built-in scrolling of Command lists and Select menus.
|
|
5
|
+
source: packages/core/src/components/scroll-area.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# ScrollArea
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
ScrollArea is a scroll container with themed scrollbars. It wraps Radix Scroll Area: native scrolling stays (wheel, touch, keyboard), and the browser's scrollbars are replaced with a thin pill thumb. It fills its parent, so the parent must have a bounded height or width. It renders one vertical scrollbar; add `ScrollBar orientation="horizontal"` as a child for horizontal scrolling.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- A long list inside a fixed-height panel, sidebar section or popover body: activity feeds, tag lists, file lists.
|
|
17
|
+
- A horizontal row of cards or chips that's wider than its container.
|
|
18
|
+
- Content that scrolls in both directions inside a fixed box (add the horizontal ScrollBar).
|
|
19
|
+
|
|
20
|
+
### When not to use
|
|
21
|
+
|
|
22
|
+
- Page-length content → let the document scroll; don't wrap the page in a ScrollArea.
|
|
23
|
+
- Secondary content you could collapse instead → use [Accordion](./accordion.md) or [Collapsible](./collapsible.md).
|
|
24
|
+
- A searchable list of options → use [Command](./command.md); its list already scrolls.
|
|
25
|
+
- A long option list in a field → use [Select](./select.md); its menu has its own viewport and scroll buttons.
|
|
26
|
+
- Sidebar navigation → use [NavigationDrawer](./navigation-drawer.md); its content area already scrolls.
|
|
27
|
+
- Tabular data → use [Table](./table.md).
|
|
28
|
+
|
|
29
|
+
## 3. Anatomy
|
|
30
|
+
|
|
31
|
+
1. **Root**: the Radix Scroll Area root, sized to fill its parent (`height` and `width` 100%), with hidden overflow. Your props go here.
|
|
32
|
+
2. **Viewport**: the native scrolling element. Your children render inside it.
|
|
33
|
+
3. **Vertical scrollbar**: always rendered by ScrollArea. A track of `--spacing-sm` + `--spacing-xxs` width holding the thumb.
|
|
34
|
+
4. **Thumb**: a pill (`--radius-radius-full`) in `--interactive-border-alt`. Drag it with a pointer.
|
|
35
|
+
5. **Horizontal scrollbar** (optional): add `<ScrollBar orientation="horizontal" />` as the last child.
|
|
36
|
+
6. **Corner**: the square where both scrollbars meet. Rendered automatically.
|
|
37
|
+
|
|
38
|
+
## 4. Variants
|
|
39
|
+
|
|
40
|
+
ScrollArea has no variant prop. Radix's `type` prop controls when the scrollbars show.
|
|
41
|
+
|
|
42
|
+
| `type` | Use for |
|
|
43
|
+
| --- | --- |
|
|
44
|
+
| `hover` (Radix default) | Most cases. Scrollbars appear while the pointer is over the area or while scrolling. |
|
|
45
|
+
| `scroll` | Quiet surfaces. Scrollbars appear only while scrolling. |
|
|
46
|
+
| `auto` | Scrollbars show whenever the content overflows. |
|
|
47
|
+
| `always` | Scrollbars always show, so the region visibly reads as scrollable. |
|
|
48
|
+
|
|
49
|
+
## 5. Sizes
|
|
50
|
+
|
|
51
|
+
ScrollArea has no size prop. It takes the size of its parent. The scrollbar width follows `--spacing-sm` + `--spacing-xxs`, so it narrows in compact density and widens in wide.
|
|
52
|
+
|
|
53
|
+
## 6. States
|
|
54
|
+
|
|
55
|
+
| State | Looks like | Notes |
|
|
56
|
+
| --- | --- | --- |
|
|
57
|
+
| Default | Content clipped to the box; scrollbars per `type` | Without a bounded parent the box grows with its content and never scrolls. |
|
|
58
|
+
| Scrolling | Thumb visible in `--interactive-border-alt` | Radix sets `data-state="visible"` on the scrollbar. |
|
|
59
|
+
| No overflow | No scrollbar | Radix hides the scrollbar when content fits, except with `type="always"`. |
|
|
60
|
+
|
|
61
|
+
## 7. Content guidelines
|
|
62
|
+
|
|
63
|
+
- Keep the heading or label for the region outside the ScrollArea, so it stays visible while the content scrolls.
|
|
64
|
+
- Pad content with a wrapper inside the ScrollArea (`padding: var(--spacing-md)`, as the stories do), not on the bounded parent, so the scrollbar sits at the edge.
|
|
65
|
+
- For a horizontal row, give the content wrapper `display: flex` and `width: max-content`, and stop its items from shrinking.
|
|
66
|
+
|
|
67
|
+
## 8. Rules
|
|
68
|
+
|
|
69
|
+
1. Give ScrollArea a bounded parent: a wrapper with a fixed `height` (or `width` for horizontal), or a flex item with `flex: 1` and `minHeight: 0` inside a parent of fixed height. `maxHeight` alone doesn't work.
|
|
70
|
+
2. Add horizontal scrolling with `<ScrollBar orientation="horizontal" />` as the last child of ScrollArea. Don't add a second vertical ScrollBar; one is built in.
|
|
71
|
+
3. Put borders, radius and background on the wrapper you own. ScrollArea drops `className` and `style`.
|
|
72
|
+
4. Don't wrap components that already scroll: Command lists, Select menus, NavigationDrawer content.
|
|
73
|
+
5. When the content has no focusable elements, make it reachable by keyboard: wrap it in a `<div tabIndex={0} role="region" aria-label="…">` inside the ScrollArea.
|
|
74
|
+
|
|
75
|
+
## 9. Dos and don'ts
|
|
76
|
+
|
|
77
|
+
**Do:** bound the parent and style it yourself.
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
<div style={{ height: "40dvh", borderWidth: 1, borderStyle: "solid", borderColor: "var(--container-border)", borderRadius: "var(--curves-md)", overflow: "hidden" }}>
|
|
81
|
+
<ScrollArea>
|
|
82
|
+
<div style={{ padding: "var(--spacing-md)" }}>{tagList}</div>
|
|
83
|
+
</ScrollArea>
|
|
84
|
+
</div>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Don't:** leave the height unbounded or try to size the component directly.
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
<ScrollArea style={{ height: 300 }}>
|
|
91
|
+
<div>{tagList}</div>
|
|
92
|
+
</ScrollArea>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Do:** add the horizontal scrollbar as a child.
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
<div style={{ width: "100%" }}>
|
|
99
|
+
<ScrollArea>
|
|
100
|
+
<div style={{ display: "flex", width: "max-content", gap: "var(--spacing-md)", padding: "var(--spacing-md)" }}>
|
|
101
|
+
{cards}
|
|
102
|
+
</div>
|
|
103
|
+
<ScrollBar orientation="horizontal" />
|
|
104
|
+
</ScrollArea>
|
|
105
|
+
</div>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Don't:** set `overflow` on your content and expect ScrollArea's scrollbars.
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
<ScrollArea>
|
|
112
|
+
<div style={{ overflowX: "auto", whiteSpace: "nowrap" }}>{cards}</div>
|
|
113
|
+
</ScrollArea>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## 10. Accessibility
|
|
117
|
+
|
|
118
|
+
- Role: none. The root and viewport are plain `<div>`s. Add `role="region"` and an `aria-label` on an inner wrapper when the region needs a name.
|
|
119
|
+
- Label: none built in.
|
|
120
|
+
- Keyboard: arrow keys, Page Up, Page Down, Home, End and Space scroll the viewport when focus is inside it. Tab moves through focusable content in DOM order. Scrollbar thumbs are pointer-only.
|
|
121
|
+
- Focus: ScrollArea adds no focus stop and doesn't trap focus. See Rule 5 for content with nothing focusable.
|
|
122
|
+
- Contrast: handled by the theme. Don't override colours. The thumb uses `--interactive-border-alt`.
|
|
123
|
+
|
|
124
|
+
## 11. Behaviour
|
|
125
|
+
|
|
126
|
+
- Responsive: fills its parent in both directions; resize the parent, not the ScrollArea.
|
|
127
|
+
- Overflow and truncation: content wider or taller than the box is clipped and scrolls. Without a horizontal ScrollBar, horizontal overflow stays clipped.
|
|
128
|
+
- Motion: scrollbars appear and hide per `type` (Radix, `scrollHideDelay` 600ms by default), with no animation. Don't add your own.
|
|
129
|
+
- Right-to-left: pass `dir="rtl"` to move the vertical scrollbar to the left.
|
|
130
|
+
|
|
131
|
+
## 12. API
|
|
132
|
+
|
|
133
|
+
<!-- api:start -->
|
|
134
|
+
### ScrollArea
|
|
135
|
+
|
|
136
|
+
| Prop | Type | Default | Description |
|
|
137
|
+
| --- | --- | --- | --- |
|
|
138
|
+
| `children` | `ReactNode` | | Content, rendered inside the viewport. Add `<ScrollBar orientation="horizontal" />` here for horizontal scrolling. |
|
|
139
|
+
| `type` | `"auto" \| "always" \| "scroll" \| "hover"` | `"hover"` | When the scrollbars show (Radix). |
|
|
140
|
+
| `scrollHideDelay` | `number` | `600` | Milliseconds before scrollbars hide, for `hover` and `scroll` (Radix). |
|
|
141
|
+
| `dir` | `"ltr" \| "rtl"` | | Reading direction; moves the vertical scrollbar (Radix). |
|
|
142
|
+
| `...props` | Radix `ScrollArea.Root` props without `className`, `style` | | Applied to the root: `id`, `aria-*`, `data-*`. `className` and `style` are omitted. |
|
|
143
|
+
|
|
144
|
+
### ScrollBar
|
|
145
|
+
|
|
146
|
+
| Prop | Type | Default | Description |
|
|
147
|
+
| --- | --- | --- | --- |
|
|
148
|
+
| `orientation` | `"vertical" \| "horizontal"` | `"vertical"` | Which scrollbar. ScrollArea already renders the vertical one. |
|
|
149
|
+
| `forceMount` | `true` | | Keeps the scrollbar mounted when hidden (Radix). |
|
|
150
|
+
| `...props` | Radix `ScrollArea.Scrollbar` props without `className`, `style` | | `className` and `style` are omitted. |
|
|
151
|
+
<!-- api:end -->
|
|
152
|
+
|
|
153
|
+
## 13. Examples
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
import { ScrollArea, Separator, Typography } from "@eluan/core";
|
|
157
|
+
|
|
158
|
+
const activity = [
|
|
159
|
+
{ id: "evt-2041", who: "Priya Raman", what: "approved invoice INV-2041", when: "2 minutes ago" },
|
|
160
|
+
{ id: "evt-2040", who: "Tomás Ortega", what: "added 3 seats to the Design team", when: "18 minutes ago" },
|
|
161
|
+
{ id: "evt-2039", who: "Mei Lin", what: "exported the Q3 revenue report", when: "1 hour ago" },
|
|
162
|
+
{ id: "evt-2038", who: "Jonah Adeyemi", what: "changed the billing email", when: "Yesterday" },
|
|
163
|
+
];
|
|
164
|
+
|
|
165
|
+
export function ActivitySidebar() {
|
|
166
|
+
return (
|
|
167
|
+
<aside style={{ display: "flex", flexDirection: "column", height: "100dvh", gap: "var(--spacing-md)" }}>
|
|
168
|
+
<div style={{ paddingInline: "var(--spacing-md)", paddingTop: "var(--spacing-md)" }}>
|
|
169
|
+
<Typography variant="subheading" as="h2">Recent activity</Typography>
|
|
170
|
+
</div>
|
|
171
|
+
<div style={{ flex: 1, minHeight: 0 }}>
|
|
172
|
+
<ScrollArea type="auto">
|
|
173
|
+
<div tabIndex={0} role="region" aria-label="Recent activity" style={{ padding: "var(--spacing-md)" }}>
|
|
174
|
+
<ul style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-sm)", listStyle: "none", margin: 0, padding: 0 }}>
|
|
175
|
+
{activity.map((event, index) => (
|
|
176
|
+
<li key={event.id} style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-sm)" }}>
|
|
177
|
+
{index > 0 && <Separator />}
|
|
178
|
+
<Typography>
|
|
179
|
+
{event.who} {event.what}
|
|
180
|
+
</Typography>
|
|
181
|
+
<Typography variant="caption" tone="muted">{event.when}</Typography>
|
|
182
|
+
</li>
|
|
183
|
+
))}
|
|
184
|
+
</ul>
|
|
185
|
+
</div>
|
|
186
|
+
</ScrollArea>
|
|
187
|
+
</div>
|
|
188
|
+
</aside>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## 14. Related components
|
|
194
|
+
|
|
195
|
+
- [Separator](./separator.md): divides rows inside a scrolling list.
|
|
196
|
+
- [Command](./command.md): a filterable list that scrolls on its own.
|
|
197
|
+
- [Accordion](./accordion.md): shortens long secondary content instead of scrolling it.
|
|
198
|
+
- [NavigationDrawer](./navigation-drawer.md): its content area already scrolls; don't wrap it.
|
|
199
|
+
- [Table](./table.md): for tabular data.
|
|
200
|
+
|
|
201
|
+
## 15. Common agent mistakes
|
|
202
|
+
|
|
203
|
+
_Filled from evals._
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: SearchInput
|
|
3
|
+
use_when: The user types a query to search or filter, in a header, toolbar or above a list; AutocompleteSearch when they pick one result from suggestions.
|
|
4
|
+
instead_of: Command for a command palette; Select or MultiSelect for choosing from a fixed list; Input for text that isn't a query.
|
|
5
|
+
source: packages/core/src/components/search-input.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# SearchInput
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
SearchInput is an [Input](./input.md) with `type="search"`, so Input adds the leading search icon automatically. It adds a clear button, Escape to clear, `onSearch` on Enter, an optional debounced `onSearch` while typing, and a loading spinner. Two siblings ship in the same module: CommandSearch, a search field that ⌘K or Ctrl+K focuses from anywhere, and AutocompleteSearch, a combobox that filters a list of suggestions as the user types.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- A site or app search field in the [Header](./header.md) or a toolbar.
|
|
17
|
+
- Filtering a table, list or grid on the current page, often with `debounceMs` for search-as-you-type.
|
|
18
|
+
- Picking one item from a known set by typing part of its name: an assignee, a project, a file (AutocompleteSearch).
|
|
19
|
+
|
|
20
|
+
### When not to use
|
|
21
|
+
|
|
22
|
+
- Text that isn't a query → use [Input](./input.md).
|
|
23
|
+
- A command palette that runs actions or navigates → use [Command](./command.md).
|
|
24
|
+
- Choosing one value from a short fixed list → use [Select](./select.md). Choosing several → use [MultiSelect](./multi-select.md).
|
|
25
|
+
- A free-text query that should run on Enter → use SearchInput, not AutocompleteSearch, which only selects options.
|
|
26
|
+
|
|
27
|
+
SearchInput earns its place over `<Input type="search">` through the clear button, Escape to clear, `onSearch` with optional debounce, and the loading state. If you only need a field with a search icon, `<Input type="search">` draws the same icon.
|
|
28
|
+
|
|
29
|
+
## 3. Anatomy
|
|
30
|
+
|
|
31
|
+
**SearchInput**
|
|
32
|
+
|
|
33
|
+
1. **Field**: a native `<input type="search">` (role `searchbox`) on Input's surface. The browser's own cancel button is hidden.
|
|
34
|
+
2. **Search icon**: added automatically by Input for `type="search"`. Don't add your own.
|
|
35
|
+
3. **Clear button**: a delete icon at the trailing edge while the field has a value, named "Clear search".
|
|
36
|
+
4. **Loading spinner**: replaces the clear button while `loading`.
|
|
37
|
+
|
|
38
|
+
**CommandSearch**: the same field and icon, plus a **shortcut hint**: a `<kbd>` showing ⌘ and `shortcutKey` at the trailing edge.
|
|
39
|
+
|
|
40
|
+
**AutocompleteSearch**
|
|
41
|
+
|
|
42
|
+
1. **Field**: Input with `role="combobox"` and a search icon.
|
|
43
|
+
2. **Clear button** or **loading spinner** at the trailing edge.
|
|
44
|
+
3. **Suggestion list**: a floating `listbox` below the field.
|
|
45
|
+
4. **Option**: optional icon, a label and an optional one-line description.
|
|
46
|
+
5. **Group heading and separator** (with `groupBy`): a muted heading above each group, a line between groups.
|
|
47
|
+
6. **Empty message**: `emptyMessage` when nothing matches.
|
|
48
|
+
7. **Status**: a visually hidden live region announcing the result count.
|
|
49
|
+
|
|
50
|
+
## 4. Variants
|
|
51
|
+
|
|
52
|
+
| Export | Use for |
|
|
53
|
+
| --- | --- |
|
|
54
|
+
| `SearchInput` | Search and filter fields; runs `onSearch` on Enter or after a debounce. |
|
|
55
|
+
| `CommandSearch` | A page-level search field that ⌘K or Ctrl+K focuses. |
|
|
56
|
+
| `AutocompleteSearch` | Selecting one option from a filtered suggestion list. |
|
|
57
|
+
|
|
58
|
+
## 5. Sizes
|
|
59
|
+
|
|
60
|
+
No size prop. The field is `--size-lg` tall, from Input, and follows density.
|
|
61
|
+
|
|
62
|
+
## 6. States
|
|
63
|
+
|
|
64
|
+
| State | Looks like | Notes |
|
|
65
|
+
| --- | --- | --- |
|
|
66
|
+
| Default | `--interactive-bg` surface, `--interactive-border-alt` border, icon and placeholder in `--interactive-fg-alt` | |
|
|
67
|
+
| Focus | Border and 1px outline in `--focus-ring`, 1px offset | Never remove or restyle the focus ring. |
|
|
68
|
+
| Filled | Clear button at the trailing edge; `--interactive-bg-hover` on hover | SearchInput hides it when `showClearButton={false}`. |
|
|
69
|
+
| Loading | Spinner at the trailing edge | SearchInput also disables the field while `loading`, so typing stops and focus is lost. AutocompleteSearch stays editable and shows a spinner in the list too. |
|
|
70
|
+
| Disabled | `--interactive-bg-disabled` surface, `--interactive-fg-disabled` text | |
|
|
71
|
+
| Open (AutocompleteSearch) | List on `--container-bg` with a border, below the field | The list border uses `--container-border-alt` while other floating panels use `--container-border`, and the group separator inside is the lighter of the two. Don't compensate in app code. |
|
|
72
|
+
| Highlighted option | `--interactive-bg-hover` | Set by arrow keys or pointer hover. |
|
|
73
|
+
| Disabled option | `--interactive-bg-disabled` surface, `--interactive-fg-disabled` text | Not selectable. |
|
|
74
|
+
| Empty | `emptyMessage` centred in the list | |
|
|
75
|
+
|
|
76
|
+
## 7. Content guidelines
|
|
77
|
+
|
|
78
|
+
- Name what is searched in the placeholder and the accessible name: "Search projects", "Filter by name".
|
|
79
|
+
- Keep `emptyMessage` specific: "No projects match" rather than an error tone.
|
|
80
|
+
- Option labels: the item's name. Descriptions: one short distinguishing detail (owner, path, type).
|
|
81
|
+
|
|
82
|
+
| Do | Don't |
|
|
83
|
+
| --- | --- |
|
|
84
|
+
| Search projects | Search... |
|
|
85
|
+
| No teammates match | Error: 0 results |
|
|
86
|
+
| Ada Lovelace · Design | Ada Lovelace, member of the Design team since 2021 |
|
|
87
|
+
|
|
88
|
+
## 8. Rules
|
|
89
|
+
|
|
90
|
+
1. Give every search field an accessible name. In a header or toolbar with no visible label, set `aria-label` ("Search projects"). The placeholder isn't a name.
|
|
91
|
+
2. Don't add a search icon. SearchInput and CommandSearch get it from Input's `type="search"`; AutocompleteSearch renders its own.
|
|
92
|
+
3. Read the value with `onValueChange`; `onChange` isn't available. Run the search in `onSearch`.
|
|
93
|
+
4. Decide what Enter does. With `onSearch` set, Enter calls it and doesn't submit an enclosing form; without `onSearch`, Enter submits the form natively.
|
|
94
|
+
5. Set `debounceMs` for search-as-you-type; there's no debounce by default.
|
|
95
|
+
6. Don't toggle `loading` on SearchInput while the user is typing; it disables the field. Show progress in the results area instead.
|
|
96
|
+
7. Use AutocompleteSearch only for choosing an option. Enter selects the highlighted option and never submits; there's no free-text submit.
|
|
97
|
+
8. Use one CommandSearch per page, and don't bind ⌘K to anything else on that page. Each instance adds its own document-level shortcut listener.
|
|
98
|
+
9. Never pass `className` or `style`; they're dropped. Put width on a wrapper.
|
|
99
|
+
|
|
100
|
+
## 9. Dos and don'ts
|
|
101
|
+
|
|
102
|
+
**Do:** name a label-less header search.
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
<SearchInput aria-label="Search projects" placeholder="Search projects" onSearch={runSearch} />
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Don't:** rely on the placeholder, or add a second icon.
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
<SearchInput placeholder="Search..." icon={<Search />} />
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Do:** debounce search-as-you-type and show progress in the results.
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
<SearchInput aria-label="Filter invoices" debounceMs={300} onSearch={setQuery} />
|
|
118
|
+
{isFetching && <Spinner />}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Don't:** set `loading` on every keystroke.
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
<SearchInput onValueChange={(q) => { setLoading(true); fetchResults(q).then(() => setLoading(false)); }} loading={loading} />
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Do:** use AutocompleteSearch to pick one item.
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
<AutocompleteSearch aria-label="Assign to" options={teammates} onSelect={(option) => assign(option.value)} />
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Don't:** use it for an open query that runs on Enter.
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
<AutocompleteSearch options={recentSearches} onValueChange={setQuery} />
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## 10. Accessibility
|
|
140
|
+
|
|
141
|
+
- SearchInput: role `searchbox`. Name from `aria-label`, or a Label tied by `htmlFor`/`id`. Enter runs `onSearch`; Escape clears a non-empty field. The clear button is out of the Tab order (`tabIndex={-1}`); Escape is the keyboard path.
|
|
142
|
+
- CommandSearch: role `searchbox`. ⌘K or Ctrl+K (or ⌘/Ctrl plus `shortcutKey`) focuses the field from anywhere on the page. The hint is a `<kbd>` and always shows ⌘, even on Windows and Linux.
|
|
143
|
+
- AutocompleteSearch: the field is a `combobox` with `aria-expanded`, `aria-autocomplete="list"` and `aria-controls`; `aria-activedescendant` points at the highlighted option. The list is a `listbox` named "Suggestions" of `option`s with `aria-selected` on the highlighted one; disabled options carry `aria-disabled`. A polite `role="status"` region announces "N results available", "Loading results" or `emptyMessage`. Group headings are visual only.
|
|
144
|
+
- AutocompleteSearch keyboard: ArrowDown or ArrowUp opens the list, then moves the highlight and wraps; Enter selects; Escape closes; Tab closes and moves on. Focus stays in the field throughout, and returns to it after a pointer selection.
|
|
145
|
+
- Landmark: wrap a site-wide search in `<form role="search">`.
|
|
146
|
+
- Contrast: handled by the theme. Don't override colours.
|
|
147
|
+
|
|
148
|
+
## 11. Behaviour
|
|
149
|
+
|
|
150
|
+
- Responsive: fills its container's width. Size it with a wrapper.
|
|
151
|
+
- Overflow and truncation: option labels and descriptions stay on one line and truncate with an ellipsis. Keep the distinguishing part at the start.
|
|
152
|
+
- Clearing (button or Escape) empties the field, calls `onValueChange("")` and `onClear`, and cancels a pending debounced search.
|
|
153
|
+
- CommandSearch doesn't wire SearchInput's behaviour: it drops `onValueChange`, and `onSearch`, `onClear`, `loading`, `showClearButton`, `searchOnEnter` and `debounceMs` do nothing. Read its value with `onInput` or a `ref`.
|
|
154
|
+
- AutocompleteSearch filtering: by default a case-insensitive substring match on `label`, `value` and `description`, capped at `maxResults`. With `showAllOnFocus`, focusing shows the options before typing. When the server already filtered the results, pass them as `options` with `filterFn={() => true}`.
|
|
155
|
+
- AutocompleteSearch selection puts the option's `label` in the field and calls `onValueChange(label)` and `onSelect(option)`.
|
|
156
|
+
- AutocompleteSearch's list is positioned under the field inside the component, not in a portal. An ancestor with `overflow: hidden` clips it; give it room. It scrolls when long and closes on a click outside.
|
|
157
|
+
- Motion: spinners rotate once per second and stop under reduced motion; colour transitions over 150ms. Don't add your own.
|
|
158
|
+
|
|
159
|
+
## 12. API
|
|
160
|
+
|
|
161
|
+
<!-- api:start -->
|
|
162
|
+
### SearchInput
|
|
163
|
+
|
|
164
|
+
| Prop | Type | Default | Description |
|
|
165
|
+
| --- | --- | --- | --- |
|
|
166
|
+
| `value` | `string` | | Controlled value. |
|
|
167
|
+
| `onValueChange` | `(value: string) => void` | | Fires on every change and on clear. |
|
|
168
|
+
| `onSearch` | `(value: string) => void` | | Runs on Enter (with `searchOnEnter`) and after `debounceMs`. |
|
|
169
|
+
| `onClear` | `() => void` | | Fires when the clear button or Escape empties the field. |
|
|
170
|
+
| `loading` | `boolean` | `false` | Shows a spinner instead of the clear button and disables the field. |
|
|
171
|
+
| `showClearButton` | `boolean` | `true` | Shows the clear button while there's a value. |
|
|
172
|
+
| `searchOnEnter` | `boolean` | `true` | Enter calls `onSearch` and prevents form submission. |
|
|
173
|
+
| `debounceMs` | `number` | | Calls `onSearch` this many ms after typing stops. No debounce when unset. |
|
|
174
|
+
| `disabled` | `boolean` | | Disables the field. |
|
|
175
|
+
| `...props` | `InputHTMLAttributes` without `className`, `style`, `size`, `type`, `onChange` | | Native attributes: `id`, `name`, `placeholder`, `autoFocus`, `aria-*`. `ref` reaches the `<input>`. |
|
|
176
|
+
|
|
177
|
+
### CommandSearch
|
|
178
|
+
|
|
179
|
+
| Prop | Type | Default | Description |
|
|
180
|
+
| --- | --- | --- | --- |
|
|
181
|
+
| `shortcutKey` | `string` | `"K"` | The key that, with ⌘ or Ctrl, focuses the field. |
|
|
182
|
+
| `showShortcut` | `boolean` | `true` | Shows the ⌘ hint at the trailing edge. |
|
|
183
|
+
| `...props` | SearchInput props | | Only native input attributes take effect (see Behaviour). |
|
|
184
|
+
|
|
185
|
+
### AutocompleteSearch
|
|
186
|
+
|
|
187
|
+
| Prop | Type | Default | Description |
|
|
188
|
+
| --- | --- | --- | --- |
|
|
189
|
+
| `options` | `AutocompleteOption[]` | required | The suggestions. |
|
|
190
|
+
| `onSelect` | `(option: AutocompleteOption) => void` | | Fires when the user picks an enabled option. |
|
|
191
|
+
| `value` | `string` | | Controlled field text. |
|
|
192
|
+
| `onValueChange` | `(value: string) => void` | | Fires on typing, selection and clear. |
|
|
193
|
+
| `loading` | `boolean` | `false` | Shows spinners in the field and list; the field stays editable. |
|
|
194
|
+
| `emptyMessage` | `string` | `"No results found"` | Shown and announced when nothing matches. |
|
|
195
|
+
| `filterFn` | `(option: AutocompleteOption, query: string) => boolean` | substring match on label, value, description | Decides which options show for the query. |
|
|
196
|
+
| `minChars` | `number` | `0` | Characters needed before filtering applies. |
|
|
197
|
+
| `maxResults` | `number` | `10` | Most options shown. |
|
|
198
|
+
| `showAllOnFocus` | `boolean` | `true` | Opens with options on focus, before typing. |
|
|
199
|
+
| `groupBy` | `(option: AutocompleteOption) => string` | | Groups options under headings. |
|
|
200
|
+
| `placeholder` | `string` | `"Search..."` | Field placeholder. |
|
|
201
|
+
| `disabled` | `boolean` | | Disables the field. |
|
|
202
|
+
| `...props` | `InputHTMLAttributes` without `className`, `style`, `size`, `type`, `onChange`, `onSelect` | | Native attributes: `id`, `name`, `aria-*`. `ref` reaches the `<input>`. |
|
|
203
|
+
|
|
204
|
+
### AutocompleteOption
|
|
205
|
+
|
|
206
|
+
| Field | Type | Description |
|
|
207
|
+
| --- | --- | --- |
|
|
208
|
+
| `value` | `string` | Unique id; also the React key. |
|
|
209
|
+
| `label` | `string` | Shown text, and the field text after selection. |
|
|
210
|
+
| `description` | `string` | Optional second line, truncated. |
|
|
211
|
+
| `icon` | `ReactNode` | Optional leading icon, sized to `--size-xxs`. |
|
|
212
|
+
| `disabled` | `boolean` | Shows the option but blocks selection. |
|
|
213
|
+
<!-- api:end -->
|
|
214
|
+
|
|
215
|
+
## 13. Examples
|
|
216
|
+
|
|
217
|
+
```tsx
|
|
218
|
+
import { Header, SearchInput } from "@eluan/core";
|
|
219
|
+
|
|
220
|
+
export function AppHeader({ onSearch }: { onSearch: (query: string) => void }) {
|
|
221
|
+
return (
|
|
222
|
+
<Header
|
|
223
|
+
logo={<span>Northwind</span>}
|
|
224
|
+
items={[
|
|
225
|
+
{ label: "Projects", href: "/projects", active: true },
|
|
226
|
+
{ label: "Reports", href: "/reports" },
|
|
227
|
+
]}
|
|
228
|
+
actions={
|
|
229
|
+
<form role="search" onSubmit={(event) => event.preventDefault()}>
|
|
230
|
+
<SearchInput aria-label="Search projects" placeholder="Search projects" onSearch={onSearch} />
|
|
231
|
+
</form>
|
|
232
|
+
}
|
|
233
|
+
/>
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
```tsx
|
|
239
|
+
import { useState } from "react";
|
|
240
|
+
import { AutocompleteSearch, Label, type AutocompleteOption } from "@eluan/core";
|
|
241
|
+
import { User } from "lucide-react";
|
|
242
|
+
|
|
243
|
+
const teammates: AutocompleteOption[] = [
|
|
244
|
+
{ value: "u_102", label: "Ada Lovelace", description: "Design", icon: <User aria-hidden="true" /> },
|
|
245
|
+
{ value: "u_204", label: "Grace Hopper", description: "Platform", icon: <User aria-hidden="true" /> },
|
|
246
|
+
{ value: "u_311", label: "Katherine Johnson", description: "Data", icon: <User aria-hidden="true" /> },
|
|
247
|
+
{ value: "u_415", label: "Alan Turing", description: "On leave", icon: <User aria-hidden="true" />, disabled: true },
|
|
248
|
+
];
|
|
249
|
+
|
|
250
|
+
export function AssigneeField({ onAssign }: { onAssign: (userId: string) => void }) {
|
|
251
|
+
const [query, setQuery] = useState("");
|
|
252
|
+
|
|
253
|
+
return (
|
|
254
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-sm)" }}>
|
|
255
|
+
<Label htmlFor="assignee">Assignee</Label>
|
|
256
|
+
<AutocompleteSearch
|
|
257
|
+
id="assignee"
|
|
258
|
+
placeholder="Search teammates"
|
|
259
|
+
emptyMessage="No teammates match"
|
|
260
|
+
options={teammates}
|
|
261
|
+
value={query}
|
|
262
|
+
onValueChange={setQuery}
|
|
263
|
+
onSelect={(option) => onAssign(option.value)}
|
|
264
|
+
/>
|
|
265
|
+
</div>
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## 14. Related components
|
|
271
|
+
|
|
272
|
+
- [Input](./input.md): the base field; `type="search"` provides the icon.
|
|
273
|
+
- [Command](./command.md): a command palette, for actions rather than search results.
|
|
274
|
+
- [MultiSelect](./multi-select.md): choosing several values from a list.
|
|
275
|
+
- [Header](./header.md): put a site search in its `actions` slot.
|
|
276
|
+
- [Kbd](./kbd.md): keyboard hints elsewhere in the UI.
|
|
277
|
+
- [Navigation pattern](../patterns/navigation.md): where search sits in the page chrome.
|
|
278
|
+
|
|
279
|
+
## 15. Common agent mistakes
|
|
280
|
+
|
|
281
|
+
_Filled from evals._
|