@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,247 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Banner
|
|
3
|
+
use_when: A message must stay visible until it's resolved: a form-level error, an account or page notice, or a blocking problem.
|
|
4
|
+
instead_of: Toast for transient confirmation; FormMessage for a single field; Badge for an item's status; Dialog when the user must decide.
|
|
5
|
+
source: packages/core/src/components/banner.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Banner
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
Banner is a full-width message strip. It renders a `<div>` holding an optional leading icon, the message, an optional trailing action and an optional dismiss button. It comes in six variants and sits inline (the default) or fixed to the top or bottom of the viewport. Eluan has no Alert component; an inline Banner fills that role.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- A form submit failed or the server rejected it: `variant="destructive"`, `position="inline"`, `role="alert"`, at the top of the form.
|
|
17
|
+
- An account or page notice that stays relevant: "Your trial ends in 3 days." Use `position="top"` with `role="status"`.
|
|
18
|
+
- A blocking problem with a fix: "Payment failed" with an Update payment method action.
|
|
19
|
+
- A note about one section of a page, inline at the top of that section.
|
|
20
|
+
|
|
21
|
+
### When not to use
|
|
22
|
+
|
|
23
|
+
- Confirming that an action succeeded → use [Toast](./toast.md) via `toast()`.
|
|
24
|
+
- One field is invalid → use FormMessage from [Label](./form-label.md), under the field.
|
|
25
|
+
- The status of an item (Active, Draft, Failed) → use [Badge](./badge.md).
|
|
26
|
+
- The user must decide before an irreversible action → use [Dialog](./dialog.md).
|
|
27
|
+
- There's nothing to show yet → see [patterns/empty-states.md](../patterns/empty-states.md).
|
|
28
|
+
|
|
29
|
+
## 3. Anatomy
|
|
30
|
+
|
|
31
|
+
1. **Container**: the `<div>`; carries the variant colours. Inline banners get `--curves-sm` corners; every variant except `default` has a 1px border.
|
|
32
|
+
2. **Icon** (optional): the `icon` prop, before the message. It inherits the variant's text colour.
|
|
33
|
+
3. **Message**: the children. Takes the remaining width and wraps.
|
|
34
|
+
4. **Action** (optional): the `action` prop, after the message. Usually a small Button.
|
|
35
|
+
5. **Dismiss button** (optional): shown with `dismissible`. An X icon button named "Dismiss" that calls `onDismiss`.
|
|
36
|
+
|
|
37
|
+
Content sits in a row with a `--spacing-sm` gap.
|
|
38
|
+
|
|
39
|
+
## 4. Variants
|
|
40
|
+
|
|
41
|
+
| Variant | Use for |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| `informative` | Neutral information: a new version, a feature note. The default. |
|
|
44
|
+
| `caution` | A problem ahead: trial ending, storage nearly full, scheduled maintenance. |
|
|
45
|
+
| `destructive` | Errors and blocking problems: a failed form submit, a failed payment. |
|
|
46
|
+
| `positive` | A success that stays relevant on the page: "Domain verified." |
|
|
47
|
+
| `neutral` | A low-emphasis note in grey. |
|
|
48
|
+
| `default` | An inverse (dark) strip for an announcement without a tone. |
|
|
49
|
+
|
|
50
|
+
## 5. Sizes
|
|
51
|
+
|
|
52
|
+
Banner has no size prop. Text is `--font-size-sm` at weight 500, with `--spacing-xs` vertical and `--spacing-sm` horizontal padding. `position` sets placement instead:
|
|
53
|
+
|
|
54
|
+
| Position | Use for |
|
|
55
|
+
| --- | --- |
|
|
56
|
+
| `inline` | Default. In the document flow, with rounded corners. Form-level and section-level messages. |
|
|
57
|
+
| `top` | Fixed to the top of the viewport, edge to edge, square corners. Account and page notices. |
|
|
58
|
+
| `bottom` | Fixed to the bottom of the viewport, edge to edge. |
|
|
59
|
+
|
|
60
|
+
## 6. States
|
|
61
|
+
|
|
62
|
+
| State | Looks like | Notes |
|
|
63
|
+
| --- | --- | --- |
|
|
64
|
+
| Default | Variant colours | |
|
|
65
|
+
| Hover | Only the dismiss button changes: 60% to full opacity | |
|
|
66
|
+
| Focus | Dismiss button: 1px outline in the banner's text colour (`currentColor`), 1px offset, at full opacity | Never remove or restyle the focus ring. |
|
|
67
|
+
| Dismissed | Nothing changes on its own | The dismiss button only calls `onDismiss`. Stop rendering the Banner in that handler. |
|
|
68
|
+
|
|
69
|
+
## 7. Content guidelines
|
|
70
|
+
|
|
71
|
+
- Say what happened and what to do next, in one or two sentences: "We couldn't save your changes. Check your connection and try again."
|
|
72
|
+
- Lead with the consequence or the date: "Your trial ends in 3 days."
|
|
73
|
+
- Put the fix in `action` as a Button with a verb label: "Upgrade", "Update payment method".
|
|
74
|
+
- Use sentence case and end sentences with a period.
|
|
75
|
+
|
|
76
|
+
| Do | Don't |
|
|
77
|
+
| --- | --- |
|
|
78
|
+
| Your trial ends in 3 days. | Heads up!!! |
|
|
79
|
+
| We couldn't save your changes. Check your connection and try again. | Error 500 |
|
|
80
|
+
| Payment failed. Update your card to keep your workspace active. | Something went wrong. |
|
|
81
|
+
|
|
82
|
+
## 8. Rules
|
|
83
|
+
|
|
84
|
+
1. Set `role` yourself: `role="alert"` for errors and blocking messages, `role="status"` for everything else. Never leave the default `role="banner"`, which is the page-header landmark, not a message.
|
|
85
|
+
2. Use `position="inline"` for form-level and section-level messages, placed at the top of the form or section they describe.
|
|
86
|
+
3. Use `position="top"` for account and page notices. Show one fixed Banner at a time.
|
|
87
|
+
4. Match `variant` to the meaning: `destructive` for errors, `caution` for warnings, `positive` for success, `informative` or `neutral` for information.
|
|
88
|
+
5. Pass `onDismiss` whenever you pass `dismissible`, and stop rendering the Banner in it. `dismissible` alone renders a button that does nothing.
|
|
89
|
+
6. Don't use a Banner for a transient confirmation (use [Toast](./toast.md)), and never show one event in both.
|
|
90
|
+
7. Size icons with `--size-xxs` and mark them `aria-hidden="true"`; don't use Lucide's numeric `size` prop.
|
|
91
|
+
8. Never pass `className` or `style`; they're dropped. Put width and margins on a wrapper.
|
|
92
|
+
|
|
93
|
+
## 9. Dos and don'ts
|
|
94
|
+
|
|
95
|
+
**Do:** show a form-level server error inline, as an alert.
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
{submitError && (
|
|
99
|
+
<Banner variant="destructive" position="inline" role="alert">
|
|
100
|
+
We couldn't create the project. Try again in a few minutes.
|
|
101
|
+
</Banner>
|
|
102
|
+
)}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Don't:** report it with a toast, or leave the landmark role on an inline message.
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
toast.error("We couldn't create the project.");
|
|
109
|
+
|
|
110
|
+
<Banner variant="destructive">We couldn't create the project.</Banner>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Do:** put a page notice at the top with its fix as the action.
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
<Banner
|
|
117
|
+
variant="caution"
|
|
118
|
+
position="top"
|
|
119
|
+
role="status"
|
|
120
|
+
action={<Button size="sm" variant="outline" asChild><a href="/billing">Upgrade</a></Button>}
|
|
121
|
+
>
|
|
122
|
+
Your trial ends in 3 days.
|
|
123
|
+
</Banner>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Don't:** make it dismissible without handling the dismissal.
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
<Banner variant="caution" position="top" dismissible>
|
|
130
|
+
Your trial ends in 3 days.
|
|
131
|
+
</Banner>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## 10. Accessibility
|
|
135
|
+
|
|
136
|
+
- Role: hardcoded `role="banner"` (a page landmark). Override it: `role="alert"` for errors and blocking messages (announced immediately), `role="status"` for other notices (announced politely). See Rules.
|
|
137
|
+
- Label: the message text. The dismiss button is named "Dismiss"; the name is fixed, so several dismissible banners share it.
|
|
138
|
+
- Keyboard: Tab reaches the action and the dismiss button; Enter and Space activate them. Banner has no Escape handling.
|
|
139
|
+
- Focus: Banner never moves focus. Render it when the event happens so the live region announces it. When the user dismisses it, the focused button unmounts; move focus to a sensible place, such as the form's first field or the page heading.
|
|
140
|
+
- The dismiss button has no padding around its `--size-xxs` icon, so its hit target is small.
|
|
141
|
+
- Contrast: handled by the theme. Don't override colours.
|
|
142
|
+
|
|
143
|
+
## 11. Behaviour
|
|
144
|
+
|
|
145
|
+
- Responsive: Banner is always 100% wide. Inline banners fill their container; `top` and `bottom` stretch edge to edge of the viewport.
|
|
146
|
+
- Overflow and truncation: the message wraps; the icon, action and dismiss button keep their size.
|
|
147
|
+
- Fixed banners (`top`, `bottom`) sit above page content at z-index 50 and don't reserve space, so they cover whatever is under them. Leave room in your layout.
|
|
148
|
+
- Motion: no enter or exit animation; the dismiss button fades its opacity over 150ms.
|
|
149
|
+
|
|
150
|
+
## 12. API
|
|
151
|
+
|
|
152
|
+
<!-- api:start -->
|
|
153
|
+
| Prop | Type | Default | Description |
|
|
154
|
+
| --- | --- | --- | --- |
|
|
155
|
+
| `variant` | `"default" \| "informative" \| "positive" \| "caution" \| "destructive" \| "neutral"` | `"informative"` | Visual style. |
|
|
156
|
+
| `position` | `"inline" \| "top" \| "bottom"` | `"inline"` | In the flow, or fixed to the top or bottom of the viewport. |
|
|
157
|
+
| `icon` | `ReactNode` | | Leading icon. |
|
|
158
|
+
| `action` | `ReactNode` | | Trailing action, usually a small Button. |
|
|
159
|
+
| `dismissible` | `boolean` | `false` | Shows a dismiss button named "Dismiss". |
|
|
160
|
+
| `onDismiss` | `() => void` | | Called when the dismiss button is clicked. Unmount the Banner here. |
|
|
161
|
+
| `role` | `string` | `"banner"` | Always set it: `"alert"` or `"status"`. |
|
|
162
|
+
| `...props` | `HTMLAttributes<HTMLDivElement>` without `className`, `style` | | `id`, `aria-*`, event handlers. The ref goes to the root `<div>`. |
|
|
163
|
+
<!-- api:end -->
|
|
164
|
+
|
|
165
|
+
## 13. Examples
|
|
166
|
+
|
|
167
|
+
Form-level error after a failed submit:
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
import { useState } from "react";
|
|
171
|
+
import { Banner, Button } from "@eluan/core";
|
|
172
|
+
import { CircleAlert } from "lucide-react";
|
|
173
|
+
|
|
174
|
+
export function CreateProjectForm({ create }: { create: () => Promise<void> }) {
|
|
175
|
+
const [failed, setFailed] = useState(false);
|
|
176
|
+
|
|
177
|
+
async function handleSubmit(event: React.FormEvent) {
|
|
178
|
+
event.preventDefault();
|
|
179
|
+
setFailed(false);
|
|
180
|
+
try {
|
|
181
|
+
await create();
|
|
182
|
+
} catch {
|
|
183
|
+
setFailed(true);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
<form onSubmit={handleSubmit} style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-lg)" }}>
|
|
189
|
+
{failed && (
|
|
190
|
+
<Banner
|
|
191
|
+
variant="destructive"
|
|
192
|
+
position="inline"
|
|
193
|
+
role="alert"
|
|
194
|
+
icon={<CircleAlert aria-hidden="true" style={{ width: "var(--size-xxs)", height: "var(--size-xxs)" }} />}
|
|
195
|
+
>
|
|
196
|
+
We couldn't create the project. Check your connection and try again.
|
|
197
|
+
</Banner>
|
|
198
|
+
)}
|
|
199
|
+
<div style={{ display: "flex", justifyContent: "flex-end" }}>
|
|
200
|
+
<Button type="submit">Create project</Button>
|
|
201
|
+
</div>
|
|
202
|
+
</form>
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Dismissible page notice:
|
|
208
|
+
|
|
209
|
+
```tsx
|
|
210
|
+
import { useState } from "react";
|
|
211
|
+
import { Banner, Button } from "@eluan/core";
|
|
212
|
+
|
|
213
|
+
export function TrialNotice({ daysLeft }: { daysLeft: number }) {
|
|
214
|
+
const [open, setOpen] = useState(true);
|
|
215
|
+
if (!open) return null;
|
|
216
|
+
|
|
217
|
+
return (
|
|
218
|
+
<Banner
|
|
219
|
+
variant="caution"
|
|
220
|
+
position="top"
|
|
221
|
+
role="status"
|
|
222
|
+
dismissible
|
|
223
|
+
onDismiss={() => setOpen(false)}
|
|
224
|
+
action={
|
|
225
|
+
<Button asChild size="sm" variant="outline">
|
|
226
|
+
<a href="/billing">Upgrade</a>
|
|
227
|
+
</Button>
|
|
228
|
+
}
|
|
229
|
+
>
|
|
230
|
+
Your trial ends in {daysLeft} days.
|
|
231
|
+
</Banner>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## 14. Related components
|
|
237
|
+
|
|
238
|
+
- [Toast](./toast.md): transient confirmation that closes on its own.
|
|
239
|
+
- [Label](./form-label.md): FormMessage for an error on one field.
|
|
240
|
+
- [Badge](./badge.md): status on an item, not a message.
|
|
241
|
+
- [Dialog](./dialog.md): when the user has to decide.
|
|
242
|
+
- [Button](./button.md): the `action` slot.
|
|
243
|
+
- See [patterns/feedback.md](../patterns/feedback.md) for choosing between them.
|
|
244
|
+
|
|
245
|
+
## 15. Common agent mistakes
|
|
246
|
+
|
|
247
|
+
_Filled from evals._
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Box
|
|
3
|
+
use_when: One element needs token padding, or needs to take the remaining space in a Row or Stack, without laying out children of its own.
|
|
4
|
+
instead_of: Stack or Row when the element also places several children; Card when the block needs a surface, border or radius.
|
|
5
|
+
source: packages/core/src/components/box.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Box
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
Box is the smallest layout primitive: an element (`div` by default) that takes `--spacing-*` padding through `pad`, `padX` and `padY`. In a flex parent it takes the remaining space with `grow` or holds its content size with `shrink={false}`. `height` and `minHeight` fill the parent or the viewport, `position` and `inset` make an anchor and an overlay pinned to it, and `overflow` clips or scrolls. It has no display, background or border of its own. Stack, Row and Grid take the same props, so reach for Box only when the element doesn't also lay out its children. It takes `as` and `asChild` and drops `className` and `style`.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- The child of a Row that should take the leftover width, such as a search Input beside a Button (`<Box grow>`).
|
|
17
|
+
- Padding around a single child, such as content inside a region you own.
|
|
18
|
+
- A semantic wrapper with padding (`as="li"`, `as="section"`).
|
|
19
|
+
- A child of a Row that must keep its size while its neighbours wrap or truncate (`<Box shrink={false}>`).
|
|
20
|
+
- A scroll region in a parent of fixed height (`<Box height="full" overflow="auto">`).
|
|
21
|
+
- An overlay on media or a panel: `position="relative"` on the anchor, `inset="fill"` (covering it) or `inset="bottom"` (a bar along its bottom edge) on the overlay.
|
|
22
|
+
|
|
23
|
+
### When not to use
|
|
24
|
+
|
|
25
|
+
- An element that places several children → [Stack](./stack.md), [Row](./row.md) or [Grid](./grid.md), which take the same padding props.
|
|
26
|
+
- A framed block with a surface → [Card](./card.md).
|
|
27
|
+
- Space between siblings → `gap` on their parent, not padding on each.
|
|
28
|
+
|
|
29
|
+
## 3. Anatomy
|
|
30
|
+
|
|
31
|
+
1. **Element**: one element (`div` by default) with padding and, with `grow`, `flex: 1 1 0` and `min-width: 0`. The other props add one rule each: `flex-shrink`, `height`, `min-height`, `position` (with edge offsets for `inset`) and `overflow`. With no props it renders a plain element with no styles.
|
|
32
|
+
|
|
33
|
+
## 4. Variants
|
|
34
|
+
|
|
35
|
+
Box has no `variant`.
|
|
36
|
+
|
|
37
|
+
## 5. Sizes
|
|
38
|
+
|
|
39
|
+
Box has no size prop. `pad` pads every side; `padX` (inline: left and right in LTR) and `padY` (block: top and bottom) override it per axis. Each is a `--spacing-*` step from `"none"` to `"4xl"`. `<Box pad="sm" padX="lg">` is `sm` top and bottom, `lg` left and right.
|
|
40
|
+
|
|
41
|
+
`height` and `minHeight` take `"full"` (100% of the parent, which needs a height of its own) or `"screen"` (the viewport, `100dvh`, so mobile browser bars don't cover the bottom). Widths aren't props; set them on an element you own.
|
|
42
|
+
|
|
43
|
+
## 6. States
|
|
44
|
+
|
|
45
|
+
| State | Looks like | Notes |
|
|
46
|
+
| --- | --- | --- |
|
|
47
|
+
| Default | Its content, padded | Static. Box has no interactive states. |
|
|
48
|
+
|
|
49
|
+
## 7. Content guidelines
|
|
50
|
+
|
|
51
|
+
- Box carries no meaning of its own. Use `as` when the element is a list item, section or label.
|
|
52
|
+
|
|
53
|
+
## 8. Rules
|
|
54
|
+
|
|
55
|
+
1. Use `--spacing-*` steps only, through `pad`, `padX` and `padY`. Never write px.
|
|
56
|
+
2. Don't use Box to space siblings apart; use `gap` on their Stack, Row or Grid.
|
|
57
|
+
3. Don't nest a Box inside a Stack or Row just to pad it; give the Stack or Row `pad` itself.
|
|
58
|
+
4. With `grow`, put `truncate` text inside the Box: `min-width: 0` lets it shrink, so the ellipsis shows instead of the row overflowing.
|
|
59
|
+
5. Don't pass `className` or `style`; they're dropped. Widths, hover effects and animation go on an element you own: nest the Box in it, or render it through `asChild`.
|
|
60
|
+
6. `inset` positions the Box absolutely against its nearest positioned ancestor. Give that ancestor `position="relative"`, or the overlay lands on whatever positioned element is further up.
|
|
61
|
+
7. `height="full"` needs a parent with a height. Inside a parent whose height comes from its content, it does nothing.
|
|
62
|
+
|
|
63
|
+
## 9. Dos and don'ts
|
|
64
|
+
|
|
65
|
+
**Do:** let one child take the remaining width.
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
<Row gap="sm">
|
|
69
|
+
<Box grow>
|
|
70
|
+
<Input type="search" aria-label="Search projects" />
|
|
71
|
+
</Box>
|
|
72
|
+
<Button variant="outline">Filters</Button>
|
|
73
|
+
</Row>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Don't:** stretch it with a hand-written flex rule.
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
<div style={{ display: "flex", gap: 8 }}>
|
|
80
|
+
<div style={{ flex: 1 }}>
|
|
81
|
+
<Input type="search" aria-label="Search projects" />
|
|
82
|
+
</div>
|
|
83
|
+
<Button variant="outline">Filters</Button>
|
|
84
|
+
</div>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## 10. Accessibility
|
|
88
|
+
|
|
89
|
+
- Role: none by default. Use `as` (`li`, `section`, `label`) when the element has meaning.
|
|
90
|
+
- Keyboard: none. Box isn't focusable.
|
|
91
|
+
|
|
92
|
+
## 11. Behaviour
|
|
93
|
+
|
|
94
|
+
- Responsive: Box has no responsive props.
|
|
95
|
+
- Density: padding follows `data-spacing`.
|
|
96
|
+
- Shrinking: with `grow`, Box has `min-width: 0`, so it can shrink below its content in a Row. `shrink={false}` does the opposite: the Box keeps its content size and its neighbours give up the room.
|
|
97
|
+
- Overlays: with `inset`, Box leaves the flow and covers or edges the anchor. A covering overlay hides what's under it from pointer events, not from screen readers; take content it hides out of the page when it shows.
|
|
98
|
+
- Motion: none.
|
|
99
|
+
|
|
100
|
+
## 12. API
|
|
101
|
+
|
|
102
|
+
<!-- api:start -->
|
|
103
|
+
| Prop | Type | Default | Description |
|
|
104
|
+
| --- | --- | --- | --- |
|
|
105
|
+
| `pad` | `"none" \| "xxs" \| "xs" \| "sm" \| "md" \| "lg" \| "xl" \| "2xl" \| "3xl" \| "4xl"` | | Padding on every side. `padX` / `padY` override it per axis. |
|
|
106
|
+
| `padX` | `"none" \| "xxs" \| "xs" \| "sm" \| "md" \| "lg" \| "xl" \| "2xl" \| "3xl" \| "4xl"` | | Inline padding (left and right in LTR). |
|
|
107
|
+
| `padY` | `"none" \| "xxs" \| "xs" \| "sm" \| "md" \| "lg" \| "xl" \| "2xl" \| "3xl" \| "4xl"` | | Block padding (top and bottom). |
|
|
108
|
+
| `grow` | `boolean` | | Take the remaining space in a flex parent: `flex: 1 1 0` with `min-width: 0`. |
|
|
109
|
+
| `as` | `"div" \| "span" \| "section" \| "article" \| "aside" \| "header" \| "footer" \| "main" \| "nav" \| "form" \| "fieldset" \| "label" \| "p" \| "ul" \| "ol" \| "li" \| "dl" \| "dt" \| "dd"` | | Element override. Defaults to `div`. |
|
|
110
|
+
| `asChild` | `boolean` | `false` | Render the child element instead (Radix Slot); the layout styles move onto it. |
|
|
111
|
+
| `shrink` | `boolean` | | `false` keeps the element at its content size in a flex parent (`flex-shrink: 0`). |
|
|
112
|
+
| `height` | `"full" \| "screen"` | | `full` fills the parent's height; `screen` fills the viewport (`100dvh`, so mobile browser bars don't cover the bottom). |
|
|
113
|
+
| `minHeight` | `"full" \| "screen"` | | At least the parent's height (`full`) or the viewport's (`screen`). |
|
|
114
|
+
| `position` | `"relative" \| "absolute"` | | `relative` makes this the anchor for `inset` children; `absolute` takes it out of flow. |
|
|
115
|
+
| `inset` | `"fill" \| "top" \| "bottom"` | | Pin to the nearest positioned ancestor: `fill` covers it, `top` and `bottom` run along that edge at full width. Sets `position: absolute`. |
|
|
116
|
+
| `overflow` | `"hidden" \| "auto"` | | `hidden` clips the content; `auto` scrolls it when it doesn't fit. |
|
|
117
|
+
| `...props` | `HTMLAttributes<HTMLElement>` without `className`, `style` | | Native attributes: `id`, `role`, `aria-*`, `data-*`, event handlers. |
|
|
118
|
+
<!-- api:end -->
|
|
119
|
+
|
|
120
|
+
## 13. Examples
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
import { Box, Button, Row, Typography } from "@eluan/core";
|
|
124
|
+
|
|
125
|
+
export function ProjectRow({ title, updated }: { title: string; updated: string }) {
|
|
126
|
+
return (
|
|
127
|
+
<Row gap="md" padY="sm">
|
|
128
|
+
<Box grow>
|
|
129
|
+
<Typography truncate>{title}</Typography>
|
|
130
|
+
</Box>
|
|
131
|
+
<Typography variant="caption" tone="muted" tabular>
|
|
132
|
+
{updated}
|
|
133
|
+
</Typography>
|
|
134
|
+
<Button size="sm">Open</Button>
|
|
135
|
+
</Row>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
An overlay: the Box is the anchor, the Stack covers it while the cover uploads.
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
import { Box, Spinner, Stack } from "@eluan/core";
|
|
144
|
+
|
|
145
|
+
export function CoverPreview({ src, uploading }: { src: string; uploading: boolean }) {
|
|
146
|
+
return (
|
|
147
|
+
<Box position="relative" overflow="hidden">
|
|
148
|
+
<img src={src} alt="Project cover" />
|
|
149
|
+
{uploading && (
|
|
150
|
+
<Stack inset="fill" align="center" justify="center">
|
|
151
|
+
<Spinner />
|
|
152
|
+
</Stack>
|
|
153
|
+
)}
|
|
154
|
+
</Box>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## 14. Related components
|
|
160
|
+
|
|
161
|
+
- [Stack](./stack.md), [Row](./row.md), [Grid](./grid.md): take the same padding and `grow` props, and lay out children too.
|
|
162
|
+
- [Card](./card.md): a padded block with a surface.
|
|
163
|
+
|
|
164
|
+
## 15. Common agent mistakes
|
|
165
|
+
|
|
166
|
+
_Filled from evals._
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Breadcrumb
|
|
3
|
+
use_when: A page sits two or more levels deep in a hierarchy and the user needs to see where they are and step back up.
|
|
4
|
+
instead_of: NavigationDrawer or NavigationMenu for primary navigation; Stepper for steps in a process; Button variant link with asChild for a single Back link.
|
|
5
|
+
source: packages/core/src/components/breadcrumb.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Breadcrumb
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
Breadcrumb shows the trail from a top-level page to the current one, as a row of links separated by chevrons inside a `<nav aria-label="breadcrumb">`. It's composed from small parts: a list, items, links, the current page, separators and an optional ellipsis that can hide middle levels in a dropdown.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- Pages two or more levels below a section: Projects › Apollo › Settings.
|
|
17
|
+
- Detail pages reached from a list, so the user can go back up to the list: Invoices › INV-1042.
|
|
18
|
+
- Documentation or file hierarchies where users jump between levels.
|
|
19
|
+
|
|
20
|
+
### When not to use
|
|
21
|
+
|
|
22
|
+
- Primary navigation between sections → use [NavigationDrawer](./navigation-drawer.md), [NavigationMenu](./navigation-menu.md) or [Header](./header.md).
|
|
23
|
+
- Progress through an ordered flow (checkout, onboarding) → use [Stepper](./stepper.md).
|
|
24
|
+
- A top-level page with nothing above it → leave Breadcrumb out.
|
|
25
|
+
- A single "Back to invoices" link → use [Button](./button.md) `variant="link"` with `asChild` around an `<a>`.
|
|
26
|
+
- Switching views within the page → use [Tabs](./tabs.md).
|
|
27
|
+
|
|
28
|
+
## 3. Anatomy
|
|
29
|
+
|
|
30
|
+
1. **Nav** (`Breadcrumb`): a `<nav aria-label="breadcrumb">` landmark. Adds no styling.
|
|
31
|
+
2. **List** (`BreadcrumbList`): an `<ol>` that wraps onto more lines when needed. `--font-size-sm` text in `--interactive-fg-alt`; items are `--spacing-xxs` apart, `--spacing-sm` from 640px up.
|
|
32
|
+
3. **Item** (`BreadcrumbItem`): an `<li>` holding one link, the page, or the ellipsis.
|
|
33
|
+
4. **Link** (`BreadcrumbLink`): an `<a>` to an ancestor page, muted until hovered. Use `asChild` to render your router's link.
|
|
34
|
+
5. **Page** (`BreadcrumbPage`): the current page as plain text in `--interactive-fg`, with `aria-current="page"`. Not a link.
|
|
35
|
+
6. **Separator** (`BreadcrumbSeparator`): an `<li>` hidden from assistive tech. Shows a chevron by default; pass one Lucide icon as a child to change it. The icon is sized to the text.
|
|
36
|
+
7. **Ellipsis** (`BreadcrumbEllipsis`, optional): stands in for hidden middle levels. With `items` it's a ghost icon Button that opens a [DropdownMenu](./dropdown-menu.md) of those levels; without `items` it's a decorative "…".
|
|
37
|
+
|
|
38
|
+
## 4. Variants
|
|
39
|
+
|
|
40
|
+
Breadcrumb has no variants. Change the separator glyph by passing an icon to `BreadcrumbSeparator`.
|
|
41
|
+
|
|
42
|
+
## 5. Sizes
|
|
43
|
+
|
|
44
|
+
Breadcrumb has no size prop. Text is `--font-size-sm` and gaps come from `--spacing-*`, so it follows the density axis.
|
|
45
|
+
|
|
46
|
+
## 6. States
|
|
47
|
+
|
|
48
|
+
| State | Looks like | Notes |
|
|
49
|
+
| --- | --- | --- |
|
|
50
|
+
| Default | Links in `--interactive-fg-alt`; the current page in `--interactive-fg` | Links set no text decoration, so they keep the browser underline unless your CSS reset removes it. |
|
|
51
|
+
| Hover | Link text turns `--interactive-fg` | |
|
|
52
|
+
| Focus | Links keep the browser's default focus ring; the ellipsis Button shows its 1px `--focus-ring` outline | Never remove or restyle the focus ring. |
|
|
53
|
+
| Current | `BreadcrumbPage`: `--interactive-fg`, not interactive | |
|
|
54
|
+
| Disabled | Ellipsis entries without `href` or `onClick` are disabled in its dropdown | |
|
|
55
|
+
|
|
56
|
+
## 7. Content guidelines
|
|
57
|
+
|
|
58
|
+
- Use each page's own title, shortened if needed: "Invoices", "INV-1042", "Settings".
|
|
59
|
+
- Use sentence case, matching the page titles.
|
|
60
|
+
- Start at the section root, not "Home", unless the site has a real home page users return to.
|
|
61
|
+
- End with the current page, as `BreadcrumbPage`.
|
|
62
|
+
- Collapse middle levels into `BreadcrumbEllipsis` when the trail has more than four levels; keep the first and the last two.
|
|
63
|
+
|
|
64
|
+
| Do | Don't |
|
|
65
|
+
| --- | --- |
|
|
66
|
+
| Invoices › INV-1042 | Home › Billing › Invoices › Invoice details for INV-1042 |
|
|
67
|
+
| Projects › Apollo › Settings | projects / apollo / settings |
|
|
68
|
+
|
|
69
|
+
## 8. Rules
|
|
70
|
+
|
|
71
|
+
1. Put each link, page and ellipsis in its own `BreadcrumbItem`, and put a `BreadcrumbSeparator` between items, never inside one.
|
|
72
|
+
2. End the trail with `BreadcrumbPage` for the current page. Don't make the current page a link.
|
|
73
|
+
3. Render router links with `asChild`: `<BreadcrumbLink asChild><Link href="/invoices">Invoices</Link></BreadcrumbLink>`.
|
|
74
|
+
4. Change the separator by passing an icon child to `BreadcrumbSeparator`. Don't use the `separator` prop on `Breadcrumb`; it isn't wired up and leaks onto the `<nav>` element.
|
|
75
|
+
5. With a client-side router, give `BreadcrumbEllipsis` items an `onClick` that calls the router. An `href` alone triggers a full page load (`window.location.href`).
|
|
76
|
+
6. Use one Breadcrumb per page, above the page title.
|
|
77
|
+
7. Never pass `className` or `style` to any part. Put spacing on a wrapper you own.
|
|
78
|
+
|
|
79
|
+
## 9. Dos and don'ts
|
|
80
|
+
|
|
81
|
+
**Do:** separate items and end with the current page.
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
<Breadcrumb>
|
|
85
|
+
<BreadcrumbList>
|
|
86
|
+
<BreadcrumbItem>
|
|
87
|
+
<BreadcrumbLink href="/invoices">Invoices</BreadcrumbLink>
|
|
88
|
+
</BreadcrumbItem>
|
|
89
|
+
<BreadcrumbSeparator />
|
|
90
|
+
<BreadcrumbItem>
|
|
91
|
+
<BreadcrumbPage>INV-1042</BreadcrumbPage>
|
|
92
|
+
</BreadcrumbItem>
|
|
93
|
+
</BreadcrumbList>
|
|
94
|
+
</Breadcrumb>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Don't:** type separators into the text or link the current page.
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
<Breadcrumb>
|
|
101
|
+
<BreadcrumbList>
|
|
102
|
+
<BreadcrumbItem>
|
|
103
|
+
<BreadcrumbLink href="/invoices">Invoices /</BreadcrumbLink>
|
|
104
|
+
<BreadcrumbLink href="/invoices/inv-1042">INV-1042</BreadcrumbLink>
|
|
105
|
+
</BreadcrumbItem>
|
|
106
|
+
</BreadcrumbList>
|
|
107
|
+
</Breadcrumb>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Do:** swap the glyph with an icon child.
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
<BreadcrumbSeparator>
|
|
114
|
+
<Slash aria-hidden="true" />
|
|
115
|
+
</BreadcrumbSeparator>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Don't:** use the unwired `separator` prop or size the icon yourself.
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
<Breadcrumb separator={<Slash size={14} />}>…</Breadcrumb>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## 10. Accessibility
|
|
125
|
+
|
|
126
|
+
- Role: a `navigation` landmark named "breadcrumb"; the trail is an ordered list. Separators are `presentation` and `aria-hidden`.
|
|
127
|
+
- Label: links are named by their text. Pass `aria-label` on `Breadcrumb` to rename the landmark ("Breadcrumb", or a localised name).
|
|
128
|
+
- Current page: `BreadcrumbPage` carries `aria-current="page"`, `role="link"` and `aria-disabled="true"`.
|
|
129
|
+
- Ellipsis: with `items`, it's a Button named "Show more breadcrumbs" that opens a menu. Without `items` it's hidden from assistive tech, so the hidden levels aren't announced.
|
|
130
|
+
- Keyboard: Tab moves through the links; Enter follows one. The ellipsis menu uses DropdownMenu keys (arrows, Enter, Escape).
|
|
131
|
+
- Contrast: handled by the theme. Don't override colours. Links keep the browser focus ring; don't add your own.
|
|
132
|
+
|
|
133
|
+
## 11. Behaviour
|
|
134
|
+
|
|
135
|
+
- Responsive: the list wraps onto more lines rather than truncating. Item gaps widen from `--spacing-xxs` to `--spacing-sm` at 640px.
|
|
136
|
+
- Overflow and truncation: nothing truncates. Shorten labels or collapse middle levels with `BreadcrumbEllipsis`.
|
|
137
|
+
- Motion: link colour transitions over 150ms. Don't add more.
|
|
138
|
+
|
|
139
|
+
## 12. API
|
|
140
|
+
|
|
141
|
+
<!-- api:start -->
|
|
142
|
+
### Breadcrumb
|
|
143
|
+
|
|
144
|
+
| Prop | Type | Default | Description |
|
|
145
|
+
| --- | --- | --- | --- |
|
|
146
|
+
| `aria-label` | `string` | `"breadcrumb"` | Name of the navigation landmark. |
|
|
147
|
+
| `separator` | `ReactNode` | | Declared but not used; it is passed through to the `<nav>`. Don't use it. |
|
|
148
|
+
| `...props` | `ComponentProps<"nav">` without `className`, `style` | | |
|
|
149
|
+
|
|
150
|
+
### BreadcrumbList, BreadcrumbItem
|
|
151
|
+
|
|
152
|
+
| Prop | Type | Default | Description |
|
|
153
|
+
| --- | --- | --- | --- |
|
|
154
|
+
| `...props` | `ComponentProps<"ol">` / `ComponentProps<"li">` without `className`, `style` | | |
|
|
155
|
+
|
|
156
|
+
### BreadcrumbLink
|
|
157
|
+
|
|
158
|
+
| Prop | Type | Default | Description |
|
|
159
|
+
| --- | --- | --- | --- |
|
|
160
|
+
| `asChild` | `boolean` | `false` | Renders your child (a router link) with the link styles. |
|
|
161
|
+
| `...props` | `ComponentProps<"a">` without `className`, `style` | | `href`. |
|
|
162
|
+
|
|
163
|
+
### BreadcrumbPage
|
|
164
|
+
|
|
165
|
+
| Prop | Type | Default | Description |
|
|
166
|
+
| --- | --- | --- | --- |
|
|
167
|
+
| `...props` | `ComponentProps<"span">` without `className`, `style` | | Renders with `aria-current="page"`. |
|
|
168
|
+
|
|
169
|
+
### BreadcrumbSeparator
|
|
170
|
+
|
|
171
|
+
| Prop | Type | Default | Description |
|
|
172
|
+
| --- | --- | --- | --- |
|
|
173
|
+
| `children` | `ReactNode` | chevron icon | One icon element to use as the separator; it's sized to the text. |
|
|
174
|
+
| `...props` | `ComponentProps<"li">` without `className`, `style` | | |
|
|
175
|
+
|
|
176
|
+
### BreadcrumbEllipsis
|
|
177
|
+
|
|
178
|
+
| Prop | Type | Default | Description |
|
|
179
|
+
| --- | --- | --- | --- |
|
|
180
|
+
| `items` | `{ label: string; href?: string; onClick?: () => void }[]` | `[]` | Hidden levels shown in a dropdown. Empty renders a decorative "…". `onClick` wins over `href`; `href` does a full page load. |
|
|
181
|
+
<!-- api:end -->
|
|
182
|
+
|
|
183
|
+
## 13. Examples
|
|
184
|
+
|
|
185
|
+
```tsx
|
|
186
|
+
import {
|
|
187
|
+
Breadcrumb,
|
|
188
|
+
BreadcrumbEllipsis,
|
|
189
|
+
BreadcrumbItem,
|
|
190
|
+
BreadcrumbLink,
|
|
191
|
+
BreadcrumbList,
|
|
192
|
+
BreadcrumbPage,
|
|
193
|
+
BreadcrumbSeparator,
|
|
194
|
+
Typography,
|
|
195
|
+
} from "@eluan/core";
|
|
196
|
+
|
|
197
|
+
export function InvoiceHeader({ navigate }: { navigate: (href: string) => void }) {
|
|
198
|
+
return (
|
|
199
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-sm)" }}>
|
|
200
|
+
<Breadcrumb>
|
|
201
|
+
<BreadcrumbList>
|
|
202
|
+
<BreadcrumbItem>
|
|
203
|
+
<BreadcrumbLink href="/billing">Billing</BreadcrumbLink>
|
|
204
|
+
</BreadcrumbItem>
|
|
205
|
+
<BreadcrumbSeparator />
|
|
206
|
+
<BreadcrumbItem>
|
|
207
|
+
<BreadcrumbEllipsis
|
|
208
|
+
items={[
|
|
209
|
+
{ label: "Customers", onClick: () => navigate("/billing/customers") },
|
|
210
|
+
{ label: "Northwind Traders", onClick: () => navigate("/billing/customers/northwind") },
|
|
211
|
+
]}
|
|
212
|
+
/>
|
|
213
|
+
</BreadcrumbItem>
|
|
214
|
+
<BreadcrumbSeparator />
|
|
215
|
+
<BreadcrumbItem>
|
|
216
|
+
<BreadcrumbLink href="/billing/customers/northwind/invoices">Invoices</BreadcrumbLink>
|
|
217
|
+
</BreadcrumbItem>
|
|
218
|
+
<BreadcrumbSeparator />
|
|
219
|
+
<BreadcrumbItem>
|
|
220
|
+
<BreadcrumbPage>INV-1042</BreadcrumbPage>
|
|
221
|
+
</BreadcrumbItem>
|
|
222
|
+
</BreadcrumbList>
|
|
223
|
+
</Breadcrumb>
|
|
224
|
+
<Typography variant="title" as="h1">Invoice INV-1042</Typography>
|
|
225
|
+
</div>
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## 14. Related components
|
|
231
|
+
|
|
232
|
+
- [NavigationDrawer](./navigation-drawer.md): primary app navigation; Breadcrumb shows depth within a section.
|
|
233
|
+
- [DropdownMenu](./dropdown-menu.md): what the ellipsis opens.
|
|
234
|
+
- [Stepper](./stepper.md): progress through ordered steps.
|
|
235
|
+
- [Typography](./typography.md): the page title that follows the trail.
|
|
236
|
+
- See [navigation patterns](../patterns/navigation.md).
|
|
237
|
+
|
|
238
|
+
## 15. Common agent mistakes
|
|
239
|
+
|
|
240
|
+
_Filled from evals._
|