@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,202 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Textarea
|
|
3
|
+
use_when: The user writes free text that can run past one line: a message, description, note or comment.
|
|
4
|
+
instead_of: Input for single-line values; RichText when the text needs formatting such as bold, lists or links.
|
|
5
|
+
source: packages/core/src/components/textarea.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Textarea
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
Textarea is a multi-line text field. It renders a native `<textarea>` at full width with a minimum height, keeps the browser's resize handle, and takes only native textarea attributes.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- Messages, descriptions, notes, comments and feedback.
|
|
17
|
+
- Any free-text answer that may need more than one line.
|
|
18
|
+
|
|
19
|
+
### When not to use
|
|
20
|
+
|
|
21
|
+
- A single-line value (name, title, URL) → use [Input](./input.md).
|
|
22
|
+
- Text that needs formatting, headings, lists or links → use [RichText](./rich-text.md).
|
|
23
|
+
- One value from a known set → use [Select](./select.md) or [RadioGroup](./radio-group.md).
|
|
24
|
+
|
|
25
|
+
## 3. Anatomy
|
|
26
|
+
|
|
27
|
+
1. **Field**: the native `<textarea>`. `--container-bg` fill, 1px `--interactive-border-alt` border, `--curves-md` radius, `--spacing-sm` block and `--spacing-md` inline padding.
|
|
28
|
+
2. **Placeholder** (optional): text in `--interactive-fg-alt`.
|
|
29
|
+
3. **Resize handle**: the browser's own. Source sets no `resize` rule, so users can drag the field larger.
|
|
30
|
+
|
|
31
|
+
## 4. Variants
|
|
32
|
+
|
|
33
|
+
Textarea has no `variant` prop and no validation tone. It always draws the same field.
|
|
34
|
+
|
|
35
|
+
## 5. Sizes
|
|
36
|
+
|
|
37
|
+
Textarea has no `size` prop. Width fills the container; the starting height comes from the native `rows` attribute, with a minimum of 80px. Text is `--font-size-base` on narrow screens and `--font-size-sm` from a 768px viewport up.
|
|
38
|
+
|
|
39
|
+
## 6. States
|
|
40
|
+
|
|
41
|
+
| State | Looks like | Notes |
|
|
42
|
+
| --- | --- | --- |
|
|
43
|
+
| Default | `--container-bg` fill, `--interactive-border-alt` border | Text colour isn't set, so it inherits from the parent. |
|
|
44
|
+
| Focus | 1px outline in `--focus-ring`, 1px offset; the border doesn't change | Never remove or restyle the focus ring. |
|
|
45
|
+
| Disabled | `--interactive-bg-disabled` fill, `--interactive-fg-disabled` text, not-allowed cursor | Set `disabled` on the Label too. |
|
|
46
|
+
| Error | No error style: `aria-invalid` changes nothing visually | Set `aria-invalid={true}` for assistive tech and show a FormMessage under the field. |
|
|
47
|
+
|
|
48
|
+
There's no hover style.
|
|
49
|
+
|
|
50
|
+
## 7. Content guidelines
|
|
51
|
+
|
|
52
|
+
- Label the field with what to write: "Your message", "Describe the issue".
|
|
53
|
+
- Use the placeholder for a prompt or example, not for instructions the user needs while typing.
|
|
54
|
+
- Say where the text goes in a FormDescription: "Your message will be copied to the support team."
|
|
55
|
+
- State any length limit in the FormDescription before the user hits it.
|
|
56
|
+
|
|
57
|
+
| Do | Don't |
|
|
58
|
+
| --- | --- |
|
|
59
|
+
| Label "Describe the issue", description "Include the steps that led to it." | Placeholder "Describe the issue, include steps, max 500 characters" with no label |
|
|
60
|
+
| Description "Up to 500 characters." | Silently cutting text off at the limit |
|
|
61
|
+
|
|
62
|
+
## 8. Rules
|
|
63
|
+
|
|
64
|
+
1. Give every Textarea a visible Label whose `htmlFor` matches its `id`, or `aria-label` when there's no visible label.
|
|
65
|
+
2. Read the value with the native `onChange` event. Textarea has no `onValueChange`.
|
|
66
|
+
3. Set the starting height with `rows`; it passes straight to the native element.
|
|
67
|
+
4. Show errors with a FormMessage linked by `aria-describedby`, plus `aria-invalid={true}`. Don't fake a red border; Textarea has none.
|
|
68
|
+
5. Don't override the font size or colours.
|
|
69
|
+
6. Never pass `className` or `style`; they're dropped. Set width on a wrapper.
|
|
70
|
+
|
|
71
|
+
## 9. Dos and don'ts
|
|
72
|
+
|
|
73
|
+
**Do:** label the field and link its helper text.
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-sm)" }}>
|
|
77
|
+
<Label htmlFor="support-message">Your message</Label>
|
|
78
|
+
<Textarea id="support-message" rows={5} aria-describedby="support-message-hint" />
|
|
79
|
+
<FormDescription id="support-message-hint">
|
|
80
|
+
Your message will be copied to the support team.
|
|
81
|
+
</FormDescription>
|
|
82
|
+
</div>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Don't:** rely on the placeholder alone.
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
<Textarea placeholder="Your message (it will be copied to support)" />
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Do:** show an error with FormMessage.
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
<Textarea id="cancel-reason" aria-invalid={true} aria-describedby="cancel-reason-error" />
|
|
95
|
+
<FormMessage id="cancel-reason-error">Tell us why you're cancelling</FormMessage>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Don't:** draw your own error border around it.
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
<div style={{ border: "1px solid red", borderRadius: 8 }}>
|
|
102
|
+
<Textarea />
|
|
103
|
+
</div>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## 10. Accessibility
|
|
107
|
+
|
|
108
|
+
- Role: `textbox` (native `<textarea>`, multi-line).
|
|
109
|
+
- Label: a Label with `htmlFor` matching the Textarea `id`, or `aria-label`. Link helper text and errors with `aria-describedby`.
|
|
110
|
+
- Keyboard: native text editing. Enter inserts a new line; it doesn't submit the form. Tab leaves the field.
|
|
111
|
+
- Focus: visible outline on `:focus-visible`. Disabled fields use the native `disabled` attribute and are skipped by Tab.
|
|
112
|
+
- Contrast: handled by the theme. Don't override colours.
|
|
113
|
+
|
|
114
|
+
## 11. Behaviour
|
|
115
|
+
|
|
116
|
+
- Responsive: `width: 100%`; constrain it with a wrapper. The font size steps down at 768px (see Sizes).
|
|
117
|
+
- Overflow and truncation: text wraps and scrolls vertically once it passes the field's height. The field doesn't grow with its content.
|
|
118
|
+
- Resize: users can drag the browser's handle to enlarge the field.
|
|
119
|
+
- Motion: none.
|
|
120
|
+
|
|
121
|
+
## 12. API
|
|
122
|
+
|
|
123
|
+
<!-- api:start -->
|
|
124
|
+
| Prop | Type | Default | Description |
|
|
125
|
+
| --- | --- | --- | --- |
|
|
126
|
+
| `rows` | `number` | browser default | Visible lines. The 80px minimum height still applies. |
|
|
127
|
+
| `value` | `string` | | Controlled value. |
|
|
128
|
+
| `defaultValue` | `string` | | Uncontrolled starting value. |
|
|
129
|
+
| `onChange` | `ChangeEventHandler<HTMLTextAreaElement>` | | Native change event. |
|
|
130
|
+
| `placeholder` | `string` | | Prompt or example text. |
|
|
131
|
+
| `maxLength` | `number` | | Native character limit. |
|
|
132
|
+
| `disabled` | `boolean` | `false` | Disables the field. |
|
|
133
|
+
| `...props` | `ComponentProps<"textarea">` without `className`, `style` | | Native attributes: `id`, `name`, `required`, `readOnly`, `aria-*`. `ref` goes to the `<textarea>`. |
|
|
134
|
+
<!-- api:end -->
|
|
135
|
+
|
|
136
|
+
## 13. Examples
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
import { Button, FormDescription, FormMessage, Label, Textarea } from "@eluan/core";
|
|
140
|
+
import * as React from "react";
|
|
141
|
+
|
|
142
|
+
const MAX_LENGTH = 500;
|
|
143
|
+
|
|
144
|
+
export function FeedbackForm({ onSend }: { onSend: (message: string) => void }) {
|
|
145
|
+
const [message, setMessage] = React.useState("");
|
|
146
|
+
const [error, setError] = React.useState<string | null>(null);
|
|
147
|
+
|
|
148
|
+
function handleSubmit(event: React.FormEvent) {
|
|
149
|
+
event.preventDefault();
|
|
150
|
+
if (!message.trim()) {
|
|
151
|
+
setError("Write a message before sending");
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
onSend(message);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return (
|
|
158
|
+
<form
|
|
159
|
+
onSubmit={handleSubmit}
|
|
160
|
+
style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-lg)" }}
|
|
161
|
+
>
|
|
162
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-sm)" }}>
|
|
163
|
+
<Label htmlFor="feedback" required>Your feedback</Label>
|
|
164
|
+
<Textarea
|
|
165
|
+
id="feedback"
|
|
166
|
+
name="feedback"
|
|
167
|
+
rows={6}
|
|
168
|
+
required
|
|
169
|
+
maxLength={MAX_LENGTH}
|
|
170
|
+
placeholder="What worked, and what got in your way?"
|
|
171
|
+
value={message}
|
|
172
|
+
onChange={(event) => {
|
|
173
|
+
setMessage(event.target.value);
|
|
174
|
+
setError(null);
|
|
175
|
+
}}
|
|
176
|
+
aria-invalid={error ? true : undefined}
|
|
177
|
+
aria-describedby={error ? "feedback-hint feedback-error" : "feedback-hint"}
|
|
178
|
+
/>
|
|
179
|
+
<FormDescription id="feedback-hint">
|
|
180
|
+
{message.length} of {MAX_LENGTH} characters. Our product team reads every message.
|
|
181
|
+
</FormDescription>
|
|
182
|
+
{error && <FormMessage id="feedback-error">{error}</FormMessage>}
|
|
183
|
+
</div>
|
|
184
|
+
<div style={{ display: "flex", justifyContent: "flex-end" }}>
|
|
185
|
+
<Button type="submit">Send feedback</Button>
|
|
186
|
+
</div>
|
|
187
|
+
</form>
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## 14. Related components
|
|
193
|
+
|
|
194
|
+
- [Input](./input.md): the single-line field.
|
|
195
|
+
- [Label](./form-label.md): Label, FormDescription and FormMessage around the field.
|
|
196
|
+
- [RichText](./rich-text.md): an editor for formatted text.
|
|
197
|
+
- [Fieldset](./fieldset.md): groups the field with related ones.
|
|
198
|
+
- See [../patterns/forms.md](../patterns/forms.md) for form layout and validation.
|
|
199
|
+
|
|
200
|
+
## 15. Common agent mistakes
|
|
201
|
+
|
|
202
|
+
_Filled from evals._
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: TimeInput
|
|
3
|
+
use_when: The user enters a time of day with no date, such as opening hours or a daily reminder.
|
|
4
|
+
instead_of: Input type=time or a Select of times; DateTimePicker when a date is needed too.
|
|
5
|
+
source: packages/core/src/components/time-input.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# TimeInput
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
TimeInput is a segmented time field: separate hours and minutes inputs, an optional seconds input, and AM/PM toggles in 12-hour mode. Its value is a string such as `"14:30"` or `"02:30 PM"`. DateTimePicker uses it for its time row.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- A time of day on its own: opening hours, quiet hours, a daily digest time, a recurring reminder.
|
|
17
|
+
- The time half of a composed control, next to an inline [Calendar](./calendar.md).
|
|
18
|
+
|
|
19
|
+
### When not to use
|
|
20
|
+
|
|
21
|
+
- One moment with a date → use [DateTimePicker](./date-time-picker.md).
|
|
22
|
+
- A date only → use [DatePicker](./date-picker.md).
|
|
23
|
+
- A duration or count (minutes of a call, number of hours) → use [NumberInput](./number-input.md).
|
|
24
|
+
- Choosing from a few fixed slots (9:00, 9:30, 10:00) → use [Select](./select.md) or [SegmentedControl](./segmented-control.md).
|
|
25
|
+
|
|
26
|
+
## 3. Anatomy
|
|
27
|
+
|
|
28
|
+
1. **Field**: the bordered container, `--size-lg` tall, with `--curves-md` corners.
|
|
29
|
+
2. **Clock icon** (optional): leading, in `--interactive-fg-alt`. Hide it with `showIcon={false}`.
|
|
30
|
+
3. **Segments**: hours, minutes and optional seconds inputs in `--font-mono` with tabular figures, separated by colons.
|
|
31
|
+
4. **Period toggles** (12-hour only): AM and PM Toggles behind a hairline divider.
|
|
32
|
+
|
|
33
|
+
## 4. Variants
|
|
34
|
+
|
|
35
|
+
TimeInput has no `variant` prop. `timeInputVariants` is exported for compatibility and returns an empty string. `format` and `showSeconds` decide the segments:
|
|
36
|
+
|
|
37
|
+
| Props | Segments | Value |
|
|
38
|
+
| --- | --- | --- |
|
|
39
|
+
| `format="24"` (default) | Hours (0 to 23), minutes | `"14:30"` |
|
|
40
|
+
| `format="12"` | Hours (1 to 12), minutes, AM/PM | `"02:30 PM"` |
|
|
41
|
+
| `showSeconds` | Adds seconds | `"14:30:45"` or `"02:30:45 PM"` |
|
|
42
|
+
|
|
43
|
+
## 5. Sizes
|
|
44
|
+
|
|
45
|
+
`size` accepts only `"default"` and has no effect. The field is `--size-lg` tall, matching default Input and Button heights, and as wide as its segments.
|
|
46
|
+
|
|
47
|
+
## 6. States
|
|
48
|
+
|
|
49
|
+
| State | Looks like | Notes |
|
|
50
|
+
| --- | --- | --- |
|
|
51
|
+
| Default | `--interactive-border-alt` border, digits in `--interactive-fg` | |
|
|
52
|
+
| Focus | The focused segment fills with `--interactive-bg-hover`; the field gets a 1px outline in `--focus-ring`, 1px offset | Never remove or restyle the focus ring. The field's border darkens to `--focus-ring` too. |
|
|
53
|
+
| Empty | No empty state: an empty `value` shows 00:00 (24-hour) or 12:00 AM (12-hour) | `placeholder` is accepted and ignored. |
|
|
54
|
+
| Period | The active period is a pressed Toggle | 12-hour only. |
|
|
55
|
+
| Disabled | `--interactive-bg-disabled` fill, `--interactive-fg-disabled` text, no pointer events | Segments and toggles are disabled. |
|
|
56
|
+
| Error | No built-in error state | Put a FormMessage under the field and reference it with `aria-describedby` on TimeInput. |
|
|
57
|
+
|
|
58
|
+
## 7. Content guidelines
|
|
59
|
+
|
|
60
|
+
- Name what the time is for in the label: "Opens at", "Send digest at".
|
|
61
|
+
- Add the time zone to the label or hint when it isn't the user's own: "Quiet hours start (UTC)".
|
|
62
|
+
- Pass values in the shape `format` emits: `"HH:MM"` for 24-hour, `"HH:MM AM"` or `"HH:MM PM"` (with a space) for 12-hour, plus `":SS"` with `showSeconds`. In 12-hour mode a 24-hour string is also read and converted.
|
|
63
|
+
|
|
64
|
+
| Do | Don't |
|
|
65
|
+
| --- | --- |
|
|
66
|
+
| Opens at | Time |
|
|
67
|
+
| Send digest at | Enter a time |
|
|
68
|
+
|
|
69
|
+
## 8. Rules
|
|
70
|
+
|
|
71
|
+
1. Pass `value` and `onValueChange`, using the string shapes above.
|
|
72
|
+
2. Label it. TimeInput renders a `div`, which `Label htmlFor` can't target: pass `role="group"` and `aria-labelledby` pointing at the Label's `id`.
|
|
73
|
+
3. Don't use `placeholder`; it does nothing. TimeInput can't show "no time", so for an optional time pair it with a [Switch](./switch.md) or [Checkbox](./checkbox.md) ("Set a time") and render TimeInput only when it's on.
|
|
74
|
+
4. With `name`, a hidden input submits the displayed time, 00:00 included, even if the user never touched the field. Only render it when a time is meant to be sent.
|
|
75
|
+
5. Keep `format` and the value shape in step. `onValueChange` always emits the shape of the current `format`.
|
|
76
|
+
6. Never pass `className` or `style`; they're omitted. Use a wrapper for layout.
|
|
77
|
+
|
|
78
|
+
## 9. Dos and don'ts
|
|
79
|
+
|
|
80
|
+
**Do:** name the group and control the value.
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
<Label id="opens-at-label">Opens at</Label>
|
|
84
|
+
<TimeInput role="group" aria-labelledby="opens-at-label" value={opensAt} onValueChange={setOpensAt} />
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Don't:** rely on a placeholder or an unlabelled field.
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
<TimeInput placeholder="Opening time" />
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Do:** hide the field until an optional time is wanted.
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
<Switch id="set-reminder" checked={hasReminder} onCheckedChange={setHasReminder} />
|
|
97
|
+
<Label htmlFor="set-reminder">Remind me at a set time</Label>
|
|
98
|
+
{hasReminder && (
|
|
99
|
+
<TimeInput role="group" aria-label="Reminder time" name="reminderTime" value={time} onValueChange={setTime} />
|
|
100
|
+
)}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Don't:** treat 00:00 as "not set".
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
const hasTime = value !== "00:00";
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## 10. Accessibility
|
|
110
|
+
|
|
111
|
+
- Role: no role on the field by default; add `role="group"`. The segments are text inputs with `inputMode="numeric"`, named "Hours", "Minutes" and "Seconds". AM and PM are Toggle buttons with `aria-pressed`.
|
|
112
|
+
- Label: `aria-labelledby` on the field pointing at a visible Label, or `aria-label` when the context already shows the meaning.
|
|
113
|
+
- Keyboard: type digits; hours move on to minutes once two digits are typed, or one digit that can't start a two-digit hour. Up and Down step the focused segment and wrap. `:` jumps to the next segment. Tab moves through segments, then the AM and PM toggles; Enter or Space presses a toggle.
|
|
114
|
+
- Focus: a segment selects its digits on focus, so typing replaces them. Out-of-range numbers are clamped when the segment loses focus.
|
|
115
|
+
- Contrast: handled by the theme. Don't override colours.
|
|
116
|
+
|
|
117
|
+
## 11. Behaviour
|
|
118
|
+
|
|
119
|
+
- Responsive: TimeInput sizes to its content and doesn't stretch to the container. Align it to the start of its column.
|
|
120
|
+
- Updates: `onValueChange` fires on every valid digit, step and period change, not only on blur.
|
|
121
|
+
- Ranges: hours run 0 to 23 (24-hour) or 1 to 12 (12-hour); minutes and seconds 0 to 59.
|
|
122
|
+
- Motion: border and colour transitions over 150ms. Don't add your own.
|
|
123
|
+
|
|
124
|
+
## 12. API
|
|
125
|
+
|
|
126
|
+
<!-- api:start -->
|
|
127
|
+
| Prop | Type | Default | Description |
|
|
128
|
+
| --- | --- | --- | --- |
|
|
129
|
+
| `value` | `string` | `""` | `"HH:MM"`, `"HH:MM AM/PM"`, or with `:SS` when `showSeconds` is set. |
|
|
130
|
+
| `onValueChange` | `(value: string) => void` | | Called with the new time string. |
|
|
131
|
+
| `format` | `"12" \| "24"` | `"24"` | Clock format; `"12"` adds AM/PM toggles. |
|
|
132
|
+
| `showSeconds` | `boolean` | `false` | Adds a seconds segment. |
|
|
133
|
+
| `showIcon` | `boolean` | `true` | Shows the leading clock icon. |
|
|
134
|
+
| `disabled` | `boolean` | `false` | Disables segments and toggles. |
|
|
135
|
+
| `name` | `string` | | Renders a hidden input with the current time for native form submission. |
|
|
136
|
+
| `placeholder` | `string` | | Accepted and ignored. |
|
|
137
|
+
| `size` | `"default"` | | No effect. |
|
|
138
|
+
| `ref` | `Ref<HTMLDivElement>` | | Forwarded to the field `div`. |
|
|
139
|
+
| `...props` | `HTMLAttributes<HTMLDivElement>` without `className`, `style`, `onChange` | | Spread on the field: `role`, `aria-labelledby`, `aria-describedby`, `id`. |
|
|
140
|
+
<!-- api:end -->
|
|
141
|
+
|
|
142
|
+
`timeInputVariants()` returns `""`. Don't use it.
|
|
143
|
+
|
|
144
|
+
## 13. Examples
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
import * as React from "react";
|
|
148
|
+
import { FormDescription, Label, TimeInput } from "@eluan/core";
|
|
149
|
+
|
|
150
|
+
export function DigestTimeField() {
|
|
151
|
+
const [sendAt, setSendAt] = React.useState("08:00 AM");
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<div style={{ display: "flex", flexDirection: "column", alignItems: "flex-start", gap: "var(--spacing-sm)" }}>
|
|
155
|
+
<Label id="digest-time-label">Send digest at</Label>
|
|
156
|
+
<TimeInput
|
|
157
|
+
role="group"
|
|
158
|
+
aria-labelledby="digest-time-label"
|
|
159
|
+
aria-describedby="digest-time-hint"
|
|
160
|
+
format="12"
|
|
161
|
+
name="digestTime"
|
|
162
|
+
value={sendAt}
|
|
163
|
+
onValueChange={setSendAt}
|
|
164
|
+
/>
|
|
165
|
+
<FormDescription id="digest-time-hint">Sent every weekday in your local time.</FormDescription>
|
|
166
|
+
</div>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## 14. Related components
|
|
172
|
+
|
|
173
|
+
- [DateTimePicker](./date-time-picker.md): a date and a time in one control; it uses TimeInput for its time row.
|
|
174
|
+
- [DatePicker](./date-picker.md): the chooser for all date and time components.
|
|
175
|
+
- [Toggle](./toggle.md): the AM and PM controls.
|
|
176
|
+
- [Label](./form-label.md): the visible label; see also [forms](../patterns/forms.md).
|
|
177
|
+
- [Input](./input.md): for free text; don't use `type="time"`.
|
|
178
|
+
|
|
179
|
+
## 15. Common agent mistakes
|
|
180
|
+
|
|
181
|
+
_Filled from evals._
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Toast
|
|
3
|
+
use_when: Briefly confirming an action that just finished, such as "Settings saved"; mount Toast once, then call toast() from sonner.
|
|
4
|
+
instead_of: Banner for persistent, blocking or form-level messages; FormMessage for a single field; Dialog when the user must decide.
|
|
5
|
+
source: packages/core/src/components/toast.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Toast
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
Toast is the Sonner toaster with Eluan's styling applied. Render `<Toast />` once near the app root, then show a toast from anywhere by calling `toast()` from the `sonner` package. `@eluan/core` doesn't re-export `toast()`. Toasts are transient: they stack in a corner of the screen and close on their own after a few seconds.
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm add sonner
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 2. When to use
|
|
19
|
+
|
|
20
|
+
- Confirming an action that succeeded, especially when the result isn't visible where the user is: "Settings saved", "Invite sent".
|
|
21
|
+
- Offering a short undo after a reversible action, with an `action` button.
|
|
22
|
+
- Reporting the outcome of background work with `toast.promise()`.
|
|
23
|
+
|
|
24
|
+
### When not to use
|
|
25
|
+
|
|
26
|
+
- A form submit failed or the server rejected it → use [Banner](./banner.md) `variant="destructive"` `position="inline"` with `role="alert"`, at the top of the form.
|
|
27
|
+
- An account or page notice that must stay visible (trial ending, maintenance tonight) → use [Banner](./banner.md) `position="top"`.
|
|
28
|
+
- One field is invalid → use FormMessage from [Label](./form-label.md), under the field.
|
|
29
|
+
- The user must decide before continuing → use [Dialog](./dialog.md).
|
|
30
|
+
- The status of an item (Active, Failed) → use [Badge](./badge.md).
|
|
31
|
+
- Something is loading in place → use [Spinner](./spinner.md) or [Skeleton](./skeleton.md).
|
|
32
|
+
|
|
33
|
+
## 3. Anatomy
|
|
34
|
+
|
|
35
|
+
1. **Toaster**: the `<Toast />` mount. A fixed region at one corner of the viewport that stacks toasts.
|
|
36
|
+
2. **Toast**: one notification card. Neutral surface for `toast()`, tone surface for typed toasts.
|
|
37
|
+
3. **Icon**: Sonner's built-in icon for `success`, `info`, `warning`, `error` and `loading` toasts.
|
|
38
|
+
4. **Title**: the first argument to `toast()`.
|
|
39
|
+
5. **Description** (optional): the `description` option, under the title.
|
|
40
|
+
6. **Action** (optional): `action: { label, onClick }`, a trailing button in primary colours.
|
|
41
|
+
7. **Cancel** (optional): `cancel: { label, onClick }`, a trailing button in ghost colours.
|
|
42
|
+
|
|
43
|
+
## 4. Variants
|
|
44
|
+
|
|
45
|
+
`<Toast />` has no variant prop. Pick the look per call:
|
|
46
|
+
|
|
47
|
+
| Call | Looks like | Use for |
|
|
48
|
+
| --- | --- | --- |
|
|
49
|
+
| `toast()` | `--container-bg-alt` surface | Routine confirmation: "Settings saved". |
|
|
50
|
+
| `toast.success()` | `--positive-*` surface | A success worth emphasising: "Payment received". |
|
|
51
|
+
| `toast.info()` | `--informative-*` surface | A neutral heads-up about something that just happened. |
|
|
52
|
+
| `toast.warning()` | `--cautionary-*` surface | A completed action with a caveat: "Saved, but 2 rows were skipped". |
|
|
53
|
+
| `toast.error()` | `--destructive-*` surface | A background failure the user doesn't have to fix here: "Couldn't sync, retrying". |
|
|
54
|
+
| `toast.promise()` | Loading, then success or error | Async work the user started and keeps working through. |
|
|
55
|
+
|
|
56
|
+
## 5. Sizes
|
|
57
|
+
|
|
58
|
+
Toast has no size prop. The global stylesheet sets the text to `--font-size-sm`, padding to `--spacing-md` and corners to `--curves-md`. Width comes from Sonner.
|
|
59
|
+
|
|
60
|
+
## 6. States
|
|
61
|
+
|
|
62
|
+
| State | Looks like | Notes |
|
|
63
|
+
| --- | --- | --- |
|
|
64
|
+
| Default | Card in the corner set by `position` | Closes after 4 seconds (Sonner's default `duration`). The description is muted twice (a grey colour plus 80% opacity) and stays grey on tone surfaces; keep the essential words in the title and don't recolour it. |
|
|
65
|
+
| Hover | The stack expands and the timer pauses | Also pauses while the user interacts with a toast or the tab is hidden. |
|
|
66
|
+
| Focus | Sonner's own focus shadow on the toast and its buttons | Never remove or restyle the focus ring. |
|
|
67
|
+
| Loading | Sonner's spinner in the icon slot | `toast.loading()` or the loading step of `toast.promise()`. |
|
|
68
|
+
| Error | `--destructive-*` surface | `toast.error()`, or the error step of `toast.promise()`. |
|
|
69
|
+
|
|
70
|
+
## 7. Content guidelines
|
|
71
|
+
|
|
72
|
+
- Title: say what happened, in the past tense, in two to four words: "Settings saved", "Invite sent".
|
|
73
|
+
- Description: optional, one line that adds a useful detail: "We'll notify you when they accept."
|
|
74
|
+
- Action label: one verb for the one thing the user can do: "Undo", "View".
|
|
75
|
+
- Use sentence case. No exclamation marks.
|
|
76
|
+
|
|
77
|
+
| Do | Don't |
|
|
78
|
+
| --- | --- |
|
|
79
|
+
| Settings saved | Success! |
|
|
80
|
+
| Invite sent to Dana Lee | Your request has been processed successfully |
|
|
81
|
+
| Project archived, with an Undo action | Are you sure? (a toast can't ask a question) |
|
|
82
|
+
|
|
83
|
+
## 8. Rules
|
|
84
|
+
|
|
85
|
+
1. Mount exactly one `<Toast />`, near the app root. Sonner sends every `toast()` call to every mounted toaster, so a second mount shows each toast twice.
|
|
86
|
+
2. Import `toast` from `"sonner"` and add `sonner` to your own dependencies. Under pnpm, the copy inside `@eluan/core` isn't resolvable from your code. Keep it in the same range as `@eluan/core` (`^2.0.7`) so only one copy is installed.
|
|
87
|
+
3. Use a toast only for transient, non-blocking confirmation. Never put an error the user must act on in a toast; use an inline [Banner](./banner.md).
|
|
88
|
+
4. Don't pass `className`, `style` or `toastOptions` to `<Toast />`. They're spread last and replace Eluan's class hooks, so toasts lose their token styling. Set per-toast options in the `toast()` call, and the toaster-wide timeout with the top-level `duration` prop.
|
|
89
|
+
5. Don't make a toast the only place important information appears. It disappears; if a message must stay until dismissed, use a Banner instead of `duration: Infinity`.
|
|
90
|
+
6. Show one toast per event. Don't also show a Banner for the same thing.
|
|
91
|
+
|
|
92
|
+
## 9. Dos and don'ts
|
|
93
|
+
|
|
94
|
+
**Do:** mount once, then confirm a successful save.
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
// Root layout
|
|
98
|
+
<EluanProvider defaultTheme="minimal">
|
|
99
|
+
{children}
|
|
100
|
+
<Toast />
|
|
101
|
+
</EluanProvider>
|
|
102
|
+
|
|
103
|
+
// Anywhere
|
|
104
|
+
toast("Settings saved");
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Don't:** mount a toaster per page or report a failed form submit with a toast.
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
<SettingsPage>
|
|
111
|
+
<Toast />
|
|
112
|
+
</SettingsPage>
|
|
113
|
+
|
|
114
|
+
toast.error("Couldn't save. Check the highlighted fields.");
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Do:** offer undo for a reversible action.
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
toast("Project archived", {
|
|
121
|
+
action: { label: "Undo", onClick: () => restoreProject(projectId) },
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Don't:** restyle the toaster through props.
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
<Toast className="my-toasts" toastOptions={{ duration: 8000 }} />
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## 10. Accessibility
|
|
132
|
+
|
|
133
|
+
- Role: Sonner renders the toaster as a `<section>` live region (`aria-live="polite"`) holding a list; each toast is a list item that can take focus.
|
|
134
|
+
- Label: the region is named "Notifications alt+T" (from `containerAriaLabel` and `hotkey`). New toasts are announced politely; they don't interrupt.
|
|
135
|
+
- Keyboard: Alt+T moves focus into the toasts and expands the stack; Tab reaches each toast and its action and cancel buttons; Escape collapses the stack.
|
|
136
|
+
- Focus: a new toast never takes focus. When focus leaves the toaster, Sonner returns it to the element that had it before.
|
|
137
|
+
- Timing: the timer pauses on hover, while the stack is expanded and while the tab is hidden. Keep toasts short enough to read in the default 4 seconds; anything longer belongs in a Banner.
|
|
138
|
+
- Contrast: handled by the theme. Don't override colours. Toast focus indicators come from Sonner's stylesheet, not Eluan tokens.
|
|
139
|
+
|
|
140
|
+
## 11. Behaviour
|
|
141
|
+
|
|
142
|
+
- Position: bottom right by default; set `position` once on `<Toast />` (`"top-right"`, `"bottom-center"` and so on).
|
|
143
|
+
- Stacking: up to three toasts show at once (`visibleToasts`); older ones collapse behind the front toast until hovered.
|
|
144
|
+
- Responsive: below 600px wide, toasts span the width of the screen.
|
|
145
|
+
- Overflow and truncation: long words break anywhere; text wraps. Keep titles short instead.
|
|
146
|
+
- Motion: toasts slide in and out and can be swiped away. Sonner turns its transitions off under `prefers-reduced-motion`. Don't add your own.
|
|
147
|
+
- Styling lives entirely in `@eluan/core/styles.css` (raw CSS keyed on Sonner's data attributes), so that stylesheet must be imported at the app entry.
|
|
148
|
+
- `closeButton` renders Sonner's own close button, which Eluan's stylesheet doesn't theme.
|
|
149
|
+
|
|
150
|
+
## 12. API
|
|
151
|
+
|
|
152
|
+
`Toast` takes Sonner's `ToasterProps`. Unlike other Eluan components its type doesn't omit `className` and `style`, but passing them (or `toastOptions`) removes Eluan's styling; see Rules.
|
|
153
|
+
|
|
154
|
+
<!-- api:start -->
|
|
155
|
+
### Toast
|
|
156
|
+
|
|
157
|
+
| Prop | Type | Default | Description |
|
|
158
|
+
| --- | --- | --- | --- |
|
|
159
|
+
| `position` | `"top-left" \| "top-center" \| "top-right" \| "bottom-left" \| "bottom-center" \| "bottom-right"` | `"bottom-right"` | Corner the toasts stack in. |
|
|
160
|
+
| `duration` | `number` | `4000` | Milliseconds before each toast closes. |
|
|
161
|
+
| `visibleToasts` | `number` | `3` | How many toasts show before older ones collapse. |
|
|
162
|
+
| `expand` | `boolean` | `false` | Shows the stack expanded instead of collapsed. |
|
|
163
|
+
| `closeButton` | `boolean` | `false` | Adds Sonner's close button to every toast (not themed). |
|
|
164
|
+
| `hotkey` | `string[]` | `["altKey", "KeyT"]` | Keys that move focus to the toasts. |
|
|
165
|
+
| `containerAriaLabel` | `string` | `"Notifications"` | Accessible name of the toast region. |
|
|
166
|
+
| `offset` | `string \| number \| object` | Sonner default | Distance from the viewport edges. |
|
|
167
|
+
| `...props` | Sonner `ToasterProps` | | `dir`, `gap`, `icons`, `swipeDirections`, `mobileOffset`. Don't pass `className`, `style` or `toastOptions`. |
|
|
168
|
+
|
|
169
|
+
### toast() options
|
|
170
|
+
|
|
171
|
+
Second argument to `toast()`, `toast.success()` and the other calls, imported from `"sonner"`.
|
|
172
|
+
|
|
173
|
+
| Prop | Type | Default | Description |
|
|
174
|
+
| --- | --- | --- | --- |
|
|
175
|
+
| `description` | `ReactNode` | | One line under the title. |
|
|
176
|
+
| `action` | `{ label: ReactNode; onClick: (event) => void }` | | Trailing primary button, such as Undo. |
|
|
177
|
+
| `cancel` | `{ label: ReactNode; onClick: (event) => void }` | | Trailing ghost button. |
|
|
178
|
+
| `duration` | `number` | Toaster's `duration` | Milliseconds for this toast. |
|
|
179
|
+
| `id` | `string \| number` | generated | Reuse an id to update a toast in place. |
|
|
180
|
+
| `onDismiss` | `(toast) => void` | | Called when the user dismisses the toast. |
|
|
181
|
+
| `onAutoClose` | `(toast) => void` | | Called when the timer closes the toast. |
|
|
182
|
+
<!-- api:end -->
|
|
183
|
+
|
|
184
|
+
## 13. Examples
|
|
185
|
+
|
|
186
|
+
```tsx
|
|
187
|
+
import { useState } from "react";
|
|
188
|
+
import { Banner, Button, EluanProvider, Label, Switch, Toast } from "@eluan/core";
|
|
189
|
+
import { toast } from "sonner";
|
|
190
|
+
|
|
191
|
+
export function App({ children }: { children: React.ReactNode }) {
|
|
192
|
+
return (
|
|
193
|
+
<EluanProvider defaultTheme="minimal">
|
|
194
|
+
{children}
|
|
195
|
+
<Toast />
|
|
196
|
+
</EluanProvider>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export function NotificationSettingsForm({ save }: { save: () => Promise<void> }) {
|
|
201
|
+
const [saving, setSaving] = useState(false);
|
|
202
|
+
const [error, setError] = useState(false);
|
|
203
|
+
|
|
204
|
+
async function handleSubmit(event: React.FormEvent) {
|
|
205
|
+
event.preventDefault();
|
|
206
|
+
if (saving) return;
|
|
207
|
+
setSaving(true);
|
|
208
|
+
setError(false);
|
|
209
|
+
try {
|
|
210
|
+
await save();
|
|
211
|
+
toast("Settings saved");
|
|
212
|
+
} catch {
|
|
213
|
+
setError(true);
|
|
214
|
+
} finally {
|
|
215
|
+
setSaving(false);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return (
|
|
220
|
+
<form onSubmit={handleSubmit} style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-lg)" }}>
|
|
221
|
+
{error && (
|
|
222
|
+
<Banner variant="destructive" position="inline" role="alert">
|
|
223
|
+
We couldn't save your settings. Check your connection and try again.
|
|
224
|
+
</Banner>
|
|
225
|
+
)}
|
|
226
|
+
<div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", gap: "var(--spacing-md)" }}>
|
|
227
|
+
<Label htmlFor="weekly-digest">Weekly digest email</Label>
|
|
228
|
+
<Switch id="weekly-digest" name="weeklyDigest" defaultChecked />
|
|
229
|
+
</div>
|
|
230
|
+
<div style={{ display: "flex", justifyContent: "flex-end", gap: "var(--spacing-sm)" }}>
|
|
231
|
+
<Button type="submit" aria-busy={saving} aria-disabled={saving}>
|
|
232
|
+
{saving ? "Saving…" : "Save changes"}
|
|
233
|
+
</Button>
|
|
234
|
+
</div>
|
|
235
|
+
</form>
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## 14. Related components
|
|
241
|
+
|
|
242
|
+
- [Banner](./banner.md): persistent, blocking or form-level messages.
|
|
243
|
+
- [Label](./form-label.md): FormMessage for an error on one field.
|
|
244
|
+
- [Dialog](./dialog.md): when the user has to decide.
|
|
245
|
+
- [Badge](./badge.md): status on an item, not a message.
|
|
246
|
+
- [Spinner](./spinner.md): in-place loading feedback.
|
|
247
|
+
- See [patterns/feedback.md](../patterns/feedback.md) for choosing between them.
|
|
248
|
+
|
|
249
|
+
## 15. Common agent mistakes
|
|
250
|
+
|
|
251
|
+
_Filled from evals._
|