@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,214 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Button
|
|
3
|
+
use_when: The user triggers an action, submits a form or opens an overlay.
|
|
4
|
+
instead_of: Link or your router's link for navigation (Button asChild only to style one); Toggle or Switch for on/off state; DropdownMenu for a list of actions.
|
|
5
|
+
source: packages/core/src/components/button.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Button
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
Button triggers an action. It renders a native `<button>` (or its child, with `asChild`) and comes in fourteen variants and seven sizes, including square icon-only sizes.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- Submitting or cancelling a form.
|
|
17
|
+
- Running an action on the current page: save, delete, export, add.
|
|
18
|
+
- Opening a Dialog, Sheet, Popover or DropdownMenu (as the trigger, with `asChild` on the trigger part).
|
|
19
|
+
- An icon-only action, with an `icon*` size and an `aria-label`.
|
|
20
|
+
|
|
21
|
+
### When not to use
|
|
22
|
+
|
|
23
|
+
- Moving to another page or URL → use your router's link, or [Button](./button.md) `variant="link"` with `asChild` around an `<a>` when it must look like a button.
|
|
24
|
+
- Turning a setting on or off → use [Switch](./switch.md).
|
|
25
|
+
- A pressed/unpressed state that stays visible → use [Toggle](./toggle.md) or [ToggleGroup](./toggle-group.md).
|
|
26
|
+
- Picking one view of several → use [Tabs](./tabs.md) or [SegmentedControl](./segmented-control.md).
|
|
27
|
+
- Several related actions behind one control → use [DropdownMenu](./dropdown-menu.md) or [ActionPopover](./action-popover.md).
|
|
28
|
+
|
|
29
|
+
## 3. Anatomy
|
|
30
|
+
|
|
31
|
+
1. **Container**: the `<button>` element; carries the variant colours, radius and focus outline.
|
|
32
|
+
2. **Label**: the text child. Required unless the button is icon-only.
|
|
33
|
+
3. **Icon** (optional): a Lucide icon before or after the label, or alone for icon-only sizes. Content sits in a row with a `--spacing-xs` gap.
|
|
34
|
+
|
|
35
|
+
## 4. Variants
|
|
36
|
+
|
|
37
|
+
| Variant | Use for |
|
|
38
|
+
| --- | --- |
|
|
39
|
+
| `default` | The single main action in a view or form: Save, Create, Continue. |
|
|
40
|
+
| `secondary` | A neutral filled action next to a primary one. |
|
|
41
|
+
| `outline` | Secondary actions: Cancel, Back, Export. |
|
|
42
|
+
| `ghost` | Low-emphasis actions in toolbars, table rows and headers. |
|
|
43
|
+
| `mutedGhost` | Even quieter toolbar actions on busy surfaces. |
|
|
44
|
+
| `fadedGhost` | Actions that should recede until hovered (60% opacity at rest). |
|
|
45
|
+
| `destructive` | The confirm action of a destructive flow: Delete project. |
|
|
46
|
+
| `dangerGhost` | A low-emphasis destructive entry point, such as Remove in a row. |
|
|
47
|
+
| `caution` | An action with a reversible but notable consequence. |
|
|
48
|
+
| `positive` | An action that confirms a successful or approving outcome: Approve. |
|
|
49
|
+
| `dashed` | Adding an item to a list or an empty slot: Add field. |
|
|
50
|
+
| `input` | A button that opens a picker and should look like a form field (DatePicker and Select-like triggers). |
|
|
51
|
+
| `inputMuted` | The same, showing placeholder-weight text. |
|
|
52
|
+
| `link` | An inline text action that looks like a link. |
|
|
53
|
+
|
|
54
|
+
## 5. Sizes
|
|
55
|
+
|
|
56
|
+
| Size | Use in |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| `default` | Most buttons (`--size-lg` tall). |
|
|
59
|
+
| `sm` | Dense toolbars, table rows, inline with small text (`--size-md`). |
|
|
60
|
+
| `lg` | A hero or marketing call to action (`--size-xl`). |
|
|
61
|
+
| `icon` | Icon-only, next to default-size controls. |
|
|
62
|
+
| `iconSm` | Icon-only, in dense rows. |
|
|
63
|
+
| `iconXs` | Icon-only, inside another control (clear buttons, chips). |
|
|
64
|
+
| `iconInline` | Icon-only, inline with text, no fixed box. |
|
|
65
|
+
|
|
66
|
+
## 6. States
|
|
67
|
+
|
|
68
|
+
| State | Looks like | Notes |
|
|
69
|
+
| --- | --- | --- |
|
|
70
|
+
| Default | Variant colours | |
|
|
71
|
+
| Hover | Variant `-hover` background | |
|
|
72
|
+
| Focus | 1px outline in `--focus-ring`, 1px offset | Never remove or restyle the focus ring. |
|
|
73
|
+
| Active | Variant `-active` background; solid variants nudge down slightly | `destructive` and `dashed` lose label contrast while pressed. |
|
|
74
|
+
| Disabled | 50% opacity, no pointer events | `input` variants switch to the disabled interactive tokens instead. |
|
|
75
|
+
| Loading | No built-in loading state | Put a [Spinner](./spinner.md) before the label, keep the label, set `aria-busy` and `aria-disabled`, and ignore clicks until the work settles. Don't set `disabled` on the button that was pressed: it drops keyboard focus. |
|
|
76
|
+
|
|
77
|
+
## 7. Content guidelines
|
|
78
|
+
|
|
79
|
+
- Start with a verb and say what happens: "Save changes", "Delete project".
|
|
80
|
+
- Use sentence case. Keep labels to one to three words.
|
|
81
|
+
- Match the label to the result the user expects, and reuse the same verb in the confirmation (Dialog title "Delete project?", button "Delete project").
|
|
82
|
+
- Don't end with punctuation.
|
|
83
|
+
|
|
84
|
+
| Do | Don't |
|
|
85
|
+
| --- | --- |
|
|
86
|
+
| Save changes | Click here |
|
|
87
|
+
| Delete project | OK |
|
|
88
|
+
| Add teammate | Submit |
|
|
89
|
+
| Cancel | No thanks! |
|
|
90
|
+
|
|
91
|
+
## 8. Rules
|
|
92
|
+
|
|
93
|
+
1. Use one `default` (primary) button per view or form.
|
|
94
|
+
2. Set `type="button"` on every button that doesn't submit a form. Button has no default type, so inside a `<form>` it submits.
|
|
95
|
+
3. Give icon-only buttons an `aria-label`. Mark the icon `aria-hidden="true"`.
|
|
96
|
+
4. Put the primary action last in a button row (rightmost in left-to-right layouts), with secondary actions before it.
|
|
97
|
+
5. Use `destructive` only for the action that actually destroys, usually inside a confirmation Dialog.
|
|
98
|
+
6. Never pass `className` or `style`; they're dropped. Use `fullWidth` or a wrapper for layout.
|
|
99
|
+
7. Use `asChild` to render a link with button styling, never `onClick` with `window.location`.
|
|
100
|
+
|
|
101
|
+
## 9. Dos and don'ts
|
|
102
|
+
|
|
103
|
+
**Do:** one primary action, secondary actions in `outline`.
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
<div style={{ display: "flex", gap: "var(--spacing-sm)", justifyContent: "flex-end" }}>
|
|
107
|
+
<Button type="button" variant="outline">Cancel</Button>
|
|
108
|
+
<Button type="submit">Save changes</Button>
|
|
109
|
+
</div>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Don't:** stack several primary buttons or make Cancel primary.
|
|
113
|
+
|
|
114
|
+
```tsx
|
|
115
|
+
<div>
|
|
116
|
+
<Button>Cancel</Button>
|
|
117
|
+
<Button>Save draft</Button>
|
|
118
|
+
<Button>Publish</Button>
|
|
119
|
+
</div>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Do:** name icon-only buttons.
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
<Button type="button" variant="ghost" size="icon" aria-label="Close panel">
|
|
126
|
+
<X aria-hidden="true" style={{ width: "var(--size-xxs)", height: "var(--size-xxs)" }} />
|
|
127
|
+
</Button>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Don't:** leave them unlabeled or style them by hand.
|
|
131
|
+
|
|
132
|
+
```tsx
|
|
133
|
+
<Button size="icon" style={{ background: "#eee" }}>
|
|
134
|
+
<X />
|
|
135
|
+
</Button>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**Do:** navigate with a link styled as a button.
|
|
139
|
+
|
|
140
|
+
```tsx
|
|
141
|
+
<Button asChild variant="outline">
|
|
142
|
+
<a href="/billing">View billing</a>
|
|
143
|
+
</Button>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Don't:** navigate from a click handler.
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
<Button onClick={() => (window.location.href = "/billing")}>View billing</Button>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## 10. Accessibility
|
|
153
|
+
|
|
154
|
+
- Role: `button` (native `<button>`); with `asChild`, the child's role (a link stays a link).
|
|
155
|
+
- Label: the text content; `aria-label` for icon-only buttons.
|
|
156
|
+
- Keyboard: Enter and Space activate. Tab moves focus in DOM order.
|
|
157
|
+
- Focus: visible outline on `:focus-visible`. Disabled buttons use `pointer-events: none` and the native `disabled` attribute, so they're skipped by Tab.
|
|
158
|
+
- Contrast: handled by the theme. Don't override colours.
|
|
159
|
+
|
|
160
|
+
## 11. Behaviour
|
|
161
|
+
|
|
162
|
+
- Responsive: Button sizes to its content; `fullWidth` stretches it to the container. Use `fullWidth` for stacked mobile actions.
|
|
163
|
+
- Overflow and truncation: labels don't wrap (`white-space: nowrap`). Keep them short; don't rely on truncation.
|
|
164
|
+
- Motion: colour transitions over 150ms; solid variants nudge down on press. Don't add your own.
|
|
165
|
+
- `attachment="start"` or `"end"` flattens one edge so the button sits flush against an adjacent Input.
|
|
166
|
+
|
|
167
|
+
## 12. API
|
|
168
|
+
|
|
169
|
+
<!-- api:start -->
|
|
170
|
+
| Prop | Type | Default | Description |
|
|
171
|
+
| --- | --- | --- | --- |
|
|
172
|
+
| `variant` | `"default" \| "destructive" \| "caution" \| "positive" \| "outline" \| "dashed" \| "secondary" \| "ghost" \| "mutedGhost" \| "dangerGhost" \| "fadedGhost" \| "input" \| "inputMuted" \| "link"` | `"default"` | Visual style. |
|
|
173
|
+
| `size` | `"default" \| "sm" \| "lg" \| "icon" \| "iconSm" \| "iconXs" \| "iconInline"` | `"default"` | Height and padding; `icon*` sizes are square for icon-only buttons. |
|
|
174
|
+
| `align` | `"center" \| "start"` | `"center"` | Horizontal alignment of the content. |
|
|
175
|
+
| `attachment` | `"none" \| "start" \| "end"` | `"none"` | Flattens one edge to sit flush against an adjacent control. |
|
|
176
|
+
| `shape` | `"default" \| "round"` | `"default"` | `"round"` makes a pill. |
|
|
177
|
+
| `textAlign` | `"center" \| "left"` | `"center"` | Text alignment inside the button. |
|
|
178
|
+
| `fullWidth` | `boolean` | `false` | Stretches to the container width. |
|
|
179
|
+
| `asChild` | `boolean` | `false` | Renders the child element with Button's props and styles (Radix Slot). |
|
|
180
|
+
| `...props` | `ButtonHTMLAttributes` without `className`, `style` | | Native button attributes: `type`, `disabled`, `onClick`, `aria-*`. |
|
|
181
|
+
<!-- api:end -->
|
|
182
|
+
|
|
183
|
+
## 13. Examples
|
|
184
|
+
|
|
185
|
+
```tsx
|
|
186
|
+
import { Button } from "@eluan/core";
|
|
187
|
+
import { Plus } from "lucide-react";
|
|
188
|
+
|
|
189
|
+
export function ProjectToolbar({ onCreate }: { onCreate: () => void }) {
|
|
190
|
+
return (
|
|
191
|
+
<div style={{ display: "flex", alignItems: "center", gap: "var(--spacing-sm)" }}>
|
|
192
|
+
<Button asChild variant="ghost" size="sm">
|
|
193
|
+
<a href="/projects/archive">View archive</a>
|
|
194
|
+
</Button>
|
|
195
|
+
<Button type="button" onClick={onCreate}>
|
|
196
|
+
<Plus aria-hidden="true" style={{ width: "var(--size-xxs)", height: "var(--size-xxs)" }} />
|
|
197
|
+
New project
|
|
198
|
+
</Button>
|
|
199
|
+
</div>
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## 14. Related components
|
|
205
|
+
|
|
206
|
+
- [Toggle](./toggle.md): a button that stays pressed.
|
|
207
|
+
- [ToggleGroup](./toggle-group.md): a set of pressable options.
|
|
208
|
+
- [DropdownMenu](./dropdown-menu.md): several actions behind one trigger Button.
|
|
209
|
+
- [Dialog](./dialog.md): confirm destructive actions before running them.
|
|
210
|
+
- [Spinner](./spinner.md): in-button loading feedback.
|
|
211
|
+
|
|
212
|
+
## 15. Common agent mistakes
|
|
213
|
+
|
|
214
|
+
- Setting `disabled` on the button that started a save or delete. Focus drops to the page the moment it's pressed. Set `aria-busy` and `aria-disabled` and ignore clicks until the work settles; the Spinner and label show it's busy.
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Calendar
|
|
3
|
+
use_when: A month grid stays visible on the page for picking one date, several dates or a range.
|
|
4
|
+
instead_of: DatePicker or DateRangePicker for a date field in a form or filter bar; DateTimePicker when the time matters too.
|
|
5
|
+
source: packages/core/src/components/calendar.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Calendar
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
Calendar is an inline month grid built on react-day-picker v9. It replaces the library's caption with month and year Selects, puts previous and next month buttons on either side, and supports single, multiple and range selection. DatePicker, DateRangePicker and DateTimePicker all render it inside a Popover.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- A date choice that stays on the page: a booking or availability view, a side panel that filters by day.
|
|
17
|
+
- Picking several separate dates (`mode="multiple"`). No picker wraps this mode.
|
|
18
|
+
- A custom panel or popover around a month grid that the pickers don't cover.
|
|
19
|
+
|
|
20
|
+
### When not to use
|
|
21
|
+
|
|
22
|
+
- A date field in a form → use [DatePicker](./date-picker.md).
|
|
23
|
+
- A start and end date in a form or filter bar → use DateRangePicker, documented in [DatePicker](./date-picker.md).
|
|
24
|
+
- A date plus a time of day → use [DateTimePicker](./date-time-picker.md).
|
|
25
|
+
- A time of day on its own → use [TimeInput](./time-input.md).
|
|
26
|
+
- A birth date or any date many years from today → use an [Input](./input.md) with a format hint. The year Select only lists ten years around the current one.
|
|
27
|
+
|
|
28
|
+
## 3. Anatomy
|
|
29
|
+
|
|
30
|
+
1. **Previous and next buttons**: ghost icon Buttons on the left and right edges, named "Go to previous month" and "Go to next month".
|
|
31
|
+
2. **Caption**: a month Select and a year Select for each month shown.
|
|
32
|
+
3. **Weekday row**: short weekday names in `--interactive-fg-alt`.
|
|
33
|
+
4. **Day grid**: one grid per month. Each day is a button with its number in `--font-mono`.
|
|
34
|
+
5. **Outside days** (optional): trailing and leading days of the adjacent months, shown by default.
|
|
35
|
+
|
|
36
|
+
Calendar draws no border or background of its own. Put it on a surface you own: a Card, a Popover, or a bordered wrapper.
|
|
37
|
+
|
|
38
|
+
## 4. Variants
|
|
39
|
+
|
|
40
|
+
Calendar has no `variant` prop. `mode` sets how selection works:
|
|
41
|
+
|
|
42
|
+
| Mode | Use for |
|
|
43
|
+
| --- | --- |
|
|
44
|
+
| `single` | One date. Clicking the selected date again clears it unless `required` is set. |
|
|
45
|
+
| `multiple` | Several separate dates, each toggled on click. |
|
|
46
|
+
| `range` | A start and end date. The first click selects that day as a one-day range; the next click before or after it extends the range. Use `numberOfMonths={2}`. |
|
|
47
|
+
|
|
48
|
+
## 5. Sizes
|
|
49
|
+
|
|
50
|
+
Calendar has no size prop. Day cells are `--size-md` tall and the grid stretches to fill its container, so the wrapper's width sets the cell width.
|
|
51
|
+
|
|
52
|
+
## 6. States
|
|
53
|
+
|
|
54
|
+
| State | Looks like | Notes |
|
|
55
|
+
| --- | --- | --- |
|
|
56
|
+
| Default | Day numbers in `--font-mono`, `--font-size-sm` | |
|
|
57
|
+
| Hover | Day fills with `--interactive-bg-hover` and rounds to `--curves-lg` | |
|
|
58
|
+
| Focus | 1px outline in `--focus-ring`, 1px offset, on the focused day | Never remove or restyle the focus ring. |
|
|
59
|
+
| Selected | `--interactive-bg-selected` fill with `--interactive-fg-selected` text; hovering it uses `--action-primary-bg-hover` | |
|
|
60
|
+
| Range | Start and end days take the selected fill with rounded outer corners; days between use `--interactive-bg-alt2` with `--interactive-fg-alt` text and square corners | The start day squares its inner corner once both ends are chosen. This is deliberate; don't restyle it. |
|
|
61
|
+
| Today | Bold number with a short keyline under it | The keyline offset is in `em` on purpose so it tracks density. |
|
|
62
|
+
| Outside day | `--interactive-fg-disabled` text | A selected outside day (a range that crosses a month boundary) renders pale text on a pale fill and is close to invisible. In `mode="range"`, set `showOutsideDays={false}` to avoid it. |
|
|
63
|
+
| Disabled | Whole calendar at 50% opacity, no pointer events, `aria-disabled` on the root | Set with `disabled`. |
|
|
64
|
+
|
|
65
|
+
## 7. Content guidelines
|
|
66
|
+
|
|
67
|
+
- Calendar has no text props. Name what the date is for in a heading or label right above it: "Delivery day", "Out of office".
|
|
68
|
+
- Show the chosen date in words near an inline calendar when it drives the rest of the page ("Arrives Thursday, 30 October").
|
|
69
|
+
- Month names in the caption are English whatever `locale` you pass.
|
|
70
|
+
|
|
71
|
+
| Do | Don't |
|
|
72
|
+
| --- | --- |
|
|
73
|
+
| Delivery day | Select |
|
|
74
|
+
| Days off | Calendar |
|
|
75
|
+
|
|
76
|
+
## 8. Rules
|
|
77
|
+
|
|
78
|
+
1. Always pass `mode`. Without it, days render as plain text, not buttons, and nothing can be selected.
|
|
79
|
+
2. Pass `selected` and `onSelect` together. The shape follows `mode`: a `Date`, a `Date[]`, or `{ from, to }`.
|
|
80
|
+
3. Give Calendar a container. It fills the width it's given, so constrain it with a wrapper (`width: "fit-content"` or a fixed column) and put it on a Card, a Popover or a bordered wrapper.
|
|
81
|
+
4. Use `disabled` only as a boolean for the whole calendar. Any truthy value, including a date matcher, disables every day. To restrict dates, check the date in `onSelect` and explain with a [Label](./form-label.md) hint or FormMessage.
|
|
82
|
+
5. Use `numberOfMonths={2}` for ranges, as DateRangePicker does.
|
|
83
|
+
6. Declare the range type yourself (`{ from: Date | undefined; to?: Date | undefined }`) instead of importing `DateRange` from `react-day-picker`, which is Eluan's dependency, not your app's.
|
|
84
|
+
7. Never pass `className`, `classNames`, `style` or a `MonthCaption` component. Calendar overwrites `className`, `classNames` and the caption.
|
|
85
|
+
|
|
86
|
+
## 9. Dos and don'ts
|
|
87
|
+
|
|
88
|
+
**Do:** set a mode and control the selection.
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
const [day, setDay] = React.useState<Date | undefined>();
|
|
92
|
+
|
|
93
|
+
<Calendar mode="single" selected={day} onSelect={setDay} />
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Don't:** leave out `mode`, or restyle the grid.
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
<Calendar selected={day} className="my-calendar" />
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Do:** hide outside days on an inline range calendar.
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
<Calendar mode="range" selected={range} onSelect={setRange} numberOfMonths={2} showOutsideDays={false} />
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Don't:** pass a date matcher to `disabled`; it disables the whole calendar.
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
<Calendar mode="single" selected={day} onSelect={setDay} disabled={{ before: new Date() }} />
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## 10. Accessibility
|
|
115
|
+
|
|
116
|
+
- Role: each month is a `grid` named by its month and year ("October 2026"); in `multiple` and `range` modes it is `aria-multiselectable`. Days are `gridcell`s holding buttons.
|
|
117
|
+
- Label: each day button is named with the full date ("Monday, October 27th, 2026"), with "Today, " before it and ", selected" after it where they apply. Name the calendar as a whole by wrapping it in `role="group"` with `aria-labelledby` pointing at your visible heading. The month and year Selects are named only by their current value ("October", "2026").
|
|
118
|
+
- Keyboard: Arrow keys move one day or one week; Shift with Left or Right moves a month, with Up or Down a year. Page Up and Page Down move a month (with Shift, a year). Home and End go to the start and end of the week. Enter or Space selects the focused day. Tab moves through the previous button, the month and year Selects, the grid and the next button.
|
|
119
|
+
- Focus: only one day is in the tab order at a time (roving focus); arrow keys move it, and the displayed month follows. Calendar doesn't trap focus.
|
|
120
|
+
- Contrast: handled by the theme. Don't override colours.
|
|
121
|
+
- Text size: the weekday row uses a fixed size that doesn't follow the fluid type scale or density. Don't compensate per calendar.
|
|
122
|
+
|
|
123
|
+
## 11. Behaviour
|
|
124
|
+
|
|
125
|
+
- Responsive: the grid fills its container. With `numberOfMonths={2}`, months sit side by side from a 640px viewport and stack below it, with a divider between them.
|
|
126
|
+
- Navigation: the arrows step one month. The month Select lists all twelve months; the year Select lists ten years, from five before the current year to four after. Dates outside that window are still reachable with the arrows, but the year Select then shows no matching year.
|
|
127
|
+
- Month state: uncontrolled by default (starts at `defaultMonth` or today). Pass `month` and `onMonthChange` to control it; the arrows, Selects and keyboard all report through `onMonthChange`.
|
|
128
|
+
- Motion: day colours and corners transition over 150ms. Don't add your own.
|
|
129
|
+
|
|
130
|
+
## 12. API
|
|
131
|
+
|
|
132
|
+
<!-- api:start -->
|
|
133
|
+
| Prop | Type | Default | Description |
|
|
134
|
+
| --- | --- | --- | --- |
|
|
135
|
+
| `mode` | `"single" \| "multiple" \| "range"` | | Selection mode. Required in practice: without it days aren't selectable. |
|
|
136
|
+
| `selected` | `Date \| Date[] \| { from: Date \| undefined; to?: Date \| undefined }` | | Controlled selection; the shape follows `mode`. |
|
|
137
|
+
| `onSelect` | `(selected) => void` | | Called with the new selection, or `undefined` when the user clears it. |
|
|
138
|
+
| `required` | `boolean` | `false` | Stops the user clearing the selection by clicking the selected day again. |
|
|
139
|
+
| `numberOfMonths` | `number` | `1` | Months shown together. |
|
|
140
|
+
| `month` | `Date` | | Controlled displayed month. Pair with `onMonthChange`. |
|
|
141
|
+
| `defaultMonth` | `Date` | today | Initial month when uncontrolled. |
|
|
142
|
+
| `onMonthChange` | `(month: Date) => void` | | Called when the displayed month changes. |
|
|
143
|
+
| `showOutsideDays` | `boolean` | `true` | Shows days from the adjacent months. |
|
|
144
|
+
| `disabled` | `boolean` | `false` | Disables the whole calendar. Date matchers aren't supported. |
|
|
145
|
+
| `min` / `max` | `number` | | `multiple` mode: fewest and most dates; `range` mode: shortest and longest range, in days. |
|
|
146
|
+
| `weekStartsOn` | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6` | from `locale` | First day of the week; `0` is Sunday. |
|
|
147
|
+
| `locale` | react-day-picker locale | en-US | Weekday names and day labels. The month Select stays in English. |
|
|
148
|
+
| `...props` | react-day-picker `DayPicker` props | | Passed through, for example `footer`, `fixedWeeks`, `aria-labelledby`. `className` and `classNames` are overwritten, and `components.MonthCaption` is replaced. |
|
|
149
|
+
<!-- api:end -->
|
|
150
|
+
|
|
151
|
+
## 13. Examples
|
|
152
|
+
|
|
153
|
+
```tsx
|
|
154
|
+
import * as React from "react";
|
|
155
|
+
import { Calendar, Card, CardContent, CardHeader, CardTitle, Typography } from "@eluan/core";
|
|
156
|
+
|
|
157
|
+
export function DeliveryDayCard() {
|
|
158
|
+
const [day, setDay] = React.useState<Date | undefined>();
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<div style={{ width: "fit-content" }}>
|
|
162
|
+
<Card>
|
|
163
|
+
<CardHeader>
|
|
164
|
+
<CardTitle id="delivery-day-title">Delivery day</CardTitle>
|
|
165
|
+
</CardHeader>
|
|
166
|
+
<CardContent>
|
|
167
|
+
<div role="group" aria-labelledby="delivery-day-title">
|
|
168
|
+
<Calendar mode="single" required selected={day} onSelect={setDay} />
|
|
169
|
+
</div>
|
|
170
|
+
<Typography variant="caption" tone="muted" aria-live="polite">
|
|
171
|
+
{day
|
|
172
|
+
? `Arrives ${day.toLocaleDateString(undefined, { weekday: "long", day: "numeric", month: "long" })}`
|
|
173
|
+
: "Pick a day to see when your order arrives."}
|
|
174
|
+
</Typography>
|
|
175
|
+
</CardContent>
|
|
176
|
+
</Card>
|
|
177
|
+
</div>
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## 14. Related components
|
|
183
|
+
|
|
184
|
+
- [DatePicker](./date-picker.md): Calendar in a Popover behind a field-style trigger; also covers DateRangePicker.
|
|
185
|
+
- [DateTimePicker](./date-time-picker.md): Calendar plus a TimeInput in one Popover.
|
|
186
|
+
- [Popover](./popover.md): the surface to use if you build your own calendar popover.
|
|
187
|
+
- [Select](./select.md): the caption's month and year controls.
|
|
188
|
+
- [Card](./card.md): a surface for an inline calendar.
|
|
189
|
+
|
|
190
|
+
## 15. Common agent mistakes
|
|
191
|
+
|
|
192
|
+
_Filled from evals._
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Card
|
|
3
|
+
use_when: Grouping content about one item or topic on its own surface, such as a project, a plan or a settings group.
|
|
4
|
+
instead_of: Table for items compared across the same attributes; Fieldset for a group of form fields; Dialog or Sheet for content over the page.
|
|
5
|
+
source: packages/core/src/components/card.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Card
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
Card is a bordered surface that groups content about one thing. It renders a `<div>` with optional header, content and footer parts, and takes an `elevation` (shadow depth) and a `clickable` flag. It's the only component with its own elevation prop; see [elevation.md](../foundations/elevation.md).
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- Items that stand alone and are browsed in a grid: projects, articles, integrations.
|
|
17
|
+
- A few plans or options side by side, one of them recommended (pricing).
|
|
18
|
+
- A settings group or summary block inside a page section.
|
|
19
|
+
- A surface that must lift off a busy background (`elevation="sm"` or `"md"`).
|
|
20
|
+
|
|
21
|
+
### When not to use
|
|
22
|
+
|
|
23
|
+
- Items compared across the same attributes (users, invoices, line items) → use [Table](./table.md).
|
|
24
|
+
- A group of related form fields with a legend → use [Fieldset](./fieldset.md).
|
|
25
|
+
- Content that floats over the page or blocks it → use [Popover](./popover.md), [Dialog](./dialog.md) or [Sheet](./sheet.md).
|
|
26
|
+
- Long secondary content the user may skip → use [Accordion](./accordion.md).
|
|
27
|
+
- Dividing sections inside one card → use [Separator](./separator.md) or headings, never a nested Card.
|
|
28
|
+
|
|
29
|
+
## 3. Anatomy
|
|
30
|
+
|
|
31
|
+
1. **Card**: the container. Background `--container-bg`, 1px border, `--curves-lg` corners, shadow from `elevation`.
|
|
32
|
+
2. **CardHeader** (optional): a column holding the title and description, padded `--spacing-2xl` on all sides.
|
|
33
|
+
3. **CardTitle** (optional): the card's heading text, `--font-size-xl` at weight 600. Renders a `<div>`, not a heading element (see Accessibility).
|
|
34
|
+
4. **CardDescription** (optional): muted supporting text under the title, `--font-size-sm`.
|
|
35
|
+
5. **CardContent**: the body. Padded `--spacing-2xl` on the sides and bottom; no top padding, so it sits under the header (see Rules 3 for cards without one).
|
|
36
|
+
6. **CardFooter** (optional): a row for actions, padded like CardContent. It has no gap between children.
|
|
37
|
+
|
|
38
|
+
## 4. Variants
|
|
39
|
+
|
|
40
|
+
Card has no `variant` prop. Its look comes from `elevation` and `clickable`.
|
|
41
|
+
|
|
42
|
+
| Elevation | Use for |
|
|
43
|
+
| --- | --- |
|
|
44
|
+
| `none` | Flat layouts where the border alone separates the card: settings groups, cards on a plain page. |
|
|
45
|
+
| `sm` (default) | Most cards. A slight lift off the page. |
|
|
46
|
+
| `md` | A card that must stand out from a busy background, or the recommended option in a row. |
|
|
47
|
+
| `lg` | Rare. A single prominent card on an otherwise empty area. |
|
|
48
|
+
|
|
49
|
+
`clickable` makes the whole card respond to hover: a deeper shadow, a 1px lift and a pointer cursor. It adds no role, focus or keyboard handling (see Rules and Accessibility).
|
|
50
|
+
|
|
51
|
+
## 5. Sizes
|
|
52
|
+
|
|
53
|
+
Card has no size prop. It fills the width of its parent; set width or grid placement on a wrapper you own. Inner padding is fixed at `--spacing-2xl`, which scales with density.
|
|
54
|
+
|
|
55
|
+
## 6. States
|
|
56
|
+
|
|
57
|
+
| State | Looks like | Notes |
|
|
58
|
+
| --- | --- | --- |
|
|
59
|
+
| Default | `--container-bg` surface, border, shadow from `elevation` | Shadows are hardcoded black at low opacity, so raised cards barely show depth in dim and dark modes. Use `elevation="none"` with the border where depth must read in every mode. |
|
|
60
|
+
| Hover | `clickable` only: deeper shadow and a 1px upward lift | Non-clickable cards don't react. |
|
|
61
|
+
| Focus | No focus style of its own | A Card is only focusable if you add `tabIndex`; then the browser's default ring shows. Never remove or restyle the focus ring. |
|
|
62
|
+
| Active | `clickable` only: shadow drops back to `md`, lift resets | |
|
|
63
|
+
|
|
64
|
+
## 7. Content guidelines
|
|
65
|
+
|
|
66
|
+
- Give each card a short title that names the item: "Pro", "Billing contact", "Q3 roadmap".
|
|
67
|
+
- Keep the description to one sentence that says what the card is for or what changed.
|
|
68
|
+
- Use sentence case for titles and descriptions. Don't end titles with punctuation.
|
|
69
|
+
- Keep cards in a grid parallel: same parts, same order, similar length.
|
|
70
|
+
- Put at most one primary Button in a card, in the footer.
|
|
71
|
+
|
|
72
|
+
| Do | Don't |
|
|
73
|
+
| --- | --- |
|
|
74
|
+
| Pro | Our amazing Pro plan! |
|
|
75
|
+
| Manage how you receive notifications. | This card lets you manage your notification settings below. |
|
|
76
|
+
| Team members | Members of your team that you have invited |
|
|
77
|
+
|
|
78
|
+
## 8. Rules
|
|
79
|
+
|
|
80
|
+
1. Don't nest a Card inside a Card. Divide a card with [Separator](./separator.md) or headings.
|
|
81
|
+
2. Never add `box-shadow` to a card or a wrapper; choose an `elevation` instead.
|
|
82
|
+
3. Don't add padding around card parts; they already pad with `--spacing-2xl`. The exception: CardContent has no top padding, so a card without a CardHeader starts flush with its top border. Start cards with a CardHeader, or give your own element inside CardContent `paddingTop: "var(--spacing-2xl)"`.
|
|
83
|
+
4. CardFooter has no gap. Put two or more actions in a wrapper with `display: flex` and a `--spacing-*` gap, or use one `fullWidth` Button.
|
|
84
|
+
5. Use one `default` (primary) Button per card. In a row of plan cards, only the recommended card gets the primary Button; the others use `outline`.
|
|
85
|
+
6. Don't set `clickable` on a card that contains its own Buttons or links; nested interactive elements inside a clickable surface conflict.
|
|
86
|
+
7. If the whole card must be clickable, give it `role`, `tabIndex={0}`, an `aria-label`, and handle Enter and Space in `onKeyDown`. Prefer a Button or link inside a non-clickable card.
|
|
87
|
+
8. Never pass `className` or `style`; they're dropped. Size and place cards with a wrapper or a grid parent.
|
|
88
|
+
|
|
89
|
+
## 9. Dos and don'ts
|
|
90
|
+
|
|
91
|
+
**Do:** space footer actions with a wrapper.
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
<CardFooter>
|
|
95
|
+
<div style={{ display: "flex", gap: "var(--spacing-sm)", justifyContent: "flex-end", width: "100%" }}>
|
|
96
|
+
<Button type="button" variant="outline">Cancel</Button>
|
|
97
|
+
<Button type="submit">Save changes</Button>
|
|
98
|
+
</div>
|
|
99
|
+
</CardFooter>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Don't:** drop Buttons straight into CardFooter; they touch.
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
<CardFooter>
|
|
106
|
+
<Button variant="outline">Cancel</Button>
|
|
107
|
+
<Button>Save changes</Button>
|
|
108
|
+
</CardFooter>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Do:** get depth from `elevation`.
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
<Card elevation="md">
|
|
115
|
+
<CardHeader>
|
|
116
|
+
<CardTitle>Quarterly revenue</CardTitle>
|
|
117
|
+
<CardDescription>Up 12% on last quarter.</CardDescription>
|
|
118
|
+
</CardHeader>
|
|
119
|
+
</Card>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Don't:** add a shadow or restyle the card.
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
<Card style={{ boxShadow: "0 8px 24px rgba(0, 0, 0, 0.2)", padding: 32 }}>
|
|
126
|
+
<CardContent>Quarterly revenue is up 12% on last quarter.</CardContent>
|
|
127
|
+
</Card>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Do:** divide one card with a Separator.
|
|
131
|
+
|
|
132
|
+
```tsx
|
|
133
|
+
<Card elevation="none">
|
|
134
|
+
<CardHeader>
|
|
135
|
+
<CardTitle>Email</CardTitle>
|
|
136
|
+
</CardHeader>
|
|
137
|
+
<CardContent>
|
|
138
|
+
<p>Product updates</p>
|
|
139
|
+
<Separator />
|
|
140
|
+
<p>Weekly digest</p>
|
|
141
|
+
</CardContent>
|
|
142
|
+
</Card>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Don't:** nest cards.
|
|
146
|
+
|
|
147
|
+
```tsx
|
|
148
|
+
<Card>
|
|
149
|
+
<CardContent>
|
|
150
|
+
<Card><CardContent>Product updates</CardContent></Card>
|
|
151
|
+
<Card><CardContent>Weekly digest</CardContent></Card>
|
|
152
|
+
</CardContent>
|
|
153
|
+
</Card>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## 10. Accessibility
|
|
157
|
+
|
|
158
|
+
- Role: none by default (a plain `<div>`). Add `role="article"` or `role="group"` with an `aria-label` when a card is a self-contained item in a list, as the tests do.
|
|
159
|
+
- Label: CardTitle renders a `<div>`, so it isn't a heading and doesn't name the card. When the title belongs in the page outline, pass `role="heading"` and an `aria-level` that fits (for example `aria-level={3}` under an `h2` section).
|
|
160
|
+
- Keyboard: Card itself isn't focusable. Its Buttons, links and inputs are reached with Tab. A `clickable` card is not reachable by keyboard unless you add `tabIndex={0}` and Enter/Space handling (Rules 7).
|
|
161
|
+
- Focus: Card declares no focus style; a focusable card shows the browser's default ring. Don't add or remove one.
|
|
162
|
+
- Contrast: handled by the theme. Don't override colours.
|
|
163
|
+
|
|
164
|
+
## 11. Behaviour
|
|
165
|
+
|
|
166
|
+
- Responsive: Card fills its parent's width. Lay cards out with a grid or flex wrapper and a `--spacing-lg` gap (page-layout.md), and drop to one column on narrow screens in your own stylesheet.
|
|
167
|
+
- Overflow and truncation: content wraps; nothing is clipped or truncated. Keep titles short.
|
|
168
|
+
- Motion: `clickable` cards animate shadow and lift over 200ms. Don't add your own transitions.
|
|
169
|
+
|
|
170
|
+
## 12. API
|
|
171
|
+
|
|
172
|
+
<!-- api:start -->
|
|
173
|
+
### Card
|
|
174
|
+
|
|
175
|
+
| Prop | Type | Default | Description |
|
|
176
|
+
| --- | --- | --- | --- |
|
|
177
|
+
| `elevation` | `"none" \| "sm" \| "md" \| "lg"` | `"sm"` | Shadow depth. |
|
|
178
|
+
| `clickable` | `boolean` | `false` | Adds a hover shadow, lift and pointer cursor. Adds no role, focus or keyboard handling. |
|
|
179
|
+
| `...props` | `HTMLAttributes<HTMLDivElement>` without `className`, `style` | | Native div attributes: `role`, `aria-*`, `onClick`, `tabIndex`, `onKeyDown`. |
|
|
180
|
+
|
|
181
|
+
### CardHeader, CardTitle, CardDescription, CardContent, CardFooter
|
|
182
|
+
|
|
183
|
+
| Prop | Type | Default | Description |
|
|
184
|
+
| --- | --- | --- | --- |
|
|
185
|
+
| `children` | `ReactNode` | | The part's content. |
|
|
186
|
+
| `...props` | `HTMLAttributes<HTMLDivElement>` without `className`, `style` | | Native div attributes. Each part renders a `<div>`; pass `role="heading"` and `aria-level` to CardTitle for heading semantics. |
|
|
187
|
+
<!-- api:end -->
|
|
188
|
+
|
|
189
|
+
## 13. Examples
|
|
190
|
+
|
|
191
|
+
Three plans, the middle one recommended (eval t06). Each plan stands alone, so they're Cards; only the recommended plan gets the primary Button.
|
|
192
|
+
|
|
193
|
+
```tsx
|
|
194
|
+
import {
|
|
195
|
+
Badge,
|
|
196
|
+
Button,
|
|
197
|
+
Card,
|
|
198
|
+
CardContent,
|
|
199
|
+
CardDescription,
|
|
200
|
+
CardFooter,
|
|
201
|
+
CardHeader,
|
|
202
|
+
CardTitle,
|
|
203
|
+
Typography,
|
|
204
|
+
} from "@eluan/core";
|
|
205
|
+
|
|
206
|
+
const plans = [
|
|
207
|
+
{ name: "Starter", price: "$0", description: "For trying things out.", features: ["1 project", "Community support"], recommended: false },
|
|
208
|
+
{ name: "Pro", price: "$24", description: "For small teams shipping every week.", features: ["Unlimited projects", "Email support", "Audit log"], recommended: true },
|
|
209
|
+
{ name: "Business", price: "$79", description: "For teams with security reviews.", features: ["SSO", "Priority support", "99.9% uptime SLA"], recommended: false },
|
|
210
|
+
];
|
|
211
|
+
|
|
212
|
+
export function PricingPlans() {
|
|
213
|
+
return (
|
|
214
|
+
<section style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-md)" }}>
|
|
215
|
+
<Typography variant="heading" as="h2">Choose a plan</Typography>
|
|
216
|
+
<div
|
|
217
|
+
style={{
|
|
218
|
+
display: "grid",
|
|
219
|
+
gridTemplateColumns: "repeat(3, minmax(0, 1fr))",
|
|
220
|
+
gap: "var(--spacing-lg)",
|
|
221
|
+
alignItems: "stretch",
|
|
222
|
+
}}
|
|
223
|
+
>
|
|
224
|
+
{plans.map((plan) => (
|
|
225
|
+
<Card key={plan.name} role="article" aria-label={`${plan.name} plan`} elevation={plan.recommended ? "md" : "sm"}>
|
|
226
|
+
<CardHeader>
|
|
227
|
+
<div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", gap: "var(--spacing-sm)" }}>
|
|
228
|
+
<CardTitle role="heading" aria-level={3}>{plan.name}</CardTitle>
|
|
229
|
+
{plan.recommended && <Badge variant="informative">Recommended</Badge>}
|
|
230
|
+
</div>
|
|
231
|
+
<CardDescription>{plan.description}</CardDescription>
|
|
232
|
+
</CardHeader>
|
|
233
|
+
<CardContent>
|
|
234
|
+
<Typography variant="title" as="p">
|
|
235
|
+
{plan.price}
|
|
236
|
+
<Typography variant="caption" tone="muted"> per user / month</Typography>
|
|
237
|
+
</Typography>
|
|
238
|
+
<ul style={{ margin: 0, paddingInlineStart: "var(--spacing-xl)", display: "flex", flexDirection: "column", gap: "var(--spacing-xs)" }}>
|
|
239
|
+
{plan.features.map((feature) => (
|
|
240
|
+
<li key={feature}>
|
|
241
|
+
<Typography variant="body" as="span">{feature}</Typography>
|
|
242
|
+
</li>
|
|
243
|
+
))}
|
|
244
|
+
</ul>
|
|
245
|
+
</CardContent>
|
|
246
|
+
<CardFooter>
|
|
247
|
+
<Button type="button" variant={plan.recommended ? "default" : "outline"} fullWidth>
|
|
248
|
+
Choose {plan.name}
|
|
249
|
+
</Button>
|
|
250
|
+
</CardFooter>
|
|
251
|
+
</Card>
|
|
252
|
+
))}
|
|
253
|
+
</div>
|
|
254
|
+
</section>
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## 14. Related components
|
|
260
|
+
|
|
261
|
+
- [Table](./table.md): compare items across the same columns instead of browsing them.
|
|
262
|
+
- [Separator](./separator.md): divide sections inside one card.
|
|
263
|
+
- [Button](./button.md): card actions, one primary per card.
|
|
264
|
+
- [Badge](./badge.md): a status or "Recommended" marker in the header.
|
|
265
|
+
- [Typography](./typography.md): headings and text inside CardContent.
|
|
266
|
+
- [Carousel](./carousel.md): a scrolling row of cards.
|
|
267
|
+
|
|
268
|
+
## 15. Common agent mistakes
|
|
269
|
+
|
|
270
|
+
_Filled from evals._
|