@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,300 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Menubar
|
|
3
|
+
use_when: An editor-style app needs a persistent desktop-style bar of menus such as File, Edit and View.
|
|
4
|
+
instead_of: DropdownMenu for a single menu; NavigationMenu or Header for site navigation; Button or ToggleGroup for a toolbar of direct actions.
|
|
5
|
+
source: packages/core/src/components/menubar.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Menubar
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
Menubar is a horizontal bar of menu triggers, like a desktop app's File, Edit and View. It wraps Radix Menubar: each `MenubarMenu` pairs a trigger with a portalled panel of items, checkbox and radio items, labels, separators, shortcut hints and submenus. For choosing between menus, see the chooser in [DropdownMenu](./dropdown-menu.md).
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- Document, canvas, spreadsheet or code editors where users expect File, Edit, View, Insert menus.
|
|
17
|
+
- Apps with many commands that need a stable, discoverable home, each mirrored by a keyboard shortcut.
|
|
18
|
+
|
|
19
|
+
### When not to use
|
|
20
|
+
|
|
21
|
+
- One menu of actions → use [DropdownMenu](./dropdown-menu.md).
|
|
22
|
+
- Site or app navigation between pages → use [NavigationMenu](./navigation-menu.md), [Header](./header.md) or [NavigationDrawer](./navigation-drawer.md).
|
|
23
|
+
- A few direct actions or formatting toggles → use [Button](./button.md)s or a [ToggleGroup](./toggle-group.md).
|
|
24
|
+
- Phone-width layouts → use a [DropdownMenu](./dropdown-menu.md) or a [Sheet](./sheet.md); the bar doesn't adapt.
|
|
25
|
+
|
|
26
|
+
## 3. Anatomy
|
|
27
|
+
|
|
28
|
+
1. **Bar** (`Menubar`): the root row. `--container-bg` with a `--container-border` border, `--curves-md` radius, `--spacing-xs` padding and gap.
|
|
29
|
+
2. **Menu** (`MenubarMenu`): one top-level menu. Renders no element; holds one trigger and one content.
|
|
30
|
+
3. **Trigger** (`MenubarTrigger`): the menu's name in the bar, `--font-size-sm` at weight 500.
|
|
31
|
+
4. **Content** (`MenubarContent`): the panel, portalled to the nearest `PortalContainerProvider` container or `document.body`. Aligned to the trigger's start edge, 8px below it, minimum width 12rem, with a shadow.
|
|
32
|
+
5. **Item** (`MenubarItem`): one command row, `--font-size-sm`, padded `--spacing-sm`.
|
|
33
|
+
6. **Checkbox item** (`MenubarCheckboxItem`): shows a tick in a leading indicator slot when checked.
|
|
34
|
+
7. **Radio group and radio item** (`MenubarRadioGroup`, `MenubarRadioItem`): single choice, with a filled dot in the leading slot.
|
|
35
|
+
8. **Label** (`MenubarLabel`): a non-interactive group heading, weight 600.
|
|
36
|
+
9. **Separator** (`MenubarSeparator`): a 1px line between groups.
|
|
37
|
+
10. **Shortcut** (`MenubarShortcut`): trailing hint text at `--font-size-xs` in `--container-fg-alt`. Display only; it binds no keys.
|
|
38
|
+
11. **Group** (`MenubarGroup`): wraps related items.
|
|
39
|
+
12. **Submenu** (`MenubarSub`, `MenubarSubTrigger`, `MenubarSubContent`): a nested panel, minimum width 8rem; the sub-trigger adds a trailing chevron.
|
|
40
|
+
13. **Portal** (`MenubarPortal`): the Radix portal, re-exported. Content already portals.
|
|
41
|
+
|
|
42
|
+
## 4. Variants
|
|
43
|
+
|
|
44
|
+
Menubar has no variants. Items have no `tone`; only `DropdownMenuItem` has a destructive tone.
|
|
45
|
+
|
|
46
|
+
## 5. Sizes
|
|
47
|
+
|
|
48
|
+
Menubar has no size prop. Text is `--font-size-sm` and padding comes from `--spacing-*`, so the bar follows the density axis.
|
|
49
|
+
|
|
50
|
+
## 6. States
|
|
51
|
+
|
|
52
|
+
| State | Looks like | Notes |
|
|
53
|
+
| --- | --- | --- |
|
|
54
|
+
| Default | Triggers and items inherit `--container-fg` on `--container-bg` | |
|
|
55
|
+
| Hover | Items fill `--interactive-bg-hover` with `--interactive-fg` text | Pointing at an item focuses it. Triggers have no separate hover style until focused or open. |
|
|
56
|
+
| Focus | Trigger or item fills `--interactive-bg-hover`; no outline | Never remove or restyle the focus ring. |
|
|
57
|
+
| Open | The open menu's trigger keeps the `--interactive-bg-hover` fill; so does an open sub-trigger | |
|
|
58
|
+
| Checked | A tick (checkbox) or filled dot (radio) in the leading slot | Checkbox and radio items reserve the leading slot even when unchecked. |
|
|
59
|
+
| Disabled | `--interactive-bg-disabled` fill, `--interactive-fg-disabled` text, no pointer events | Arrow keys skip disabled items. |
|
|
60
|
+
|
|
61
|
+
Known issues:
|
|
62
|
+
|
|
63
|
+
- Separators use `--container-bg-alt`, which is barely visible on the panel in `minimal`. Keep using `MenubarSeparator`; don't draw your own line.
|
|
64
|
+
- `MenubarSubContent` has no shadow, so a submenu sits flat on the panel beneath it. Don't add one.
|
|
65
|
+
|
|
66
|
+
## 7. Content guidelines
|
|
67
|
+
|
|
68
|
+
- Name triggers with one short noun users know from desktop apps: File, Edit, View, Insert, Help.
|
|
69
|
+
- Start item labels with a verb: "New document", "Export as PDF", "Undo".
|
|
70
|
+
- End a label with an ellipsis (…) only when it opens a dialog that asks for more input: "Save as…".
|
|
71
|
+
- Show the shortcut for every command that has one, using platform glyphs: "⌘N", "⇧⌘Z".
|
|
72
|
+
- Use checkbox items for show/hide toggles ("Show ruler") and radio items for one-of choices ("Zoom: 100%").
|
|
73
|
+
|
|
74
|
+
| Do | Don't |
|
|
75
|
+
| --- | --- |
|
|
76
|
+
| File | File menu |
|
|
77
|
+
| New document | Document (new) |
|
|
78
|
+
| Show ruler | Ruler on/off |
|
|
79
|
+
|
|
80
|
+
## 8. Rules
|
|
81
|
+
|
|
82
|
+
1. Put exactly one `MenubarTrigger` and one `MenubarContent` in each `MenubarMenu`.
|
|
83
|
+
2. Use Menubar for commands, never for navigation links between pages.
|
|
84
|
+
3. Register every shortcut you show. `MenubarShortcut` is text only.
|
|
85
|
+
4. Keep the bar to a handful of short triggers that fit on one line; the bar doesn't wrap or collapse.
|
|
86
|
+
5. Call `event.preventDefault()` in `onSelect` to keep a menu open while toggling checkbox or radio items.
|
|
87
|
+
6. Never pass `className` or `style` to any part. Pass `container` on `MenubarContent` when a scoped theme must reach the panel (see [theming](../foundations/theming.md)).
|
|
88
|
+
|
|
89
|
+
## 9. Dos and don'ts
|
|
90
|
+
|
|
91
|
+
**Do:** group commands under familiar menus with real shortcuts.
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
<Menubar>
|
|
95
|
+
<MenubarMenu>
|
|
96
|
+
<MenubarTrigger>Edit</MenubarTrigger>
|
|
97
|
+
<MenubarContent>
|
|
98
|
+
<MenubarItem onSelect={undo}>
|
|
99
|
+
Undo <MenubarShortcut>⌘Z</MenubarShortcut>
|
|
100
|
+
</MenubarItem>
|
|
101
|
+
<MenubarItem onSelect={redo}>
|
|
102
|
+
Redo <MenubarShortcut>⇧⌘Z</MenubarShortcut>
|
|
103
|
+
</MenubarItem>
|
|
104
|
+
</MenubarContent>
|
|
105
|
+
</MenubarMenu>
|
|
106
|
+
</Menubar>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Don't:** use a Menubar as site navigation.
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
<Menubar>
|
|
113
|
+
<MenubarMenu>
|
|
114
|
+
<MenubarTrigger>Products</MenubarTrigger>
|
|
115
|
+
<MenubarContent>
|
|
116
|
+
<MenubarItem onSelect={() => (window.location.href = "/analytics")}>Analytics</MenubarItem>
|
|
117
|
+
</MenubarContent>
|
|
118
|
+
</MenubarMenu>
|
|
119
|
+
</Menubar>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## 10. Accessibility
|
|
123
|
+
|
|
124
|
+
- Role: the bar is `menubar`; triggers are `menuitem` with `aria-haspopup` and `aria-expanded`; panels are `menu`; items are `menuitem`, `menuitemcheckbox` or `menuitemradio`.
|
|
125
|
+
- Label: triggers and items are named by their text.
|
|
126
|
+
- Keyboard: Tab reaches the bar as one stop. ArrowLeft and ArrowRight move between triggers and wrap at the ends (`loop`). Enter, Space or ArrowDown opens a menu. Inside a menu, ArrowUp and ArrowDown move, Home and End jump to the ends, typing a letter jumps to a match, Enter or Space selects, ArrowRight opens a submenu or moves to the next menu, ArrowLeft closes a submenu or moves to the previous menu, and Escape closes the menu.
|
|
127
|
+
- Focus: opening moves focus into the menu; Escape returns it to the trigger.
|
|
128
|
+
- Pointer: a click opens a menu; while one is open, pointing at another trigger switches to it. To open on hover from rest, control `value` on `Menubar` and set it from each trigger's `onPointerEnter`, as the docs demo does.
|
|
129
|
+
- Contrast: handled by the theme. Don't override colours. Focus on triggers and items is shown only by the `--interactive-bg-hover` fill, which is faint in `minimal`; don't patch it per component.
|
|
130
|
+
|
|
131
|
+
## 11. Behaviour
|
|
132
|
+
|
|
133
|
+
- Positioning: each panel opens below its trigger, aligned to the trigger's start (`align="start"`, `alignOffset` -4, `sideOffset` 8), and flips to stay on screen.
|
|
134
|
+
- Responsive: no breakpoint behaviour. The bar is a non-wrapping flex row; on narrow screens swap it for a DropdownMenu or Sheet yourself.
|
|
135
|
+
- Overflow and truncation: panels have no maximum height or scroll. Keep menus to the commands that belong there.
|
|
136
|
+
- Motion: none. Don't add any.
|
|
137
|
+
|
|
138
|
+
## 12. API
|
|
139
|
+
|
|
140
|
+
<!-- api:start -->
|
|
141
|
+
### Menubar
|
|
142
|
+
|
|
143
|
+
| Prop | Type | Default | Description |
|
|
144
|
+
| --- | --- | --- | --- |
|
|
145
|
+
| `value` | `string` | | Controlled value of the open menu (`""` when none). |
|
|
146
|
+
| `defaultValue` | `string` | | Initially open menu when uncontrolled. |
|
|
147
|
+
| `onValueChange` | `(value: string) => void` | | Called when a menu opens or closes. |
|
|
148
|
+
| `loop` | `boolean` | `true` | Wraps arrow-key focus between the first and last trigger. |
|
|
149
|
+
| `...props` | Radix `Menubar.Root` props without `className`, `style` | | `dir`. |
|
|
150
|
+
|
|
151
|
+
### MenubarMenu
|
|
152
|
+
|
|
153
|
+
| Prop | Type | Default | Description |
|
|
154
|
+
| --- | --- | --- | --- |
|
|
155
|
+
| `value` | `string` | generated | Identifies the menu for `Menubar` `value`. |
|
|
156
|
+
| `...props` | Radix `Menubar.Menu` props | | Re-exported Radix part. |
|
|
157
|
+
|
|
158
|
+
### MenubarTrigger
|
|
159
|
+
|
|
160
|
+
| Prop | Type | Default | Description |
|
|
161
|
+
| --- | --- | --- | --- |
|
|
162
|
+
| `disabled` | `boolean` | `false` | Prevents opening. |
|
|
163
|
+
| `...props` | Radix `Menubar.Trigger` props without `className`, `style` | | `asChild`, `onPointerEnter`. |
|
|
164
|
+
|
|
165
|
+
### MenubarContent
|
|
166
|
+
|
|
167
|
+
| Prop | Type | Default | Description |
|
|
168
|
+
| --- | --- | --- | --- |
|
|
169
|
+
| `container` | `HTMLElement \| null` | provider container, then `document.body` | Element to portal into. |
|
|
170
|
+
| `align` | `"start" \| "center" \| "end"` | `"start"` | Alignment against the trigger. |
|
|
171
|
+
| `alignOffset` | `number` | `-4` | Shift along the alignment axis in px. |
|
|
172
|
+
| `sideOffset` | `number` | `8` | Distance from the trigger in px. |
|
|
173
|
+
| `...props` | Radix `Menubar.Content` props without `className`, `style` | | `side`, `loop`, `onCloseAutoFocus`. |
|
|
174
|
+
|
|
175
|
+
### MenubarItem, MenubarLabel, MenubarSubTrigger
|
|
176
|
+
|
|
177
|
+
| Prop | Type | Default | Description |
|
|
178
|
+
| --- | --- | --- | --- |
|
|
179
|
+
| `inset` | `boolean` | `false` | Adds left padding to line up with checkbox and radio items. |
|
|
180
|
+
| `onSelect` (Item) | `(event: Event) => void` | | Runs the command; `event.preventDefault()` keeps the menu open. |
|
|
181
|
+
| `disabled` (Item, SubTrigger) | `boolean` | `false` | Skipped by the keyboard, not clickable. |
|
|
182
|
+
| `...props` | Radix `Item` / `Label` / `SubTrigger` props without `className`, `style` | | `asChild`, `textValue`. |
|
|
183
|
+
|
|
184
|
+
### MenubarCheckboxItem, MenubarRadioGroup, MenubarRadioItem
|
|
185
|
+
|
|
186
|
+
| Prop | Type | Default | Description |
|
|
187
|
+
| --- | --- | --- | --- |
|
|
188
|
+
| `checked` (CheckboxItem) | `boolean \| "indeterminate"` | | Checked state. |
|
|
189
|
+
| `onCheckedChange` (CheckboxItem) | `(checked: boolean) => void` | | Called when toggled. |
|
|
190
|
+
| `value`, `onValueChange` (RadioGroup) | `string`, `(value: string) => void` | | Selected value and change handler. |
|
|
191
|
+
| `value` (RadioItem) | `string` | | Required. The item's value. |
|
|
192
|
+
| `...props` | Radix props without `className`, `style` | | `disabled`, `onSelect`. |
|
|
193
|
+
|
|
194
|
+
### MenubarSub, MenubarSubContent, MenubarSeparator, MenubarShortcut, MenubarGroup, MenubarPortal
|
|
195
|
+
|
|
196
|
+
| Prop | Type | Default | Description |
|
|
197
|
+
| --- | --- | --- | --- |
|
|
198
|
+
| `open`, `defaultOpen`, `onOpenChange` (Sub) | `boolean`, `boolean`, `(open: boolean) => void` | | Submenu open state. |
|
|
199
|
+
| `...props` (SubContent, Separator) | Radix props without `className`, `style` | | `sideOffset`, `loop` on SubContent. |
|
|
200
|
+
| `...props` (Shortcut) | `HTMLAttributes<HTMLSpanElement>` without `className`, `style` | | Renders a `<span>`. |
|
|
201
|
+
| `...props` (Group, Portal) | Radix `Group` / `Portal` props | | Re-exported Radix parts. |
|
|
202
|
+
|
|
203
|
+
`className` and `style` are omitted from every wrapped part. The re-exported Radix parts (Menu, Group, Portal, Sub, RadioGroup) still forward them; don't pass them there either.
|
|
204
|
+
<!-- api:end -->
|
|
205
|
+
|
|
206
|
+
## 13. Examples
|
|
207
|
+
|
|
208
|
+
```tsx
|
|
209
|
+
import * as React from "react";
|
|
210
|
+
import {
|
|
211
|
+
Menubar,
|
|
212
|
+
MenubarCheckboxItem,
|
|
213
|
+
MenubarContent,
|
|
214
|
+
MenubarItem,
|
|
215
|
+
MenubarMenu,
|
|
216
|
+
MenubarRadioGroup,
|
|
217
|
+
MenubarRadioItem,
|
|
218
|
+
MenubarSeparator,
|
|
219
|
+
MenubarShortcut,
|
|
220
|
+
MenubarSub,
|
|
221
|
+
MenubarSubContent,
|
|
222
|
+
MenubarSubTrigger,
|
|
223
|
+
MenubarTrigger,
|
|
224
|
+
} from "@eluan/core";
|
|
225
|
+
|
|
226
|
+
export function EditorMenubar({
|
|
227
|
+
onNew,
|
|
228
|
+
onExport,
|
|
229
|
+
onUndo,
|
|
230
|
+
onRedo,
|
|
231
|
+
}: {
|
|
232
|
+
onNew: () => void;
|
|
233
|
+
onExport: (format: "pdf" | "docx") => void;
|
|
234
|
+
onUndo: () => void;
|
|
235
|
+
onRedo: () => void;
|
|
236
|
+
}) {
|
|
237
|
+
const [showRuler, setShowRuler] = React.useState(true);
|
|
238
|
+
const [zoom, setZoom] = React.useState("100");
|
|
239
|
+
const keepOpen = (event: Event) => event.preventDefault();
|
|
240
|
+
|
|
241
|
+
return (
|
|
242
|
+
<div style={{ paddingBlock: "var(--spacing-sm)" }}>
|
|
243
|
+
<Menubar>
|
|
244
|
+
<MenubarMenu>
|
|
245
|
+
<MenubarTrigger>File</MenubarTrigger>
|
|
246
|
+
<MenubarContent>
|
|
247
|
+
<MenubarItem onSelect={onNew}>
|
|
248
|
+
New document <MenubarShortcut>⌘N</MenubarShortcut>
|
|
249
|
+
</MenubarItem>
|
|
250
|
+
<MenubarSeparator />
|
|
251
|
+
<MenubarSub>
|
|
252
|
+
<MenubarSubTrigger>Export as</MenubarSubTrigger>
|
|
253
|
+
<MenubarSubContent>
|
|
254
|
+
<MenubarItem onSelect={() => onExport("pdf")}>PDF</MenubarItem>
|
|
255
|
+
<MenubarItem onSelect={() => onExport("docx")}>Word document</MenubarItem>
|
|
256
|
+
</MenubarSubContent>
|
|
257
|
+
</MenubarSub>
|
|
258
|
+
</MenubarContent>
|
|
259
|
+
</MenubarMenu>
|
|
260
|
+
<MenubarMenu>
|
|
261
|
+
<MenubarTrigger>Edit</MenubarTrigger>
|
|
262
|
+
<MenubarContent>
|
|
263
|
+
<MenubarItem onSelect={onUndo}>
|
|
264
|
+
Undo <MenubarShortcut>⌘Z</MenubarShortcut>
|
|
265
|
+
</MenubarItem>
|
|
266
|
+
<MenubarItem onSelect={onRedo}>
|
|
267
|
+
Redo <MenubarShortcut>⇧⌘Z</MenubarShortcut>
|
|
268
|
+
</MenubarItem>
|
|
269
|
+
</MenubarContent>
|
|
270
|
+
</MenubarMenu>
|
|
271
|
+
<MenubarMenu>
|
|
272
|
+
<MenubarTrigger>View</MenubarTrigger>
|
|
273
|
+
<MenubarContent>
|
|
274
|
+
<MenubarCheckboxItem checked={showRuler} onCheckedChange={setShowRuler} onSelect={keepOpen}>
|
|
275
|
+
Show ruler
|
|
276
|
+
</MenubarCheckboxItem>
|
|
277
|
+
<MenubarSeparator />
|
|
278
|
+
<MenubarRadioGroup value={zoom} onValueChange={setZoom}>
|
|
279
|
+
<MenubarRadioItem value="75" onSelect={keepOpen}>Zoom 75%</MenubarRadioItem>
|
|
280
|
+
<MenubarRadioItem value="100" onSelect={keepOpen}>Zoom 100%</MenubarRadioItem>
|
|
281
|
+
<MenubarRadioItem value="150" onSelect={keepOpen}>Zoom 150%</MenubarRadioItem>
|
|
282
|
+
</MenubarRadioGroup>
|
|
283
|
+
</MenubarContent>
|
|
284
|
+
</MenubarMenu>
|
|
285
|
+
</Menubar>
|
|
286
|
+
</div>
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## 14. Related components
|
|
292
|
+
|
|
293
|
+
- [DropdownMenu](./dropdown-menu.md): a single menu on a trigger, and the chooser for all menus.
|
|
294
|
+
- [ContextMenu](./context-menu.md): the same commands on right-click.
|
|
295
|
+
- [NavigationMenu](./navigation-menu.md): navigation links with panels, not commands.
|
|
296
|
+
- [Kbd](./kbd.md): show a shortcut in running text rather than in a menu.
|
|
297
|
+
|
|
298
|
+
## 15. Common agent mistakes
|
|
299
|
+
|
|
300
|
+
_Filled from evals._
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: MultiSelect
|
|
3
|
+
use_when: The user picks several values from a list long enough to need search, such as labels, tags, assignees or filter values.
|
|
4
|
+
instead_of: CheckboxGroup for a short list that should stay visible; Select for one value; ToggleGroup type="multiple" for toolbar states.
|
|
5
|
+
source: packages/core/src/components/multi-select.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# MultiSelect
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
MultiSelect lets the user pick several values from a searchable list. The trigger shows each selected value as a removable chip; clicking it opens a Popover with a search field and a Command list. It is one component driven by an `options` array and takes no children.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- Several values from a list of about eight or more options, or any list the user will want to search.
|
|
17
|
+
- Labels, tags, assignees, technologies, or the values of a filter.
|
|
18
|
+
- A multi-value field where vertical space is tight and a column of checkboxes would be too tall.
|
|
19
|
+
|
|
20
|
+
### When not to use
|
|
21
|
+
|
|
22
|
+
- A short list where every option should stay visible → use [CheckboxGroup](./checkbox-group.md). It renders each option as a labelled checkbox with an optional description.
|
|
23
|
+
- One value → use [Select](./select.md).
|
|
24
|
+
- Several states that apply to content in a toolbar (bold and italic) → use [ToggleGroup](./toggle-group.md) with `type="multiple"`.
|
|
25
|
+
- Values the user types that aren't in a fixed list (free-form tags) → compose [Input](./input.md) with [Badge](./badge.md) chips. MultiSelect only picks from `options`.
|
|
26
|
+
- A command palette or search that runs actions → use [Command](./command.md).
|
|
27
|
+
|
|
28
|
+
## 3. Anatomy
|
|
29
|
+
|
|
30
|
+
1. **Trigger**: a `<div role="combobox">` styled like a field: `--interactive-bg`, 1px `--interactive-border-alt` border, at least `--size-lg` tall, growing as chips wrap. It's a div, not a button, because it contains buttons.
|
|
31
|
+
2. **Placeholder**: muted text (`--interactive-fg-alt`) shown when nothing is selected.
|
|
32
|
+
3. **Chips**: a `secondary` [Badge](./badge.md) per selected option, in selection order, each with a remove button named "Remove {label}". After `maxDisplayedItems` chips, one more chip shows "+N".
|
|
33
|
+
4. **Clear-all button**: appears at the end once anything is selected; named "Clear all selections".
|
|
34
|
+
5. **Chevron**: at the end, at 50% opacity; turns 180° while open.
|
|
35
|
+
6. **Panel**: a [Popover](./popover.md) as wide as the trigger. Holds a compact search field (`searchPlaceholder`) and the option list. Selected options sort to the top and show a check mark. When the search matches nothing, `emptyMessage` shows in muted text.
|
|
36
|
+
|
|
37
|
+
## 4. Variants
|
|
38
|
+
|
|
39
|
+
MultiSelect has no variants. Its look comes from the field tokens it shares with Select and Input.
|
|
40
|
+
|
|
41
|
+
## 5. Sizes
|
|
42
|
+
|
|
43
|
+
MultiSelect has no size prop. The trigger is at least `--size-lg` tall with `--font-size-sm` text and grows to fit wrapped chips; it fills its container's width, and the panel matches that width. Set width on a wrapper.
|
|
44
|
+
|
|
45
|
+
## 6. States
|
|
46
|
+
|
|
47
|
+
| State | Looks like | Notes |
|
|
48
|
+
| --- | --- | --- |
|
|
49
|
+
| Default | Field surface with the placeholder | |
|
|
50
|
+
| Hover | Chip remove buttons go from 60% to full opacity; clear-all fills with `--interactive-bg-hover` | The trigger itself has no hover style. |
|
|
51
|
+
| Focus | 1px outline in `--focus-ring`, 1px offset; the border also switches to `--focus-ring` | Never remove or restyle the focus ring. |
|
|
52
|
+
| Open | Chevron turned; panel below the trigger with the search field focused | The panel stays open while the user picks. |
|
|
53
|
+
| Selected | Chips in the trigger; the same options at the top of the list, weight 500, with a check mark | |
|
|
54
|
+
| Overflow | A "+N" chip after `maxDisplayedItems` chips | The hidden values stay selected and appear at the top of the list. |
|
|
55
|
+
| No results | `emptyMessage` in muted text | |
|
|
56
|
+
| Disabled | `--interactive-bg-disabled` fill, `--interactive-fg-disabled` text, not-allowed cursor | Set `disabled`. The trigger leaves the Tab order and won't open; chip remove and clear-all buttons are disabled. |
|
|
57
|
+
| Disabled option | The option fills with `--interactive-bg-disabled` and can't be picked | Set `disabled: true` on the option. |
|
|
58
|
+
| Error | No built-in error style | Put a [FormMessage](./form-label.md) under the field. MultiSelect accepts no `aria-*` props, so you can't set `aria-invalid` on it. |
|
|
59
|
+
|
|
60
|
+
## 7. Content guidelines
|
|
61
|
+
|
|
62
|
+
- Override the generic defaults with words from your domain. The defaults are "Select items…", "Search…" and "No items found.".
|
|
63
|
+
- Write the placeholder as a prompt ("Add labels"), the search placeholder as what to search ("Search labels"), and the empty message as what didn't match ("No labels match").
|
|
64
|
+
- Keep option labels to one to three words. Chips don't truncate, so long labels push the trigger onto more lines.
|
|
65
|
+
- Use the same label text the user will see in the chip; `label` is shown in both places.
|
|
66
|
+
|
|
67
|
+
| Do | Don't |
|
|
68
|
+
| --- | --- |
|
|
69
|
+
| Add labels | Select items… |
|
|
70
|
+
| Search teammates | Search… |
|
|
71
|
+
| No teammates match | No items found. |
|
|
72
|
+
| Bug, Feature, Design debt | bug_report, FEATURE-REQ |
|
|
73
|
+
|
|
74
|
+
## 8. Rules
|
|
75
|
+
|
|
76
|
+
1. Control MultiSelect with `value` and `onValueChange`, or seed it with `defaultValue`. It always emits the full array.
|
|
77
|
+
2. Give every option a unique `value` and a human-readable `label`. Search matches both.
|
|
78
|
+
3. Put a visible label directly above every MultiSelect. It accepts no `id`, `aria-label` or `aria-labelledby`, so a `htmlFor` link can't reach it (see Accessibility).
|
|
79
|
+
4. Submit the value yourself. MultiSelect has no `name` and renders no form input.
|
|
80
|
+
5. Pass `options` as a flat array. There's no grouping or custom option rendering.
|
|
81
|
+
6. Never pass children, `className` or `style`. Set width on a wrapper.
|
|
82
|
+
7. Don't put MultiSelect inside a `<button>` or a `<label>`; its trigger already contains buttons.
|
|
83
|
+
|
|
84
|
+
## 9. Dos and don'ts
|
|
85
|
+
|
|
86
|
+
**Do:** label the field and use domain words for every string.
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
<div role="group" aria-labelledby="labels-heading" style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-sm)" }}>
|
|
90
|
+
<Typography id="labels-heading" variant="label" weight="medium">Labels</Typography>
|
|
91
|
+
<MultiSelect
|
|
92
|
+
options={labelOptions}
|
|
93
|
+
value={labels}
|
|
94
|
+
onValueChange={setLabels}
|
|
95
|
+
placeholder="Add labels"
|
|
96
|
+
searchPlaceholder="Search labels"
|
|
97
|
+
emptyMessage="No labels match"
|
|
98
|
+
/>
|
|
99
|
+
</div>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Don't:** leave it unlabelled with generic text, or try to name it with props it drops.
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
<MultiSelect aria-label="Labels" options={labelOptions} onValueChange={setLabels} />
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Do:** use CheckboxGroup when there are only a few options.
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
<CheckboxGroup value={channels} onValueChange={setChannels}>
|
|
112
|
+
<CheckboxGroupItem value="email" label="Email" />
|
|
113
|
+
<CheckboxGroupItem value="sms" label="SMS" />
|
|
114
|
+
<CheckboxGroupItem value="push" label="Push" />
|
|
115
|
+
</CheckboxGroup>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Don't:** hide three options behind a searchable popover.
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
<MultiSelect
|
|
122
|
+
options={[
|
|
123
|
+
{ value: "email", label: "Email" },
|
|
124
|
+
{ value: "sms", label: "SMS" },
|
|
125
|
+
{ value: "push", label: "Push" },
|
|
126
|
+
]}
|
|
127
|
+
value={channels}
|
|
128
|
+
onValueChange={setChannels}
|
|
129
|
+
/>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## 10. Accessibility
|
|
133
|
+
|
|
134
|
+
- Role: the trigger is a `combobox` with `aria-expanded` (and `aria-disabled` when disabled). Chip remove and clear-all controls are `button`s inside it. The panel's search field is a `combobox`, the list a `listbox`, and each option an `option`.
|
|
135
|
+
- Label: MultiSelect accepts no `id`, `aria-label` or `aria-labelledby`, so its combobox has no accessible name. Put a visible label right above it and wrap both in an element with `role="group"` and `aria-labelledby` pointing at the label.
|
|
136
|
+
- Selected state: chosen options show a check mark (hidden from assistive tech) and a heavier weight; `aria-selected` on an option marks the keyboard highlight, not the selection. Screen-reader users hear the selection through the chips' "Remove {label}" buttons.
|
|
137
|
+
- Keyboard: on the trigger, Enter or Space toggles the panel and ArrowDown opens it. Tab moves from the trigger to each chip's remove button, then to clear-all. In the panel, typing filters, ArrowUp and ArrowDown move, Enter toggles the highlighted option, and Escape closes.
|
|
138
|
+
- Focus: opening moves focus into the panel's search field. The panel doesn't trap focus. Closing returns focus to the trigger. The chip remove and clear-all buttons show the same focus outline, at full opacity.
|
|
139
|
+
- Contrast: handled by the theme. Don't override colours.
|
|
140
|
+
|
|
141
|
+
## 11. Behaviour
|
|
142
|
+
|
|
143
|
+
- Responsive: the trigger fills its container and wraps chips onto new lines. The panel matches the trigger's width and opens below it, aligned to the start.
|
|
144
|
+
- Overflow and truncation: only the first `maxDisplayedItems` chips render (default 4); the rest collapse into "+N". Chips don't truncate long labels.
|
|
145
|
+
- Ordering: selected options sort to the top of the list each time it renders.
|
|
146
|
+
- Removing: a chip's remove button and clear-all change the value without opening the panel.
|
|
147
|
+
- Motion: field colours transition over 150ms and the chevron turns on open. Don't add your own.
|
|
148
|
+
|
|
149
|
+
## 12. API
|
|
150
|
+
|
|
151
|
+
<!-- api:start -->
|
|
152
|
+
| Prop | Type | Default | Description |
|
|
153
|
+
| --- | --- | --- | --- |
|
|
154
|
+
| `options` | `MultiSelectOption[]` (`{ value: string; label: string; disabled?: boolean }`) | | Required. The selectable options, in display order. |
|
|
155
|
+
| `value` | `string[]` | | Controlled selection. |
|
|
156
|
+
| `defaultValue` | `string[]` | `[]` | Initial selection when uncontrolled. |
|
|
157
|
+
| `onValueChange` | `(value: string[]) => void` | | Called with the full new selection. |
|
|
158
|
+
| `placeholder` | `string` | `"Select items…"` | Trigger text when nothing is selected. |
|
|
159
|
+
| `searchPlaceholder` | `string` | `"Search…"` | Placeholder in the panel's search field. |
|
|
160
|
+
| `emptyMessage` | `string` | `"No items found."` | Shown when the search matches nothing. |
|
|
161
|
+
| `maxDisplayedItems` | `number` | `4` | Chips shown before the "+N" chip. |
|
|
162
|
+
| `disabled` | `boolean` | `false` | Disables the whole control. |
|
|
163
|
+
<!-- api:end -->
|
|
164
|
+
|
|
165
|
+
MultiSelect takes only these props: no `children`, `id`, `name` or `aria-*`. `className` and `style` are omitted; Eluan components are styling-closed. The ref points at the trigger `<div>`.
|
|
166
|
+
|
|
167
|
+
## 13. Examples
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
import { useState } from "react";
|
|
171
|
+
import { MultiSelect, Typography, type MultiSelectOption } from "@eluan/core";
|
|
172
|
+
|
|
173
|
+
const labelOptions: MultiSelectOption[] = [
|
|
174
|
+
{ value: "bug", label: "Bug" },
|
|
175
|
+
{ value: "feature", label: "Feature" },
|
|
176
|
+
{ value: "design-debt", label: "Design debt" },
|
|
177
|
+
{ value: "docs", label: "Documentation" },
|
|
178
|
+
{ value: "performance", label: "Performance" },
|
|
179
|
+
{ value: "security", label: "Security" },
|
|
180
|
+
{ value: "accessibility", label: "Accessibility" },
|
|
181
|
+
{ value: "wontfix", label: "Won't fix", disabled: true },
|
|
182
|
+
];
|
|
183
|
+
|
|
184
|
+
export function IssueLabelsField() {
|
|
185
|
+
const [labels, setLabels] = useState<string[]>(["bug"]);
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
<div
|
|
189
|
+
role="group"
|
|
190
|
+
aria-labelledby="issue-labels-label"
|
|
191
|
+
style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-sm)" }}
|
|
192
|
+
>
|
|
193
|
+
<Typography id="issue-labels-label" variant="label" weight="medium">
|
|
194
|
+
Labels
|
|
195
|
+
</Typography>
|
|
196
|
+
<MultiSelect
|
|
197
|
+
options={labelOptions}
|
|
198
|
+
value={labels}
|
|
199
|
+
onValueChange={setLabels}
|
|
200
|
+
placeholder="Add labels"
|
|
201
|
+
searchPlaceholder="Search labels"
|
|
202
|
+
emptyMessage="No labels match"
|
|
203
|
+
maxDisplayedItems={3}
|
|
204
|
+
/>
|
|
205
|
+
</div>
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## 14. Related components
|
|
211
|
+
|
|
212
|
+
- [CheckboxGroup](./checkbox-group.md): several values from a short list, all visible.
|
|
213
|
+
- [Select](./select.md): one value from a list.
|
|
214
|
+
- [ToggleGroup](./toggle-group.md): several pressable tool states in a toolbar.
|
|
215
|
+
- [Command](./command.md) and [Popover](./popover.md): the parts MultiSelect is built from.
|
|
216
|
+
- [Badge](./badge.md): the chip used for each selected value.
|
|
217
|
+
- See [forms](../patterns/forms.md) for choosing between selection controls.
|
|
218
|
+
|
|
219
|
+
## 15. Common agent mistakes
|
|
220
|
+
|
|
221
|
+
_Filled from evals._
|