@eluan/core 0.5.1 → 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/icon.d.ts +26 -0
- package/dist/components/layout-shared.d.ts +307 -0
- 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/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/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-B6NBbDCW.js → multi-select-CVxkWW29.js} +30 -30
- 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/{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/{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/input-otp-DcZ7wyjs.cjs +0 -1
- package/dist/multi-select-kcoUbSwE.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/tree-view-CNvEc1TT.cjs +0 -1
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: DropdownMenu
|
|
3
|
+
use_when: A button opens a short list of actions or view settings, such as a table row's actions menu or an account menu.
|
|
4
|
+
instead_of: Select to pick a form value; ActionPopover for a plain icon-only list of actions; ContextMenu for right-click; Menubar for an app-wide File/Edit bar.
|
|
5
|
+
source: packages/core/src/components/dropdown-menu.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# DropdownMenu
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
DropdownMenu opens a floating list of actions from a trigger. It wraps Radix DropdownMenu: the panel portals out of the page, and it supports plain items (with a destructive tone), checkbox and radio items, labels, separators, shortcut hints and submenus. This file is also the chooser for every "menu of actions" task: start with the table below.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- A table row's actions (Edit, Duplicate, Delete) behind a ghost icon Button labelled for that row.
|
|
17
|
+
- An account or workspace menu in a header: Profile, Billing, Sign out.
|
|
18
|
+
- A split of related secondary actions behind one button: Export as CSV, Export as PDF.
|
|
19
|
+
- View settings that apply at once and stay visible as checked state: show columns, sort order, density.
|
|
20
|
+
|
|
21
|
+
### Choosing a menu
|
|
22
|
+
|
|
23
|
+
Menus run actions. Pickers choose a value. Pick by what happens when the user chooses an option.
|
|
24
|
+
|
|
25
|
+
| You need… | Use |
|
|
26
|
+
| --- | --- |
|
|
27
|
+
| A button that opens actions, with groups, labels, shortcuts, submenus or checkable items | DropdownMenu |
|
|
28
|
+
| An icon-only "…" button with a flat list of actions (label, icon, destructive, disabled) and nothing else | [ActionPopover](./action-popover.md); it renders a DropdownMenu for you |
|
|
29
|
+
| The same actions on right-click or long-press of a surface: a file tile, a canvas, a row | [ContextMenu](./context-menu.md), plus a visible DropdownMenu or ActionPopover with the same actions |
|
|
30
|
+
| A persistent desktop-style bar of menus: File, Edit, View | [Menubar](./menubar.md) |
|
|
31
|
+
| The user picks one value for a form field and the trigger shows the choice | [Select](./select.md) |
|
|
32
|
+
| Searching or filtering a long list of options or commands | [Command](./command.md) |
|
|
33
|
+
| Site navigation with link panels | [NavigationMenu](./navigation-menu.md) |
|
|
34
|
+
| Text, a form or other non-menu content in a floating panel | [Popover](./popover.md) |
|
|
35
|
+
|
|
36
|
+
### When not to use
|
|
37
|
+
|
|
38
|
+
- Choosing a value that a form submits → use [Select](./select.md), or [RadioGroup](./radio-group.md) when there are few options.
|
|
39
|
+
- One or two actions → show them as [Button](./button.md)s; don't hide them in a menu.
|
|
40
|
+
- Right-click actions on a surface → use [ContextMenu](./context-menu.md).
|
|
41
|
+
- File/Edit/View bars in an editor-style app → use [Menubar](./menubar.md).
|
|
42
|
+
- Moving between pages or sections of a site → use [NavigationMenu](./navigation-menu.md) or [NavigationDrawer](./navigation-drawer.md).
|
|
43
|
+
- A setting that should stay visible on the page → use [Switch](./switch.md) or [Checkbox](./checkbox.md).
|
|
44
|
+
|
|
45
|
+
## 3. Anatomy
|
|
46
|
+
|
|
47
|
+
1. **Root** (`DropdownMenu`): holds open state. Renders no element.
|
|
48
|
+
2. **Trigger** (`DropdownMenuTrigger`): the control that opens the menu. Use `asChild` around a [Button](./button.md).
|
|
49
|
+
3. **Content** (`DropdownMenuContent`): the floating panel, portalled to the nearest `PortalContainerProvider` container or `document.body`. `--container-bg` surface, `--container-border` border, `--curves-md` radius, `--spacing-xs` padding, minimum width 8rem, 4px from the trigger.
|
|
50
|
+
4. **Item** (`DropdownMenuItem`): one action row. `--font-size-sm` text, padded `--spacing-xs` by `--spacing-sm`, with a `--spacing-sm` gap between an icon and the label.
|
|
51
|
+
5. **Checkbox item** (`DropdownMenuCheckboxItem`): an item with a checkbox box on the trailing edge, drawn to match [Checkbox](./checkbox.md).
|
|
52
|
+
6. **Radio group and radio item** (`DropdownMenuRadioGroup`, `DropdownMenuRadioItem`): single choice among items, with a radio ring on the trailing edge, drawn to match [RadioGroup](./radio-group.md).
|
|
53
|
+
7. **Label** (`DropdownMenuLabel`): a non-interactive heading for a group, weight 600.
|
|
54
|
+
8. **Separator** (`DropdownMenuSeparator`): a 1px line between groups, running edge to edge.
|
|
55
|
+
9. **Shortcut** (`DropdownMenuShortcut`): trailing hint text at `--font-size-xs` and 60% opacity. Display only; it binds no keys.
|
|
56
|
+
10. **Group** (`DropdownMenuGroup`): wraps related items.
|
|
57
|
+
11. **Submenu** (`DropdownMenuSub`, `DropdownMenuSubTrigger`, `DropdownMenuSubContent`): a nested panel. The sub-trigger adds a trailing chevron; the sub-panel uses a larger shadow than the main panel.
|
|
58
|
+
12. **Portal** (`DropdownMenuPortal`): the Radix portal, re-exported. Content already portals, so you rarely need it.
|
|
59
|
+
|
|
60
|
+
## 4. Variants
|
|
61
|
+
|
|
62
|
+
DropdownMenu has no variant prop. `DropdownMenuItem` takes a `tone`:
|
|
63
|
+
|
|
64
|
+
| Tone | Use for |
|
|
65
|
+
| --- | --- |
|
|
66
|
+
| `default` | Every ordinary action. |
|
|
67
|
+
| `destructive` | An action that deletes, revokes or can't be undone: Delete invoice, Remove member. Text uses `--destructive-fg`. |
|
|
68
|
+
|
|
69
|
+
## 5. Sizes
|
|
70
|
+
|
|
71
|
+
DropdownMenu has no size prop. Item text is `--font-size-sm` and padding comes from `--spacing-*`, so the menu follows the density axis.
|
|
72
|
+
|
|
73
|
+
## 6. States
|
|
74
|
+
|
|
75
|
+
| State | Looks like | Notes |
|
|
76
|
+
| --- | --- | --- |
|
|
77
|
+
| Default | Items inherit `--container-fg` on `--container-bg` | |
|
|
78
|
+
| 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. Checkbox and radio items also fill on `:hover`. |
|
|
79
|
+
| Focus | Trigger: the Button's outline. Inside the menu: the highlighted row, no outline | Never remove or restyle the focus ring. |
|
|
80
|
+
| Open | A sub-trigger with its submenu open keeps the `--interactive-bg-hover` fill | The trigger Button has no open styling of its own. |
|
|
81
|
+
| Checked | Checkbox item: filled `--interactive-bg-selected` box with a tick. Radio item: filled ring with a centre dot | Only `checked={true}` draws the tick. `checked="indeterminate"` renders an empty box, so don't use it. |
|
|
82
|
+
| Disabled | `--interactive-bg-disabled` fill, `--interactive-fg-disabled` text, no pointer events | Arrow keys skip disabled items. |
|
|
83
|
+
| Destructive | `--destructive-fg` text, kept while highlighted | |
|
|
84
|
+
|
|
85
|
+
Separators currently use `--container-bg-alt`, which is barely visible on the panel in `minimal`. Don't draw your own line; keep using `DropdownMenuSeparator`.
|
|
86
|
+
|
|
87
|
+
## 7. Content guidelines
|
|
88
|
+
|
|
89
|
+
- Start action labels with a verb and name the object when it isn't obvious: "Duplicate", "Export as CSV", "Delete invoice".
|
|
90
|
+
- Use sentence case. Keep labels to one to four words; long labels wrap.
|
|
91
|
+
- End a label with an ellipsis (…) only when the item opens a dialog that asks for more input: "Rename…", "Move to…".
|
|
92
|
+
- Put the destructive item last, after a separator.
|
|
93
|
+
- Group related items under a `DropdownMenuLabel` when the menu has more than one kind of action.
|
|
94
|
+
- Show a shortcut only if that shortcut works elsewhere in the app. Use platform glyphs: "⌘D", "⇧⌘P".
|
|
95
|
+
- Name icon-only triggers after the object they act on: "Actions for invoice INV-1042".
|
|
96
|
+
|
|
97
|
+
| Do | Don't |
|
|
98
|
+
| --- | --- |
|
|
99
|
+
| Duplicate | Make a copy of this item |
|
|
100
|
+
| Export as CSV | CSV |
|
|
101
|
+
| Rename… | Rename this… |
|
|
102
|
+
| Delete invoice | Delete!!! |
|
|
103
|
+
|
|
104
|
+
## 8. Rules
|
|
105
|
+
|
|
106
|
+
1. Wrap the trigger with `asChild`: `<DropdownMenuTrigger asChild><Button …/></DropdownMenuTrigger>`. Without it you nest a button inside a button.
|
|
107
|
+
2. Give an icon-only trigger an `aria-label` that names the object, and mark the icon `aria-hidden="true"`.
|
|
108
|
+
3. Run actions in `onSelect`. Call `event.preventDefault()` in `onSelect` to keep the menu open, as the stories do for checkbox and radio items.
|
|
109
|
+
4. Use `tone="destructive"` only for actions that destroy or revoke. Place it last, after a separator, and confirm it in a [Dialog](./dialog.md).
|
|
110
|
+
5. To open a Dialog from an item, control the Dialog's `open` state and set it in the item's `onSelect`. Don't nest the Dialog inside the menu.
|
|
111
|
+
6. Navigate from an item with `asChild` around a link: `<DropdownMenuItem asChild><a href="/settings">Settings</a></DropdownMenuItem>`. Never set `window.location` in a handler.
|
|
112
|
+
7. Put only menu items in the content: items, checkbox and radio items, labels, separators, groups and submenus. Forms and rich content go in a [Popover](./popover.md).
|
|
113
|
+
8. Never pass `className` or `style` to any part. Pass `container` on `DropdownMenuContent` when a scoped theme must reach the panel (see [theming](../foundations/theming.md)).
|
|
114
|
+
|
|
115
|
+
## 9. Dos and don'ts
|
|
116
|
+
|
|
117
|
+
**Do:** label a row's icon trigger with the row it acts on.
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
<DropdownMenu>
|
|
121
|
+
<DropdownMenuTrigger asChild>
|
|
122
|
+
<Button type="button" variant="ghost" size="iconSm" aria-label="Actions for invoice INV-1042">
|
|
123
|
+
<MoreHorizontal aria-hidden="true" style={{ width: "var(--size-xxs)", height: "var(--size-xxs)" }} />
|
|
124
|
+
</Button>
|
|
125
|
+
</DropdownMenuTrigger>
|
|
126
|
+
<DropdownMenuContent align="end">
|
|
127
|
+
<DropdownMenuItem onSelect={onEdit}>Edit</DropdownMenuItem>
|
|
128
|
+
<DropdownMenuItem onSelect={onDuplicate}>Duplicate</DropdownMenuItem>
|
|
129
|
+
</DropdownMenuContent>
|
|
130
|
+
</DropdownMenu>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Don't:** nest a Button without `asChild`, or leave the icon trigger unnamed.
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
<DropdownMenu>
|
|
137
|
+
<DropdownMenuTrigger>
|
|
138
|
+
<Button size="iconSm"><MoreHorizontal /></Button>
|
|
139
|
+
</DropdownMenuTrigger>
|
|
140
|
+
<DropdownMenuContent>
|
|
141
|
+
<DropdownMenuItem onClick={onEdit}>Edit</DropdownMenuItem>
|
|
142
|
+
</DropdownMenuContent>
|
|
143
|
+
</DropdownMenu>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Do:** use Select when the user is choosing a value for a form.
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
<Select name="currency" defaultValue="eur">
|
|
150
|
+
<SelectTrigger aria-label="Currency">
|
|
151
|
+
<SelectValue />
|
|
152
|
+
</SelectTrigger>
|
|
153
|
+
<SelectContent>
|
|
154
|
+
<SelectItem value="eur">Euro</SelectItem>
|
|
155
|
+
<SelectItem value="usd">US dollar</SelectItem>
|
|
156
|
+
</SelectContent>
|
|
157
|
+
</Select>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Don't:** build a form field out of a menu's radio items.
|
|
161
|
+
|
|
162
|
+
```tsx
|
|
163
|
+
<DropdownMenu>
|
|
164
|
+
<DropdownMenuTrigger asChild>
|
|
165
|
+
<Button variant="input">{currency}</Button>
|
|
166
|
+
</DropdownMenuTrigger>
|
|
167
|
+
<DropdownMenuContent>
|
|
168
|
+
<DropdownMenuRadioGroup value={currency} onValueChange={setCurrency}>
|
|
169
|
+
<DropdownMenuRadioItem value="eur">Euro</DropdownMenuRadioItem>
|
|
170
|
+
<DropdownMenuRadioItem value="usd">US dollar</DropdownMenuRadioItem>
|
|
171
|
+
</DropdownMenuRadioGroup>
|
|
172
|
+
</DropdownMenuContent>
|
|
173
|
+
</DropdownMenu>
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Do:** separate the destructive action and give it the tone.
|
|
177
|
+
|
|
178
|
+
```tsx
|
|
179
|
+
<DropdownMenuContent>
|
|
180
|
+
<DropdownMenuItem onSelect={onArchive}>Archive</DropdownMenuItem>
|
|
181
|
+
<DropdownMenuSeparator />
|
|
182
|
+
<DropdownMenuItem tone="destructive" onSelect={() => setConfirmOpen(true)}>
|
|
183
|
+
Delete project
|
|
184
|
+
</DropdownMenuItem>
|
|
185
|
+
</DropdownMenuContent>
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Don't:** bury it mid-list or colour it by hand.
|
|
189
|
+
|
|
190
|
+
```tsx
|
|
191
|
+
<DropdownMenuContent>
|
|
192
|
+
<DropdownMenuItem onSelect={deleteProject}>
|
|
193
|
+
<span style={{ color: "red" }}>Delete project</span>
|
|
194
|
+
</DropdownMenuItem>
|
|
195
|
+
<DropdownMenuItem onSelect={onArchive}>Archive</DropdownMenuItem>
|
|
196
|
+
</DropdownMenuContent>
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## 10. Accessibility
|
|
200
|
+
|
|
201
|
+
- Role: the trigger gets `aria-haspopup="menu"` and `aria-expanded`; the content is `menu`; items are `menuitem`, `menuitemcheckbox` or `menuitemradio`.
|
|
202
|
+
- Label: the trigger's text, or `aria-label` for icon-only triggers. Items are named by their text; mark item icons `aria-hidden="true"`.
|
|
203
|
+
- Keyboard: Enter, Space or ArrowDown on the trigger opens the menu. ArrowUp and ArrowDown move between items, Home and End jump to the ends, and typing a letter jumps to a matching item. Enter or Space selects. ArrowRight opens a submenu and ArrowLeft closes it. Escape closes the menu.
|
|
204
|
+
- Focus: opening moves focus into the menu; closing returns it to the trigger. The menu is modal by default (`modal`), so outside pointer interaction is blocked while it is open.
|
|
205
|
+
- Shortcut hints are text only. Register the key binding yourself, or leave the hint out.
|
|
206
|
+
- Contrast: handled by the theme. Don't override colours.
|
|
207
|
+
|
|
208
|
+
## 11. Behaviour
|
|
209
|
+
|
|
210
|
+
- Positioning: the panel opens below the trigger, centred (`side="bottom"`, `align="center"`, `sideOffset` 4), and flips to stay on screen. Use `align="end"` for triggers at the right edge of a row or header.
|
|
211
|
+
- Responsive: no breakpoint behaviour. The panel is at least 8rem wide and grows with its widest item.
|
|
212
|
+
- Overflow and truncation: the panel has no maximum height or scroll. Keep menus short; move long lists to [Command](./command.md).
|
|
213
|
+
- Closing: selecting an item closes the menu unless `onSelect` calls `event.preventDefault()`.
|
|
214
|
+
- Motion: item background and colour transition over 150ms. There is no open or close animation. Don't add one.
|
|
215
|
+
|
|
216
|
+
## 12. API
|
|
217
|
+
|
|
218
|
+
<!-- api:start -->
|
|
219
|
+
### DropdownMenu
|
|
220
|
+
|
|
221
|
+
| Prop | Type | Default | Description |
|
|
222
|
+
| --- | --- | --- | --- |
|
|
223
|
+
| `open` | `boolean` | | Controlled open state. |
|
|
224
|
+
| `defaultOpen` | `boolean` | `false` | Initial open state when uncontrolled. |
|
|
225
|
+
| `onOpenChange` | `(open: boolean) => void` | | Called when the menu opens or closes. |
|
|
226
|
+
| `modal` | `boolean` | `true` | Blocks outside interaction while open. |
|
|
227
|
+
| `...props` | Radix `DropdownMenu.Root` props | | `dir`. |
|
|
228
|
+
|
|
229
|
+
### DropdownMenuTrigger
|
|
230
|
+
|
|
231
|
+
| Prop | Type | Default | Description |
|
|
232
|
+
| --- | --- | --- | --- |
|
|
233
|
+
| `asChild` | `boolean` | `false` | Renders your child (a Button) as the trigger. |
|
|
234
|
+
| `disabled` | `boolean` | `false` | Prevents opening. |
|
|
235
|
+
| `...props` | Radix `DropdownMenu.Trigger` props | | Re-exported Radix part. |
|
|
236
|
+
|
|
237
|
+
### DropdownMenuContent
|
|
238
|
+
|
|
239
|
+
| Prop | Type | Default | Description |
|
|
240
|
+
| --- | --- | --- | --- |
|
|
241
|
+
| `container` | `HTMLElement \| null` | provider container, then `document.body` | Element to portal into. |
|
|
242
|
+
| `side` | `"top" \| "right" \| "bottom" \| "left"` | `"bottom"` | Preferred side of the trigger. |
|
|
243
|
+
| `align` | `"start" \| "center" \| "end"` | `"center"` | Alignment against the trigger. |
|
|
244
|
+
| `sideOffset` | `number` | `4` | Distance from the trigger in px. |
|
|
245
|
+
| `loop` | `boolean` | `false` | Wraps arrow-key focus from last to first item. |
|
|
246
|
+
| `onCloseAutoFocus` | `(event: Event) => void` | | Call `event.preventDefault()` to stop focus returning to the trigger. |
|
|
247
|
+
| `...props` | Radix `DropdownMenu.Content` props without `className`, `style` | | `alignOffset`, `collisionPadding`, `onEscapeKeyDown`. |
|
|
248
|
+
|
|
249
|
+
### DropdownMenuItem
|
|
250
|
+
|
|
251
|
+
| Prop | Type | Default | Description |
|
|
252
|
+
| --- | --- | --- | --- |
|
|
253
|
+
| `tone` | `"default" \| "destructive"` | `"default"` | Destructive colours the text with `--destructive-fg`. |
|
|
254
|
+
| `inset` | `boolean` | `false` | Adds left padding to line up with items that have an icon. |
|
|
255
|
+
| `onSelect` | `(event: Event) => void` | | Runs the action; `event.preventDefault()` keeps the menu open. |
|
|
256
|
+
| `disabled` | `boolean` | `false` | Skipped by the keyboard, not clickable. |
|
|
257
|
+
| `asChild` | `boolean` | `false` | Renders your child (for example a link) as the item. |
|
|
258
|
+
| `...props` | Radix `DropdownMenu.Item` props without `className`, `style` | | `textValue` for typeahead when the label isn't plain text. |
|
|
259
|
+
|
|
260
|
+
### DropdownMenuCheckboxItem
|
|
261
|
+
|
|
262
|
+
| Prop | Type | Default | Description |
|
|
263
|
+
| --- | --- | --- | --- |
|
|
264
|
+
| `checked` | `boolean \| "indeterminate"` | | Checked state. Only `true` draws the tick. |
|
|
265
|
+
| `onCheckedChange` | `(checked: boolean) => void` | | Called when toggled. |
|
|
266
|
+
| `...props` | Radix `DropdownMenu.CheckboxItem` props without `className`, `style` | | `disabled`, `onSelect`. |
|
|
267
|
+
|
|
268
|
+
### DropdownMenuRadioGroup and DropdownMenuRadioItem
|
|
269
|
+
|
|
270
|
+
| Prop | Type | Default | Description |
|
|
271
|
+
| --- | --- | --- | --- |
|
|
272
|
+
| `value` (group) | `string` | | Selected value. |
|
|
273
|
+
| `onValueChange` (group) | `(value: string) => void` | | Called when a radio item is chosen. |
|
|
274
|
+
| `value` (item) | `string` | | Required. The item's value. |
|
|
275
|
+
| `...props` | Radix `DropdownMenu.RadioGroup` / `RadioItem` props without `className`, `style` | | `disabled`, `onSelect` on items. |
|
|
276
|
+
|
|
277
|
+
### DropdownMenuLabel, DropdownMenuSubTrigger
|
|
278
|
+
|
|
279
|
+
| Prop | Type | Default | Description |
|
|
280
|
+
| --- | --- | --- | --- |
|
|
281
|
+
| `inset` | `boolean` | `false` | Adds left padding to line up with items that have an icon. |
|
|
282
|
+
| `...props` | Radix `Label` / `SubTrigger` props without `className`, `style` | | `disabled` on the sub-trigger. |
|
|
283
|
+
|
|
284
|
+
### DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuGroup, DropdownMenuPortal
|
|
285
|
+
|
|
286
|
+
| Prop | Type | Default | Description |
|
|
287
|
+
| --- | --- | --- | --- |
|
|
288
|
+
| `open`, `defaultOpen`, `onOpenChange` (Sub) | as on the root | | Submenu open state. |
|
|
289
|
+
| `...props` (SubContent, Separator) | Radix props without `className`, `style` | | `sideOffset`, `loop` on SubContent. |
|
|
290
|
+
| `...props` (Shortcut) | `HTMLAttributes<HTMLSpanElement>` without `className`, `style` | | Renders a `<span>`. |
|
|
291
|
+
| `...props` (Group, Portal) | Radix `Group` / `Portal` props | | Re-exported Radix parts. |
|
|
292
|
+
|
|
293
|
+
`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.
|
|
294
|
+
<!-- api:end -->
|
|
295
|
+
|
|
296
|
+
## 13. Examples
|
|
297
|
+
|
|
298
|
+
A table row actions menu with a confirmed delete:
|
|
299
|
+
|
|
300
|
+
```tsx
|
|
301
|
+
import * as React from "react";
|
|
302
|
+
import {
|
|
303
|
+
Button,
|
|
304
|
+
Dialog,
|
|
305
|
+
DialogContent,
|
|
306
|
+
DialogDescription,
|
|
307
|
+
DialogFooter,
|
|
308
|
+
DialogHeader,
|
|
309
|
+
DialogTitle,
|
|
310
|
+
DropdownMenu,
|
|
311
|
+
DropdownMenuContent,
|
|
312
|
+
DropdownMenuItem,
|
|
313
|
+
DropdownMenuSeparator,
|
|
314
|
+
DropdownMenuShortcut,
|
|
315
|
+
DropdownMenuTrigger,
|
|
316
|
+
TableCell,
|
|
317
|
+
TableRow,
|
|
318
|
+
} from "@eluan/core";
|
|
319
|
+
import { Copy, Download, MoreHorizontal, Pencil, Trash2 } from "lucide-react";
|
|
320
|
+
|
|
321
|
+
const iconStyle = { width: "var(--size-xxs)", height: "var(--size-xxs)" };
|
|
322
|
+
|
|
323
|
+
export function InvoiceRow({
|
|
324
|
+
invoice,
|
|
325
|
+
onDuplicate,
|
|
326
|
+
onDownload,
|
|
327
|
+
onDelete,
|
|
328
|
+
}: {
|
|
329
|
+
invoice: { id: string; customer: string; total: string };
|
|
330
|
+
onDuplicate: () => void;
|
|
331
|
+
onDownload: () => void;
|
|
332
|
+
onDelete: () => void;
|
|
333
|
+
}) {
|
|
334
|
+
const [confirmOpen, setConfirmOpen] = React.useState(false);
|
|
335
|
+
|
|
336
|
+
return (
|
|
337
|
+
<TableRow>
|
|
338
|
+
<TableCell weight="medium">{invoice.id}</TableCell>
|
|
339
|
+
<TableCell>{invoice.customer}</TableCell>
|
|
340
|
+
<TableCell>{invoice.total}</TableCell>
|
|
341
|
+
<TableCell>
|
|
342
|
+
<DropdownMenu>
|
|
343
|
+
<DropdownMenuTrigger asChild>
|
|
344
|
+
<Button type="button" variant="ghost" size="iconSm" aria-label={`Actions for invoice ${invoice.id}`}>
|
|
345
|
+
<MoreHorizontal aria-hidden="true" style={iconStyle} />
|
|
346
|
+
</Button>
|
|
347
|
+
</DropdownMenuTrigger>
|
|
348
|
+
<DropdownMenuContent align="end">
|
|
349
|
+
<DropdownMenuItem asChild>
|
|
350
|
+
<a href={`/invoices/${invoice.id}/edit`}>
|
|
351
|
+
<Pencil aria-hidden="true" style={iconStyle} />
|
|
352
|
+
Edit
|
|
353
|
+
</a>
|
|
354
|
+
</DropdownMenuItem>
|
|
355
|
+
<DropdownMenuItem onSelect={onDuplicate}>
|
|
356
|
+
<Copy aria-hidden="true" style={iconStyle} />
|
|
357
|
+
Duplicate
|
|
358
|
+
<DropdownMenuShortcut>⌘D</DropdownMenuShortcut>
|
|
359
|
+
</DropdownMenuItem>
|
|
360
|
+
<DropdownMenuItem onSelect={onDownload}>
|
|
361
|
+
<Download aria-hidden="true" style={iconStyle} />
|
|
362
|
+
Download PDF
|
|
363
|
+
</DropdownMenuItem>
|
|
364
|
+
<DropdownMenuSeparator />
|
|
365
|
+
<DropdownMenuItem tone="destructive" onSelect={() => setConfirmOpen(true)}>
|
|
366
|
+
<Trash2 aria-hidden="true" style={iconStyle} />
|
|
367
|
+
Delete invoice
|
|
368
|
+
</DropdownMenuItem>
|
|
369
|
+
</DropdownMenuContent>
|
|
370
|
+
</DropdownMenu>
|
|
371
|
+
|
|
372
|
+
<Dialog open={confirmOpen} onOpenChange={setConfirmOpen}>
|
|
373
|
+
<DialogContent>
|
|
374
|
+
<DialogHeader>
|
|
375
|
+
<DialogTitle>Delete invoice {invoice.id}?</DialogTitle>
|
|
376
|
+
<DialogDescription>The invoice and its payment history are removed. This can't be undone.</DialogDescription>
|
|
377
|
+
</DialogHeader>
|
|
378
|
+
<DialogFooter>
|
|
379
|
+
<Button type="button" variant="outline" onClick={() => setConfirmOpen(false)}>
|
|
380
|
+
Cancel
|
|
381
|
+
</Button>
|
|
382
|
+
<Button type="button" variant="destructive" onClick={onDelete}>
|
|
383
|
+
Delete invoice
|
|
384
|
+
</Button>
|
|
385
|
+
</DialogFooter>
|
|
386
|
+
</DialogContent>
|
|
387
|
+
</Dialog>
|
|
388
|
+
</TableCell>
|
|
389
|
+
</TableRow>
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
View settings that stay open while toggled:
|
|
395
|
+
|
|
396
|
+
```tsx
|
|
397
|
+
import * as React from "react";
|
|
398
|
+
import {
|
|
399
|
+
Button,
|
|
400
|
+
DropdownMenu,
|
|
401
|
+
DropdownMenuCheckboxItem,
|
|
402
|
+
DropdownMenuContent,
|
|
403
|
+
DropdownMenuLabel,
|
|
404
|
+
DropdownMenuRadioGroup,
|
|
405
|
+
DropdownMenuRadioItem,
|
|
406
|
+
DropdownMenuSeparator,
|
|
407
|
+
DropdownMenuTrigger,
|
|
408
|
+
} from "@eluan/core";
|
|
409
|
+
|
|
410
|
+
export function ViewOptions() {
|
|
411
|
+
const [showArchived, setShowArchived] = React.useState(false);
|
|
412
|
+
const [sort, setSort] = React.useState("due");
|
|
413
|
+
const keepOpen = (event: Event) => event.preventDefault();
|
|
414
|
+
|
|
415
|
+
return (
|
|
416
|
+
<DropdownMenu>
|
|
417
|
+
<DropdownMenuTrigger asChild>
|
|
418
|
+
<Button type="button" variant="outline" size="sm">View</Button>
|
|
419
|
+
</DropdownMenuTrigger>
|
|
420
|
+
<DropdownMenuContent align="end">
|
|
421
|
+
<DropdownMenuLabel>Show</DropdownMenuLabel>
|
|
422
|
+
<DropdownMenuCheckboxItem checked={showArchived} onCheckedChange={setShowArchived} onSelect={keepOpen}>
|
|
423
|
+
Archived invoices
|
|
424
|
+
</DropdownMenuCheckboxItem>
|
|
425
|
+
<DropdownMenuSeparator />
|
|
426
|
+
<DropdownMenuLabel>Sort by</DropdownMenuLabel>
|
|
427
|
+
<DropdownMenuRadioGroup value={sort} onValueChange={setSort}>
|
|
428
|
+
<DropdownMenuRadioItem value="due" onSelect={keepOpen}>Due date</DropdownMenuRadioItem>
|
|
429
|
+
<DropdownMenuRadioItem value="amount" onSelect={keepOpen}>Amount</DropdownMenuRadioItem>
|
|
430
|
+
<DropdownMenuRadioItem value="customer" onSelect={keepOpen}>Customer</DropdownMenuRadioItem>
|
|
431
|
+
</DropdownMenuRadioGroup>
|
|
432
|
+
</DropdownMenuContent>
|
|
433
|
+
</DropdownMenu>
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
## 14. Related components
|
|
439
|
+
|
|
440
|
+
- [ActionPopover](./action-popover.md): a ready-made icon trigger and flat action list built on DropdownMenu.
|
|
441
|
+
- [ContextMenu](./context-menu.md): the same kind of menu, opened by right-click or long-press.
|
|
442
|
+
- [Menubar](./menubar.md): several menus in a persistent bar.
|
|
443
|
+
- [Select](./select.md): picks a value for a form instead of running an action.
|
|
444
|
+
- [Command](./command.md): a searchable list for many options or commands.
|
|
445
|
+
- [Button](./button.md): the trigger.
|
|
446
|
+
- [Dialog](./dialog.md): confirms the destructive item.
|
|
447
|
+
|
|
448
|
+
## 15. Common agent mistakes
|
|
449
|
+
|
|
450
|
+
_Filled from evals._
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: EmailInput
|
|
3
|
+
use_when: The user types an email address, with optional inline format feedback once they leave the field.
|
|
4
|
+
instead_of: Input for any other single-line text; PasswordInput, PhoneInput or SearchInput for those field types.
|
|
5
|
+
source: packages/core/src/components/email-input.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# EmailInput
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
EmailInput is an [Input](./input.md) with `type="email"`, so it shows Input's mail icon and the email keyboard on mobile. With `showValidation` it checks the value against a basic `name@domain.tld` pattern and, after the user first leaves the field, shows a check or alert icon and tints the border.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- Any field that collects an email address: sign-up, sign-in, invites, contact and checkout forms.
|
|
17
|
+
- When you want format feedback before submit (`showValidation`), or a validity flag for your own logic (`onValidationChange`).
|
|
18
|
+
|
|
19
|
+
### When not to use
|
|
20
|
+
|
|
21
|
+
- Any other single-line text → use [Input](./input.md).
|
|
22
|
+
- A password → use [PasswordInput](./password-input.md). A phone number → use [PhoneInput](./phone-input.md). A search query → use [SearchInput](./search-input.md).
|
|
23
|
+
- Several addresses in one field → use [Textarea](./textarea.md) and split them yourself, or [MultiSelect](./multi-select.md) to pick existing people.
|
|
24
|
+
|
|
25
|
+
EmailInput earns its place through `showValidation`. Without it, it renders the same field as `<Input type="email">`. The check is a format pattern only: it doesn't look up domains or catch typos like `gmial.com`.
|
|
26
|
+
|
|
27
|
+
## 3. Anatomy
|
|
28
|
+
|
|
29
|
+
1. **Field**: Input's surface around a native `<input type="email">`.
|
|
30
|
+
2. **Leading icon**: Input's mail icon, added automatically for `type="email"`.
|
|
31
|
+
3. **Status icon** (with `showValidation`): a check in `--positive-fg` or an alert in `--destructive-fg` at the trailing edge. It appears after the first blur, and only while the field has a value.
|
|
32
|
+
|
|
33
|
+
## 4. Variants
|
|
34
|
+
|
|
35
|
+
No variant prop. `showValidation` turns on the status icon and the positive or destructive border; without it the field looks like a plain Input.
|
|
36
|
+
|
|
37
|
+
## 5. Sizes
|
|
38
|
+
|
|
39
|
+
No size prop. The field is `--size-lg` tall, from Input, and follows density.
|
|
40
|
+
|
|
41
|
+
## 6. States
|
|
42
|
+
|
|
43
|
+
| State | Looks like | Notes |
|
|
44
|
+
| --- | --- | --- |
|
|
45
|
+
| Default | `--interactive-bg` surface, `--interactive-border-alt` border, icon and placeholder in `--interactive-fg-alt` | |
|
|
46
|
+
| Focus | Border and 1px outline in `--focus-ring`, 1px offset | Never remove or restyle the focus ring. |
|
|
47
|
+
| Disabled | `--interactive-bg-disabled` surface, `--interactive-fg-disabled` text, not-allowed cursor | |
|
|
48
|
+
| Valid (`showValidation`) | `--positive-fg` border, check icon | After the first blur; updates live as the user keeps typing. |
|
|
49
|
+
| Invalid (`showValidation`) | `--destructive-fg` border, alert icon | Same timing. Visual only: the icon is `aria-hidden` and EmailInput doesn't set `aria-invalid`. |
|
|
50
|
+
| Error (`aria-invalid`) | `--destructive-border` border and focus outline | Set it yourself when validation fails, with a FormMessage. |
|
|
51
|
+
|
|
52
|
+
## 7. Content guidelines
|
|
53
|
+
|
|
54
|
+
- Label the field "Email" or "Work email". Don't use the placeholder as the label.
|
|
55
|
+
- If you use a placeholder, make it an example address: "you@company.com".
|
|
56
|
+
- Write errors that say how to fix the value: "Enter an email like name@company.com".
|
|
57
|
+
|
|
58
|
+
| Do | Don't |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| Email | Enter your email address here |
|
|
61
|
+
| you@company.com (placeholder) | Email (placeholder instead of a label) |
|
|
62
|
+
| Enter an email like name@company.com | Invalid input |
|
|
63
|
+
|
|
64
|
+
## 8. Rules
|
|
65
|
+
|
|
66
|
+
1. Give the field a visible [Label](./form-label.md) tied with `htmlFor` and `id`.
|
|
67
|
+
2. Set `name` and `autoComplete="email"`.
|
|
68
|
+
3. Treat `showValidation` as a hint. Validate on submit as well; the pattern accepts many addresses that can't receive mail.
|
|
69
|
+
4. When the address is invalid, set `aria-invalid` and show a FormMessage linked with `aria-describedby`. The status icon isn't announced.
|
|
70
|
+
5. Read the value from `onChange`. Use `onValidationChange` only for validity; it fires on every change and reports `false` for an empty field.
|
|
71
|
+
6. Don't pass `icon`, `trailing` or `validationTone`. They aren't EmailInput props; `showValidation` owns the trailing slot and the border tone.
|
|
72
|
+
7. Never pass `className` or `style`; they're dropped. Put width on a wrapper.
|
|
73
|
+
|
|
74
|
+
## 9. Dos and don'ts
|
|
75
|
+
|
|
76
|
+
**Do:** label the field, keep the hint, and announce the error.
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-sm)" }}>
|
|
80
|
+
<Label htmlFor="invite-email" required>Email</Label>
|
|
81
|
+
<EmailInput
|
|
82
|
+
id="invite-email"
|
|
83
|
+
name="email"
|
|
84
|
+
autoComplete="email"
|
|
85
|
+
showValidation
|
|
86
|
+
onValidationChange={setIsValid}
|
|
87
|
+
aria-invalid={showError}
|
|
88
|
+
aria-describedby={showError ? "invite-email-error" : undefined}
|
|
89
|
+
/>
|
|
90
|
+
{showError && <FormMessage id="invite-email-error">Enter an email like name@company.com</FormMessage>}
|
|
91
|
+
</div>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Don't:** use the placeholder as the label or add a second icon.
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
<EmailInput placeholder="Email" icon={<Mail />} />
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Do:** let EmailInput draw its own status.
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
<EmailInput id="billing-email" name="billingEmail" showValidation />
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Don't:** recolour the border or add your own check icon.
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
<div style={{ border: "1px solid green" }}>
|
|
110
|
+
<EmailInput id="billing-email" />
|
|
111
|
+
<CheckCircle2 />
|
|
112
|
+
</div>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## 10. Accessibility
|
|
116
|
+
|
|
117
|
+
- Role: `textbox` (native `<input type="email">`).
|
|
118
|
+
- Label: a Label tied by `htmlFor`/`id`; `aria-label` only where a visible label would be redundant.
|
|
119
|
+
- Keyboard: standard text input. Tab moves focus in and out.
|
|
120
|
+
- Focus: native focus; visible outline on `:focus-visible`.
|
|
121
|
+
- Validation: the status icons are `aria-hidden`, and EmailInput sets no `aria-invalid` and has no live region, so assistive tech isn't told about format errors. Set `aria-invalid` and link a FormMessage yourself.
|
|
122
|
+
- Contrast: handled by the theme. Don't override colours.
|
|
123
|
+
|
|
124
|
+
## 11. Behaviour
|
|
125
|
+
|
|
126
|
+
- Responsive: fills its container's width. Constrain it with a wrapper.
|
|
127
|
+
- Validation timing: the pattern runs on every change. The icon and border appear only after the field has been blurred once and has a value; from then on they update as the user types.
|
|
128
|
+
- A `value` or `defaultValue` set in code isn't checked until the user edits the field.
|
|
129
|
+
- Motion: border and colour transitions over 150ms, from Input. Don't add your own.
|
|
130
|
+
|
|
131
|
+
## 12. API
|
|
132
|
+
|
|
133
|
+
<!-- api:start -->
|
|
134
|
+
| Prop | Type | Default | Description |
|
|
135
|
+
| --- | --- | --- | --- |
|
|
136
|
+
| `showValidation` | `boolean` | `false` | Shows the check or alert icon and tints the border after the first blur. |
|
|
137
|
+
| `onValidationChange` | `(isValid: boolean) => void` | | Fires on every change with the pattern result; `false` when the field is empty. |
|
|
138
|
+
| `onChange` | `ChangeEventHandler<HTMLInputElement>` | | Native change event; read the value here. |
|
|
139
|
+
| `onBlur` | `FocusEventHandler<HTMLInputElement>` | | Native blur event; EmailInput also marks the field as touched. |
|
|
140
|
+
| `...props` | `InputHTMLAttributes` without `className`, `style`, `size`, `type` | | Native input attributes: `id`, `name`, `value`, `placeholder`, `autoComplete`, `required`, `disabled`, `aria-*`. `ref` reaches the `<input>`. |
|
|
141
|
+
<!-- api:end -->
|
|
142
|
+
|
|
143
|
+
Input's own props (`icon`, `trailing`, `validationTone`, `size`, `attachment`, `textStyle`) aren't part of EmailInput's props.
|
|
144
|
+
|
|
145
|
+
## 13. Examples
|
|
146
|
+
|
|
147
|
+
```tsx
|
|
148
|
+
import { useState, type FormEvent } from "react";
|
|
149
|
+
import { Button, EmailInput, Label, FormMessage } from "@eluan/core";
|
|
150
|
+
|
|
151
|
+
export function InviteTeammateForm({ onInvite }: { onInvite: (email: string) => void }) {
|
|
152
|
+
const [email, setEmail] = useState("");
|
|
153
|
+
const [isValid, setIsValid] = useState(false);
|
|
154
|
+
const [submitted, setSubmitted] = useState(false);
|
|
155
|
+
const showError = submitted && !isValid;
|
|
156
|
+
|
|
157
|
+
function handleSubmit(event: FormEvent<HTMLFormElement>) {
|
|
158
|
+
event.preventDefault();
|
|
159
|
+
setSubmitted(true);
|
|
160
|
+
if (isValid) onInvite(email);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return (
|
|
164
|
+
<form onSubmit={handleSubmit} noValidate style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-lg)" }}>
|
|
165
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-sm)" }}>
|
|
166
|
+
<Label htmlFor="invite-email" required>Work email</Label>
|
|
167
|
+
<EmailInput
|
|
168
|
+
id="invite-email"
|
|
169
|
+
name="email"
|
|
170
|
+
autoComplete="email"
|
|
171
|
+
placeholder="name@company.com"
|
|
172
|
+
value={email}
|
|
173
|
+
onChange={(event) => setEmail(event.target.value)}
|
|
174
|
+
showValidation
|
|
175
|
+
onValidationChange={setIsValid}
|
|
176
|
+
aria-invalid={showError}
|
|
177
|
+
aria-describedby={showError ? "invite-email-error" : undefined}
|
|
178
|
+
/>
|
|
179
|
+
{showError && (
|
|
180
|
+
<FormMessage id="invite-email-error">Enter an email like name@company.com</FormMessage>
|
|
181
|
+
)}
|
|
182
|
+
</div>
|
|
183
|
+
<div style={{ display: "flex", justifyContent: "flex-end" }}>
|
|
184
|
+
<Button type="submit">Send invite</Button>
|
|
185
|
+
</div>
|
|
186
|
+
</form>
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## 14. Related components
|
|
192
|
+
|
|
193
|
+
- [Input](./input.md): the base field EmailInput wraps.
|
|
194
|
+
- [Label](./form-label.md): the label, and FormMessage for the error.
|
|
195
|
+
- [PasswordInput](./password-input.md): the usual partner on sign-in and sign-up forms.
|
|
196
|
+
- [Forms pattern](../patterns/forms.md): field structure, validation timing and error placement.
|
|
197
|
+
|
|
198
|
+
## 15. Common agent mistakes
|
|
199
|
+
|
|
200
|
+
_Filled from evals._
|