@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,359 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Command
|
|
3
|
+
use_when: A searchable, keyboard-driven list of commands or options, as a Cmd+K palette (CommandDialog), an inline filterable list or a searchable picker in a Popover.
|
|
4
|
+
instead_of: Select for a short fixed list; MultiSelect for several choices; SearchInput for a plain search field; DropdownMenu for a few actions behind a button. Eluan has no Combobox; Command is that primitive.
|
|
5
|
+
source: packages/core/src/components/command.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Command
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
Command is a filterable, keyboard-first list built on cmdk. Typing in its input filters and ranks the items; arrow keys move a highlight and Enter runs the highlighted item. Use it as a Cmd+K palette inside `CommandDialog`, inline on a surface, or inside a Popover as a searchable picker. Eluan has no separate Combobox: Command is the primitive, and MultiSelect is built from it.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- An app-wide command palette for navigation and actions, opened with Cmd/Ctrl+K and a visible trigger (`CommandDialog`).
|
|
17
|
+
- A filterable list that is a permanent part of the layout, such as a "Jump to setting" panel (inline `Command`).
|
|
18
|
+
- A searchable single-choice picker with many options, in a Popover.
|
|
19
|
+
|
|
20
|
+
### When not to use
|
|
21
|
+
|
|
22
|
+
- A short, fixed list of options in a form → use [Select](./select.md).
|
|
23
|
+
- Several choices from a searchable list → use [MultiSelect](./multi-select.md).
|
|
24
|
+
- A search field that filters page content, or one that just focuses on Cmd+K → use [SearchInput](./search-input.md) (`SearchInput` or `CommandSearch`).
|
|
25
|
+
- Suggestions under a text field as the user types → use [SearchInput](./search-input.md)'s `AutocompleteSearch`.
|
|
26
|
+
- A few actions behind a button → use [DropdownMenu](./dropdown-menu.md).
|
|
27
|
+
|
|
28
|
+
## 3. Anatomy
|
|
29
|
+
|
|
30
|
+
1. **Root** (`Command`): the container. Inline, it draws a `--container-border` border, `--curves-md` corners and a shadow, and fills its parent.
|
|
31
|
+
2. **Input** (`CommandInput`): a search icon and a borderless text input, with a `--container-border` line beneath.
|
|
32
|
+
3. **List** (`CommandList`): the scrolling listbox that holds everything below.
|
|
33
|
+
4. **Empty** (`CommandEmpty`): text shown only when nothing matches.
|
|
34
|
+
5. **Group** (`CommandGroup`): items under an optional `heading`, which renders small, in `--container-fg-alt` at weight 500.
|
|
35
|
+
6. **Item** (`CommandItem`): one row, with an optional leading icon, the label and an optional shortcut.
|
|
36
|
+
7. **Shortcut** (`CommandShortcut`): a muted hint pushed to the end of the row, at `--font-size-xs`.
|
|
37
|
+
8. **Separator** (`CommandSeparator`): the shared Separator line between groups, hidden while the user is searching.
|
|
38
|
+
|
|
39
|
+
## 4. Variants
|
|
40
|
+
|
|
41
|
+
There's no `variant` prop. Pick the presentation:
|
|
42
|
+
|
|
43
|
+
| Presentation | Use for |
|
|
44
|
+
| --- | --- |
|
|
45
|
+
| `CommandDialog` | The Cmd+K palette. A modal Dialog with a visually hidden title and description; the inner Command drops its own border and uses roomier rows. |
|
|
46
|
+
| Inline `Command` | A palette on the page or inside a Popover. Draws its own border and shadow. |
|
|
47
|
+
| `Dialog` with `DialogContent layout="command"` | What CommandDialog is built from: no padding and no close button. Compose it yourself only when you need Command props that CommandDialog doesn't pass through (`shouldFilter`, `filter`, `loop`, `label`, `value`). The inner Command then keeps its own border and the compact row padding. |
|
|
48
|
+
|
|
49
|
+
`CommandSearch` in [SearchInput](./search-input.md) is not part of Command: it is an Input with a Cmd+K hint that focuses itself on Cmd/Ctrl+K, with no list.
|
|
50
|
+
|
|
51
|
+
`CommandEmpty` has a `tone`: `default`, or `muted` (`--interactive-fg-alt`, less padding) for a compact picker.
|
|
52
|
+
|
|
53
|
+
## 5. Sizes
|
|
54
|
+
|
|
55
|
+
No size prop.
|
|
56
|
+
|
|
57
|
+
| Setting | Use in |
|
|
58
|
+
| --- | --- |
|
|
59
|
+
| `CommandInput density="default"` | Palettes and inline lists (`--size-xl` tall). |
|
|
60
|
+
| `CommandInput density="compact"` | A picker inside a Popover (`--size-lg`), as MultiSelect does. |
|
|
61
|
+
|
|
62
|
+
Inside `CommandDialog`, rows pad with `--spacing-sm` instead of `--spacing-xs` and the search icon grows from `--size-xxs` to `--size-xs`.
|
|
63
|
+
|
|
64
|
+
## 6. States
|
|
65
|
+
|
|
66
|
+
| State | Looks like | Notes |
|
|
67
|
+
| --- | --- | --- |
|
|
68
|
+
| Default | Rows in `--interactive-fg` | |
|
|
69
|
+
| Highlighted | The row under the keyboard cursor or pointer fills with `--interactive-bg-selected` and its text turns `--interactive-fg-selected` | cmdk calls this "selected" (`aria-selected`, `data-selected`). Moving the pointer over a row highlights it; there is no separate hover style. The CommandShortcut keeps `--container-fg-alt` and goes dark on the dark row; don't recolour it, and keep the full action name in the row so it reads without the hint. |
|
|
70
|
+
| Chosen | Weight 500 in `--interactive-fg` | Eluan's `selected` prop: the current value in a picker. It is visual only, with no ARIA state; add a Check icon as MultiSelect does. Not the same as Highlighted. |
|
|
71
|
+
| Focus | Focus stays in the input; the input draws no outline | Never remove or restyle the focus ring. The caret and the highlighted row show where the user is; don't add an outline to rows. |
|
|
72
|
+
| Disabled item | `--interactive-bg-disabled` fill, `--interactive-fg-disabled` text, no pointer events | Arrow keys skip it. |
|
|
73
|
+
| Empty | CommandEmpty text, centred | Only rendered when no item matches. |
|
|
74
|
+
| Loading | No built-in loading state | For results fetched as the user types, show a [Spinner](./spinner.md) in CommandEmpty's place. |
|
|
75
|
+
|
|
76
|
+
## 7. Content guidelines
|
|
77
|
+
|
|
78
|
+
- Write items as the page name or a verb phrase: "Settings", "New project", "Invite teammate". Sentence case.
|
|
79
|
+
- Write group headings as short nouns: "Go to", "Actions", "Recent".
|
|
80
|
+
- Write the placeholder as what can be searched: "Search pages and actions".
|
|
81
|
+
- Write the empty text as a plain statement: "No pages or actions match."
|
|
82
|
+
- Pass `title` and `description` to CommandDialog in sentence case; the defaults are "Command Menu" and "Search for a command to run."
|
|
83
|
+
- Write shortcut hints with symbols, matching what the app actually binds: "⌘P", "⌘,".
|
|
84
|
+
|
|
85
|
+
| Do | Don't |
|
|
86
|
+
| --- | --- |
|
|
87
|
+
| New project | Click to create a new project |
|
|
88
|
+
| No pages or actions match. | Oops! Nothing here |
|
|
89
|
+
| Go to | NAVIGATION |
|
|
90
|
+
|
|
91
|
+
## 8. Rules
|
|
92
|
+
|
|
93
|
+
1. Use `CommandDialog` for a Cmd+K palette. Bind Cmd/Ctrl+K yourself on `document`, and give it a visible trigger Button as well.
|
|
94
|
+
2. Put every item inside `CommandList`, with `CommandEmpty` first in the list.
|
|
95
|
+
3. Give every `CommandItem` a unique `value`. Without one, cmdk infers it from the row's text, shortcut hint included, and items with the same value highlight together. Add `keywords` for synonyms.
|
|
96
|
+
4. Run the item's action in `onSelect`. Enter and click both call it; an `onClick` on CommandItem is overwritten.
|
|
97
|
+
5. Close the dialog in `onSelect` when the item navigates or opens something else.
|
|
98
|
+
6. Use the `selected` prop only to mark the current value in a picker, with a Check icon. Never use it to show the highlight; cmdk handles that.
|
|
99
|
+
7. Use `CommandShortcut` for shortcut hints inside items, and [Kbd](./kbd.md) everywhere else.
|
|
100
|
+
8. Don't wrap an inline Command in another bordered or shadowed box; it draws its own.
|
|
101
|
+
9. Never pass `className` or `style`; they're omitted. Use a wrapper for width and height.
|
|
102
|
+
|
|
103
|
+
## 9. Dos and don'ts
|
|
104
|
+
|
|
105
|
+
**Do:** name items with a value, and act in `onSelect`.
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
<CommandItem value="Billing" keywords={["invoices", "payment"]} onSelect={() => run(() => navigate("/billing"))}>
|
|
109
|
+
Billing
|
|
110
|
+
<CommandShortcut>⌘B</CommandShortcut>
|
|
111
|
+
</CommandItem>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Don't:** use `onClick` or leave values to be guessed from text.
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
<CommandItem onClick={() => navigate("/billing")}>
|
|
118
|
+
Billing <CommandShortcut>⌘B</CommandShortcut>
|
|
119
|
+
</CommandItem>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Do:** build a searchable picker from Popover and Command, marking the chosen value.
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
<Popover open={open} onOpenChange={setOpen}>
|
|
126
|
+
<PopoverTrigger asChild>
|
|
127
|
+
<Button id="time-zone" type="button" variant={zone ? "input" : "inputMuted"} fullWidth align="start" textAlign="left">
|
|
128
|
+
{zone ?? "Choose a time zone"}
|
|
129
|
+
</Button>
|
|
130
|
+
</PopoverTrigger>
|
|
131
|
+
<PopoverContent layout="matchTrigger" align="start">
|
|
132
|
+
<Command label="Time zones">
|
|
133
|
+
<CommandInput placeholder="Search time zones" density="compact" />
|
|
134
|
+
<CommandList>
|
|
135
|
+
<CommandEmpty tone="muted">No time zones match.</CommandEmpty>
|
|
136
|
+
<CommandGroup>
|
|
137
|
+
{zones.map((name) => (
|
|
138
|
+
<CommandItem key={name} value={name} selected={name === zone} onSelect={() => { setZone(name); setOpen(false); }}>
|
|
139
|
+
{name}
|
|
140
|
+
{name === zone && <Check aria-hidden="true" style={{ marginLeft: "auto", width: "var(--size-xxs)", height: "var(--size-xxs)" }} />}
|
|
141
|
+
</CommandItem>
|
|
142
|
+
))}
|
|
143
|
+
</CommandGroup>
|
|
144
|
+
</CommandList>
|
|
145
|
+
</Command>
|
|
146
|
+
</PopoverContent>
|
|
147
|
+
</Popover>
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Don't:** hand-roll a filtered list with an Input and buttons.
|
|
151
|
+
|
|
152
|
+
```tsx
|
|
153
|
+
<Input value={query} onChange={(e) => setQuery(e.target.value)} />
|
|
154
|
+
{zones.filter((z) => z.includes(query)).map((z) => <button key={z} onClick={() => setZone(z)}>{z}</button>)}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## 10. Accessibility
|
|
158
|
+
|
|
159
|
+
- Role: the input is a `combobox` with `aria-expanded`, `aria-controls` and `aria-activedescendant`; the list is a `listbox`; items are `option`s, with `aria-selected` on the highlighted one; groups are `group`s named by their heading; separators are `separator`s.
|
|
160
|
+
- Label: the input is labelled by Command's visually hidden `label`; set it on an inline Command. CommandDialog doesn't pass one, so give its CommandInput a descriptive placeholder and an `aria-label`. The listbox is named "Suggestions" unless you pass CommandList `label`. CommandDialog's `title` names the dialog.
|
|
161
|
+
- Keyboard: Down and Up move the highlight (wrapping only with `loop`); Home and End jump to the first and last item; Alt with Down or Up jumps between groups; Enter runs the highlighted item; Ctrl+N or Ctrl+J and Ctrl+P or Ctrl+K also move down and up. Escape closes CommandDialog. Typing filters.
|
|
162
|
+
- Focus: focus stays in the input while the highlight moves. CommandDialog traps focus, focuses the input on open and puts focus back where it was on close. Inline Command doesn't trap focus.
|
|
163
|
+
- Contrast: handled by the theme. Don't override colours, including the shortcut hint on the highlighted row (States).
|
|
164
|
+
|
|
165
|
+
## 11. Behaviour
|
|
166
|
+
|
|
167
|
+
- Filtering: items are filtered and ranked by match score as the user types. Groups with no matches hide, separators hide while there's a query, and CommandEmpty shows when nothing matches. Set `shouldFilter={false}` on Command to filter the items yourself.
|
|
168
|
+
- Responsive: inline Command fills the width and height of its parent; constrain it with a wrapper. CommandDialog takes the Dialog's width.
|
|
169
|
+
- Overflow: CommandList has a fixed maximum height and scrolls; the highlighted item scrolls into view.
|
|
170
|
+
- Motion: none of its own; CommandDialog uses the Dialog's. Don't add any.
|
|
171
|
+
|
|
172
|
+
## 12. API
|
|
173
|
+
|
|
174
|
+
<!-- api:start -->
|
|
175
|
+
### Command
|
|
176
|
+
|
|
177
|
+
| Prop | Type | Default | Description |
|
|
178
|
+
| --- | --- | --- | --- |
|
|
179
|
+
| `label` | `string` | | Visually hidden label for the input. |
|
|
180
|
+
| `shouldFilter` | `boolean` | `true` | Set `false` to filter and sort items yourself. |
|
|
181
|
+
| `filter` | `(value: string, search: string, keywords?: string[]) => number` | cmdk's scorer | Match score from 0 (hidden) to 1 (best). |
|
|
182
|
+
| `value` | `string` | | Controlled value of the highlighted item. |
|
|
183
|
+
| `defaultValue` | `string` | | Initially highlighted item. |
|
|
184
|
+
| `onValueChange` | `(value: string) => void` | | Called when the highlight moves. |
|
|
185
|
+
| `loop` | `boolean` | `false` | Arrow keys wrap around. |
|
|
186
|
+
| `vimBindings` | `boolean` | `true` | Ctrl+N/J/P/K navigation. |
|
|
187
|
+
| `disablePointerSelection` | `boolean` | `false` | Stops the pointer moving the highlight. |
|
|
188
|
+
| `...props` | cmdk `Command` (div attributes) without `className`, `style` | | |
|
|
189
|
+
|
|
190
|
+
### CommandDialog
|
|
191
|
+
|
|
192
|
+
| Prop | Type | Default | Description |
|
|
193
|
+
| --- | --- | --- | --- |
|
|
194
|
+
| `open` | `boolean` | | Controlled open state. |
|
|
195
|
+
| `onOpenChange` | `(open: boolean) => void` | | Called on open and close. |
|
|
196
|
+
| `defaultOpen` | `boolean` | | Initial state when uncontrolled. |
|
|
197
|
+
| `title` | `string` | `"Command Menu"` | Visually hidden dialog title. |
|
|
198
|
+
| `description` | `string` | `"Search for a command to run."` | Visually hidden dialog description. |
|
|
199
|
+
| `...props` | Radix `Dialog` root props | | `modal` and the rest. Command props are not passed to the inner Command. |
|
|
200
|
+
|
|
201
|
+
### CommandInput
|
|
202
|
+
|
|
203
|
+
| Prop | Type | Default | Description |
|
|
204
|
+
| --- | --- | --- | --- |
|
|
205
|
+
| `density` | `"default" \| "compact"` | `"default"` | Input height: `--size-xl` or `--size-lg`. |
|
|
206
|
+
| `value` | `string` | | Controlled search text. |
|
|
207
|
+
| `onValueChange` | `(search: string) => void` | | Called as the search text changes. |
|
|
208
|
+
| `placeholder` | `string` | | Hint for what can be searched. |
|
|
209
|
+
| `...props` | cmdk `Command.Input` (input attributes) without `className`, `size`, `style` | | |
|
|
210
|
+
|
|
211
|
+
### CommandList
|
|
212
|
+
|
|
213
|
+
| Prop | Type | Default | Description |
|
|
214
|
+
| --- | --- | --- | --- |
|
|
215
|
+
| `label` | `string` | `"Suggestions"` | Accessible name of the listbox. |
|
|
216
|
+
| `...props` | cmdk `Command.List` without `className`, `style` | | |
|
|
217
|
+
|
|
218
|
+
### CommandEmpty
|
|
219
|
+
|
|
220
|
+
| Prop | Type | Default | Description |
|
|
221
|
+
| --- | --- | --- | --- |
|
|
222
|
+
| `tone` | `"default" \| "muted"` | `"default"` | `muted` uses `--interactive-fg-alt` and less padding. |
|
|
223
|
+
| `...props` | cmdk `Command.Empty` without `className`, `style` | | |
|
|
224
|
+
|
|
225
|
+
### CommandGroup
|
|
226
|
+
|
|
227
|
+
| Prop | Type | Default | Description |
|
|
228
|
+
| --- | --- | --- | --- |
|
|
229
|
+
| `heading` | `ReactNode` | | Group label; also names the group. |
|
|
230
|
+
| `value` | `string` | | Group identity. |
|
|
231
|
+
| `forceMount` | `boolean` | | Keeps the group rendered when nothing in it matches. |
|
|
232
|
+
| `...props` | cmdk `Command.Group` without `className`, `style` | | |
|
|
233
|
+
|
|
234
|
+
### CommandItem
|
|
235
|
+
|
|
236
|
+
| Prop | Type | Default | Description |
|
|
237
|
+
| --- | --- | --- | --- |
|
|
238
|
+
| `onSelect` | `(value: string) => void` | | Runs on Enter or click. |
|
|
239
|
+
| `value` | `string` | the row's text | Unique identity used for filtering and the highlight. |
|
|
240
|
+
| `keywords` | `string[]` | | Extra terms that match this item. |
|
|
241
|
+
| `disabled` | `boolean` | `false` | Skipped by the keyboard and the pointer. |
|
|
242
|
+
| `selected` | `boolean` | `false` | Eluan: marks the current value (weight 500). Not the highlight. |
|
|
243
|
+
| `forceMount` | `boolean` | | Keeps the item rendered when it doesn't match. |
|
|
244
|
+
| `...props` | cmdk `Command.Item` without `className`, `style` | | `onClick` is overwritten; use `onSelect`. |
|
|
245
|
+
|
|
246
|
+
### CommandShortcut
|
|
247
|
+
|
|
248
|
+
| Prop | Type | Default | Description |
|
|
249
|
+
| --- | --- | --- | --- |
|
|
250
|
+
| `...props` | `HTMLAttributes<HTMLSpanElement>` without `className`, `style` | | The hint text as children. |
|
|
251
|
+
|
|
252
|
+
### CommandSeparator
|
|
253
|
+
|
|
254
|
+
| Prop | Type | Default | Description |
|
|
255
|
+
| --- | --- | --- | --- |
|
|
256
|
+
| `alwaysRender` | `boolean` | `false` | Keeps the line visible while searching. |
|
|
257
|
+
<!-- api:end -->
|
|
258
|
+
|
|
259
|
+
## 13. Examples
|
|
260
|
+
|
|
261
|
+
```tsx
|
|
262
|
+
import * as React from "react";
|
|
263
|
+
import {
|
|
264
|
+
Button,
|
|
265
|
+
CommandDialog,
|
|
266
|
+
CommandEmpty,
|
|
267
|
+
CommandGroup,
|
|
268
|
+
CommandInput,
|
|
269
|
+
CommandItem,
|
|
270
|
+
CommandList,
|
|
271
|
+
CommandSeparator,
|
|
272
|
+
CommandShortcut,
|
|
273
|
+
Kbd,
|
|
274
|
+
} from "@eluan/core";
|
|
275
|
+
import { FilePlus, FolderOpen, Settings, Users } from "lucide-react";
|
|
276
|
+
|
|
277
|
+
const icon = { width: "var(--size-xxs)", height: "var(--size-xxs)" };
|
|
278
|
+
|
|
279
|
+
export function AppCommandMenu({
|
|
280
|
+
navigate,
|
|
281
|
+
createProject,
|
|
282
|
+
}: {
|
|
283
|
+
navigate: (path: string) => void;
|
|
284
|
+
createProject: () => void;
|
|
285
|
+
}) {
|
|
286
|
+
const [open, setOpen] = React.useState(false);
|
|
287
|
+
|
|
288
|
+
React.useEffect(() => {
|
|
289
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
290
|
+
if (event.key.toLowerCase() === "k" && (event.metaKey || event.ctrlKey)) {
|
|
291
|
+
event.preventDefault();
|
|
292
|
+
setOpen((value) => !value);
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
document.addEventListener("keydown", onKeyDown);
|
|
296
|
+
return () => document.removeEventListener("keydown", onKeyDown);
|
|
297
|
+
}, []);
|
|
298
|
+
|
|
299
|
+
const run = (action: () => void) => {
|
|
300
|
+
setOpen(false);
|
|
301
|
+
action();
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
return (
|
|
305
|
+
<>
|
|
306
|
+
<Button type="button" variant="outline" aria-keyshortcuts="Meta+K Control+K" onClick={() => setOpen(true)}>
|
|
307
|
+
Search
|
|
308
|
+
<Kbd keys="cmd+k" size="sm" variant="ghost" aria-hidden="true" />
|
|
309
|
+
</Button>
|
|
310
|
+
<CommandDialog
|
|
311
|
+
open={open}
|
|
312
|
+
onOpenChange={setOpen}
|
|
313
|
+
title="Command menu"
|
|
314
|
+
description="Search for a page or an action."
|
|
315
|
+
>
|
|
316
|
+
<CommandInput placeholder="Search pages and actions" aria-label="Search pages and actions" />
|
|
317
|
+
<CommandList>
|
|
318
|
+
<CommandEmpty>No pages or actions match.</CommandEmpty>
|
|
319
|
+
<CommandGroup heading="Go to">
|
|
320
|
+
<CommandItem value="Projects" onSelect={() => run(() => navigate("/projects"))}>
|
|
321
|
+
<FolderOpen aria-hidden="true" style={icon} />
|
|
322
|
+
Projects
|
|
323
|
+
</CommandItem>
|
|
324
|
+
<CommandItem value="Team members" keywords={["people", "users"]} onSelect={() => run(() => navigate("/team"))}>
|
|
325
|
+
<Users aria-hidden="true" style={icon} />
|
|
326
|
+
Team members
|
|
327
|
+
</CommandItem>
|
|
328
|
+
<CommandItem value="Settings" onSelect={() => run(() => navigate("/settings"))}>
|
|
329
|
+
<Settings aria-hidden="true" style={icon} />
|
|
330
|
+
Settings
|
|
331
|
+
<CommandShortcut>⌘,</CommandShortcut>
|
|
332
|
+
</CommandItem>
|
|
333
|
+
</CommandGroup>
|
|
334
|
+
<CommandSeparator />
|
|
335
|
+
<CommandGroup heading="Actions">
|
|
336
|
+
<CommandItem value="New project" onSelect={() => run(createProject)}>
|
|
337
|
+
<FilePlus aria-hidden="true" style={icon} />
|
|
338
|
+
New project
|
|
339
|
+
</CommandItem>
|
|
340
|
+
</CommandGroup>
|
|
341
|
+
</CommandList>
|
|
342
|
+
</CommandDialog>
|
|
343
|
+
</>
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
## 14. Related components
|
|
349
|
+
|
|
350
|
+
- [Dialog](./dialog.md): CommandDialog is a Dialog with `layout="command"`.
|
|
351
|
+
- [SearchInput](./search-input.md): plain search fields, `CommandSearch` (focus on Cmd+K, no list) and `AutocompleteSearch`.
|
|
352
|
+
- [MultiSelect](./multi-select.md): a searchable multi-choice picker built from Command in a Popover.
|
|
353
|
+
- [Popover](./popover.md): the surface for a searchable picker.
|
|
354
|
+
- [Kbd](./kbd.md): shortcut keycaps outside Command rows, such as on the trigger Button.
|
|
355
|
+
- [DropdownMenu](./dropdown-menu.md): a short menu of actions without search.
|
|
356
|
+
|
|
357
|
+
## 15. Common agent mistakes
|
|
358
|
+
|
|
359
|
+
_Filled from evals._
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ContextMenu
|
|
3
|
+
use_when: Right-click or long-press on a surface (a file tile, canvas or row) should offer actions for that thing.
|
|
4
|
+
instead_of: DropdownMenu or ActionPopover for a visible actions button; Menubar for an app-wide File/Edit bar; Select to pick a value.
|
|
5
|
+
source: packages/core/src/components/context-menu.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# ContextMenu
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
ContextMenu opens a floating list of actions where the user right-clicks, or after a 700ms long-press on touch. It wraps Radix ContextMenu: the panel portals out of the page and supports items, checkbox and radio items, labels, separators, shortcut hints and submenus. It's a shortcut to actions, so the same actions must also be reachable another way. For choosing between menus, see the chooser in [DropdownMenu](./dropdown-menu.md).
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- Right-click actions on an object in a workspace: a file or folder tile, a canvas layer, a kanban card.
|
|
17
|
+
- Power-user shortcuts that mirror a visible actions menu or toolbar.
|
|
18
|
+
|
|
19
|
+
### When not to use
|
|
20
|
+
|
|
21
|
+
- The only way to reach an action → use [DropdownMenu](./dropdown-menu.md) or [ActionPopover](./action-popover.md) on a visible button. Add a ContextMenu alongside it if you want.
|
|
22
|
+
- A row actions menu in a table → use [DropdownMenu](./dropdown-menu.md) or [ActionPopover](./action-popover.md) in the row.
|
|
23
|
+
- File/Edit/View menus for the whole app → use [Menubar](./menubar.md).
|
|
24
|
+
- Picking a value → use [Select](./select.md).
|
|
25
|
+
- Ordinary page text or links, where users expect the browser's own menu → leave the native menu alone.
|
|
26
|
+
|
|
27
|
+
## 3. Anatomy
|
|
28
|
+
|
|
29
|
+
1. **Root** (`ContextMenu`): holds open state. Renders no element.
|
|
30
|
+
2. **Trigger** (`ContextMenuTrigger`): the area that opens the menu on right-click or long-press. Use `asChild` around an element you own and style.
|
|
31
|
+
3. **Content** (`ContextMenuContent`): the floating panel at the pointer, portalled to the nearest `PortalContainerProvider` container or `document.body`. `--container-bg` surface, `--container-border` border, `--curves-md` radius, `--spacing-xxs` padding, minimum width 8rem.
|
|
32
|
+
4. **Item** (`ContextMenuItem`): one action row, `--font-size-sm`, `--curves-sm` radius.
|
|
33
|
+
5. **Checkbox item** (`ContextMenuCheckboxItem`): shows a tick in a leading indicator slot when checked.
|
|
34
|
+
6. **Radio group and radio item** (`ContextMenuRadioGroup`, `ContextMenuRadioItem`): single choice, with a filled dot in the leading slot.
|
|
35
|
+
7. **Label** (`ContextMenuLabel`): a non-interactive group heading, weight 600, `--interactive-fg`.
|
|
36
|
+
8. **Separator** (`ContextMenuSeparator`): a 1px `--container-border` line between groups.
|
|
37
|
+
9. **Shortcut** (`ContextMenuShortcut`): trailing hint text at `--font-size-xs` in `--interactive-fg-alt`. Display only; it binds no keys.
|
|
38
|
+
10. **Group** (`ContextMenuGroup`): wraps related items.
|
|
39
|
+
11. **Submenu** (`ContextMenuSub`, `ContextMenuSubTrigger`, `ContextMenuSubContent`): a nested panel; the sub-trigger adds a trailing chevron.
|
|
40
|
+
12. **Portal** (`ContextMenuPortal`): the Radix portal, re-exported. Content already portals.
|
|
41
|
+
|
|
42
|
+
## 4. Variants
|
|
43
|
+
|
|
44
|
+
ContextMenu has no variants. Items have no `tone`; only `DropdownMenuItem` has a destructive tone.
|
|
45
|
+
|
|
46
|
+
## 5. Sizes
|
|
47
|
+
|
|
48
|
+
ContextMenu has no size prop. Item text is `--font-size-sm` and padding comes from `--spacing-*`, so the menu follows the density axis.
|
|
49
|
+
|
|
50
|
+
## 6. States
|
|
51
|
+
|
|
52
|
+
| State | Looks like | Notes |
|
|
53
|
+
| --- | --- | --- |
|
|
54
|
+
| Default | Items inherit `--container-fg` on `--container-bg` | |
|
|
55
|
+
| Hover | Item row fills `--interactive-bg-hover` with `--interactive-fg` text | Pointing at an item focuses it, so hover and keyboard focus look the same. |
|
|
56
|
+
| Focus | The highlighted row, no outline | Never remove or restyle the focus ring. |
|
|
57
|
+
| Open | A sub-trigger with its submenu open keeps the `--interactive-bg-hover` fill | |
|
|
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
|
+
## 7. Content guidelines
|
|
62
|
+
|
|
63
|
+
- Start action labels with a verb: "Rename…", "Duplicate", "Move to trash".
|
|
64
|
+
- Use sentence case and keep labels to one to four words.
|
|
65
|
+
- Match the labels of the visible actions menu exactly, so both routes read the same.
|
|
66
|
+
- End a label with an ellipsis (…) only when it opens a dialog that asks for more input.
|
|
67
|
+
- Put destructive actions last, after a separator.
|
|
68
|
+
- Show a shortcut only if it works elsewhere in the app: "⌘C", "⌫".
|
|
69
|
+
|
|
70
|
+
| Do | Don't |
|
|
71
|
+
| --- | --- |
|
|
72
|
+
| Move to trash | Trash it |
|
|
73
|
+
| Rename… | Edit name of this file |
|
|
74
|
+
| Copy link | Link |
|
|
75
|
+
|
|
76
|
+
## 8. Rules
|
|
77
|
+
|
|
78
|
+
1. Offer every ContextMenu action somewhere visible too: a [DropdownMenu](./dropdown-menu.md), [ActionPopover](./action-popover.md) or toolbar Button inside or next to the target. Right-click is hidden from touch-only and keyboard users.
|
|
79
|
+
2. Wrap the target with `<ContextMenuTrigger asChild>` around an element you own, and style that element. Don't pass `style` to the trigger.
|
|
80
|
+
3. Put destructive actions last, after a separator, and confirm them in a [Dialog](./dialog.md). ContextMenu has no destructive tone; don't colour the item yourself.
|
|
81
|
+
4. Run actions in `onSelect`. Call `event.preventDefault()` in `onSelect` to keep the menu open while toggling checkbox or radio items.
|
|
82
|
+
5. Never pass `className` or `style` to any part. Pass `container` on `ContextMenuContent` when a scoped theme must reach the panel (see [theming](../foundations/theming.md)).
|
|
83
|
+
|
|
84
|
+
## 9. Dos and don'ts
|
|
85
|
+
|
|
86
|
+
**Do:** put the target in an element you own and mirror the actions on a visible button.
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
<ContextMenu>
|
|
90
|
+
<ContextMenuTrigger asChild>
|
|
91
|
+
<div style={{ display: "flex", gap: "var(--spacing-sm)", padding: "var(--spacing-md)", borderRadius: "var(--curves-md)" }}>
|
|
92
|
+
<span>Q3 report.pdf</span>
|
|
93
|
+
<ActionPopover aria-label="Actions for Q3 report.pdf" items={fileActions} />
|
|
94
|
+
</div>
|
|
95
|
+
</ContextMenuTrigger>
|
|
96
|
+
<ContextMenuContent>
|
|
97
|
+
<ContextMenuItem onSelect={onRename}>Rename…</ContextMenuItem>
|
|
98
|
+
</ContextMenuContent>
|
|
99
|
+
</ContextMenu>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Don't:** style the trigger directly or make right-click the only route.
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
<ContextMenu>
|
|
106
|
+
<ContextMenuTrigger style={{ height: "8rem", border: "1px dashed #ccc" }}>
|
|
107
|
+
Right-click here
|
|
108
|
+
</ContextMenuTrigger>
|
|
109
|
+
<ContextMenuContent>
|
|
110
|
+
<ContextMenuItem>Rename</ContextMenuItem>
|
|
111
|
+
</ContextMenuContent>
|
|
112
|
+
</ContextMenu>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**Do:** separate destructive actions at the end.
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
<ContextMenuContent>
|
|
119
|
+
<ContextMenuItem onSelect={onDuplicate}>Duplicate</ContextMenuItem>
|
|
120
|
+
<ContextMenuSeparator />
|
|
121
|
+
<ContextMenuItem onSelect={() => setConfirmOpen(true)}>Move to trash</ContextMenuItem>
|
|
122
|
+
</ContextMenuContent>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Don't:** mix them in and recolour them.
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
<ContextMenuContent>
|
|
129
|
+
<ContextMenuItem onSelect={trashFile}>
|
|
130
|
+
<span style={{ color: "var(--destructive-fg)" }}>Move to trash</span>
|
|
131
|
+
</ContextMenuItem>
|
|
132
|
+
<ContextMenuItem onSelect={onDuplicate}>Duplicate</ContextMenuItem>
|
|
133
|
+
</ContextMenuContent>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## 10. Accessibility
|
|
137
|
+
|
|
138
|
+
- Role: the content is `menu`; items are `menuitem`, `menuitemcheckbox` or `menuitemradio`. The trigger adds no role; it keeps your element's role.
|
|
139
|
+
- Label: items are named by their text.
|
|
140
|
+
- Keyboard: the menu opens on the trigger's `contextmenu` event; give keyboard users the visible actions menu (Rule 1). Inside the menu, ArrowUp and ArrowDown move between items, Home and End jump to the ends, typing a letter jumps to a matching item, Enter or Space selects, ArrowRight opens a submenu, ArrowLeft closes it and Escape closes the menu.
|
|
141
|
+
- Focus: opening moves focus into the menu. The menu is modal by default (`modal`), so outside pointer interaction is blocked while it is open.
|
|
142
|
+
- Touch: a 700ms long-press opens the menu; moving the finger cancels it.
|
|
143
|
+
- Contrast: handled by the theme. Don't override colours. The focused item is shown only by its `--interactive-bg-hover` fill, which is faint in `minimal`; don't patch it per menu.
|
|
144
|
+
|
|
145
|
+
## 11. Behaviour
|
|
146
|
+
|
|
147
|
+
- Positioning: the panel opens at the pointer and flips to stay on screen.
|
|
148
|
+
- Responsive: no breakpoint behaviour. The panel is at least 8rem wide.
|
|
149
|
+
- Overflow and truncation: no maximum height or scroll. Keep menus short.
|
|
150
|
+
- Closing: selecting an item closes the menu unless `onSelect` calls `event.preventDefault()`. Escape and outside clicks close it.
|
|
151
|
+
- Disabled trigger: `disabled` on `ContextMenuTrigger` restores the browser's native menu.
|
|
152
|
+
- Motion: none. Don't add any.
|
|
153
|
+
|
|
154
|
+
## 12. API
|
|
155
|
+
|
|
156
|
+
<!-- api:start -->
|
|
157
|
+
### ContextMenu
|
|
158
|
+
|
|
159
|
+
| Prop | Type | Default | Description |
|
|
160
|
+
| --- | --- | --- | --- |
|
|
161
|
+
| `onOpenChange` | `(open: boolean) => void` | | Called when the menu opens or closes. |
|
|
162
|
+
| `modal` | `boolean` | `true` | Blocks outside interaction while open. |
|
|
163
|
+
| `...props` | Radix `ContextMenu.Root` props | | `dir`. There is no controlled `open`; the pointer opens it. |
|
|
164
|
+
|
|
165
|
+
### ContextMenuTrigger
|
|
166
|
+
|
|
167
|
+
| Prop | Type | Default | Description |
|
|
168
|
+
| --- | --- | --- | --- |
|
|
169
|
+
| `asChild` | `boolean` | `false` | Renders your child as the trigger area. |
|
|
170
|
+
| `disabled` | `boolean` | `false` | Turns the custom menu off; the native menu shows instead. |
|
|
171
|
+
| `...props` | Radix `ContextMenu.Trigger` props | | Re-exported Radix part; renders a `<span>` without `asChild`. |
|
|
172
|
+
|
|
173
|
+
### ContextMenuContent
|
|
174
|
+
|
|
175
|
+
| Prop | Type | Default | Description |
|
|
176
|
+
| --- | --- | --- | --- |
|
|
177
|
+
| `container` | `HTMLElement \| null` | provider container, then `document.body` | Element to portal into. |
|
|
178
|
+
| `loop` | `boolean` | `false` | Wraps arrow-key focus from last to first item. |
|
|
179
|
+
| `...props` | Radix `ContextMenu.Content` props without `className`, `style` | | `alignOffset`, `collisionPadding`, `onEscapeKeyDown`, `onCloseAutoFocus`. |
|
|
180
|
+
|
|
181
|
+
### ContextMenuItem, ContextMenuLabel, ContextMenuSubTrigger
|
|
182
|
+
|
|
183
|
+
| Prop | Type | Default | Description |
|
|
184
|
+
| --- | --- | --- | --- |
|
|
185
|
+
| `inset` | `boolean` | `false` | Adds left padding to line up with checkbox and radio items. |
|
|
186
|
+
| `onSelect` (Item) | `(event: Event) => void` | | Runs the action; `event.preventDefault()` keeps the menu open. |
|
|
187
|
+
| `disabled` (Item, SubTrigger) | `boolean` | `false` | Skipped by the keyboard, not clickable. |
|
|
188
|
+
| `...props` | Radix `Item` / `Label` / `SubTrigger` props without `className`, `style` | | `asChild`, `textValue`. |
|
|
189
|
+
|
|
190
|
+
### ContextMenuCheckboxItem, ContextMenuRadioGroup, ContextMenuRadioItem
|
|
191
|
+
|
|
192
|
+
| Prop | Type | Default | Description |
|
|
193
|
+
| --- | --- | --- | --- |
|
|
194
|
+
| `checked` (CheckboxItem) | `boolean \| "indeterminate"` | | Checked state. |
|
|
195
|
+
| `onCheckedChange` (CheckboxItem) | `(checked: boolean) => void` | | Called when toggled. |
|
|
196
|
+
| `value`, `onValueChange` (RadioGroup) | `string`, `(value: string) => void` | | Selected value and change handler. |
|
|
197
|
+
| `value` (RadioItem) | `string` | | Required. The item's value. |
|
|
198
|
+
| `...props` | Radix props without `className`, `style` | | `disabled`, `onSelect`. |
|
|
199
|
+
|
|
200
|
+
### ContextMenuSub, ContextMenuSubContent, ContextMenuSeparator, ContextMenuShortcut, ContextMenuGroup, ContextMenuPortal
|
|
201
|
+
|
|
202
|
+
| Prop | Type | Default | Description |
|
|
203
|
+
| --- | --- | --- | --- |
|
|
204
|
+
| `open`, `defaultOpen`, `onOpenChange` (Sub) | `boolean`, `boolean`, `(open: boolean) => void` | | Submenu open state. |
|
|
205
|
+
| `...props` (SubContent, Separator) | Radix props without `className`, `style` | | `sideOffset`, `loop` on SubContent. |
|
|
206
|
+
| `...props` (Shortcut) | `HTMLAttributes<HTMLSpanElement>` without `className`, `style` | | Renders a `<span>`. |
|
|
207
|
+
| `...props` (Group, Portal) | Radix `Group` / `Portal` props | | Re-exported Radix parts. |
|
|
208
|
+
|
|
209
|
+
`className` and `style` are omitted from every wrapped part. The re-exported Radix parts (Trigger, Group, Portal, Sub, RadioGroup) still forward them; don't pass them there either.
|
|
210
|
+
<!-- api:end -->
|
|
211
|
+
|
|
212
|
+
## 13. Examples
|
|
213
|
+
|
|
214
|
+
```tsx
|
|
215
|
+
import * as React from "react";
|
|
216
|
+
import {
|
|
217
|
+
ActionPopover,
|
|
218
|
+
ContextMenu,
|
|
219
|
+
ContextMenuCheckboxItem,
|
|
220
|
+
ContextMenuContent,
|
|
221
|
+
ContextMenuItem,
|
|
222
|
+
ContextMenuSeparator,
|
|
223
|
+
ContextMenuShortcut,
|
|
224
|
+
ContextMenuTrigger,
|
|
225
|
+
} from "@eluan/core";
|
|
226
|
+
|
|
227
|
+
export function FileTile({
|
|
228
|
+
name,
|
|
229
|
+
pinned,
|
|
230
|
+
onOpen,
|
|
231
|
+
onRename,
|
|
232
|
+
onTogglePin,
|
|
233
|
+
onTrash,
|
|
234
|
+
}: {
|
|
235
|
+
name: string;
|
|
236
|
+
pinned: boolean;
|
|
237
|
+
onOpen: () => void;
|
|
238
|
+
onRename: () => void;
|
|
239
|
+
onTogglePin: (pinned: boolean) => void;
|
|
240
|
+
onTrash: () => void;
|
|
241
|
+
}) {
|
|
242
|
+
return (
|
|
243
|
+
<ContextMenu>
|
|
244
|
+
<ContextMenuTrigger asChild>
|
|
245
|
+
<div
|
|
246
|
+
style={{
|
|
247
|
+
display: "flex",
|
|
248
|
+
alignItems: "center",
|
|
249
|
+
justifyContent: "space-between",
|
|
250
|
+
gap: "var(--spacing-sm)",
|
|
251
|
+
padding: "var(--spacing-md)",
|
|
252
|
+
borderRadius: "var(--curves-md)",
|
|
253
|
+
backgroundColor: "var(--container-bg-alt)",
|
|
254
|
+
color: "var(--container-fg)",
|
|
255
|
+
fontSize: "var(--font-size-sm)",
|
|
256
|
+
}}
|
|
257
|
+
>
|
|
258
|
+
<span>{name}</span>
|
|
259
|
+
<ActionPopover
|
|
260
|
+
aria-label={`Actions for ${name}`}
|
|
261
|
+
items={[
|
|
262
|
+
{ label: "Open", onClick: onOpen },
|
|
263
|
+
{ label: "Rename…", onClick: onRename },
|
|
264
|
+
{ label: "Move to trash", onClick: onTrash, destructive: true },
|
|
265
|
+
]}
|
|
266
|
+
/>
|
|
267
|
+
</div>
|
|
268
|
+
</ContextMenuTrigger>
|
|
269
|
+
<ContextMenuContent>
|
|
270
|
+
<ContextMenuItem onSelect={onOpen}>
|
|
271
|
+
Open
|
|
272
|
+
<ContextMenuShortcut>⌘O</ContextMenuShortcut>
|
|
273
|
+
</ContextMenuItem>
|
|
274
|
+
<ContextMenuItem onSelect={onRename}>Rename…</ContextMenuItem>
|
|
275
|
+
<ContextMenuSeparator />
|
|
276
|
+
<ContextMenuCheckboxItem checked={pinned} onCheckedChange={onTogglePin}>
|
|
277
|
+
Pin to top
|
|
278
|
+
</ContextMenuCheckboxItem>
|
|
279
|
+
<ContextMenuSeparator />
|
|
280
|
+
<ContextMenuItem onSelect={onTrash}>Move to trash</ContextMenuItem>
|
|
281
|
+
</ContextMenuContent>
|
|
282
|
+
</ContextMenu>
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
## 14. Related components
|
|
288
|
+
|
|
289
|
+
- [DropdownMenu](./dropdown-menu.md): the same actions on a visible trigger, and the chooser for all menus.
|
|
290
|
+
- [ActionPopover](./action-popover.md): a compact visible actions button to pair with a ContextMenu.
|
|
291
|
+
- [Menubar](./menubar.md): app-wide menus in a persistent bar.
|
|
292
|
+
- [Dialog](./dialog.md): confirms destructive actions.
|
|
293
|
+
|
|
294
|
+
## 15. Common agent mistakes
|
|
295
|
+
|
|
296
|
+
_Filled from evals._
|