@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,274 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Carousel
|
|
3
|
+
use_when: Showing a row of similar slides the user pages through one or a few at a time, such as screenshots, testimonials or featured items.
|
|
4
|
+
instead_of: Card grid when every item should be visible; Tabs for switching views; Stepper for an ordered process.
|
|
5
|
+
source: packages/core/src/components/carousel.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Carousel
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
Carousel is a scrolling strip of slides with previous and next buttons, built on Embla. Slides snap into place, can be dragged or swiped, and can show one, two or three per view. Embla options, plugins and its API pass through for looping, alignment and slide counters.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- Product screenshots or images the user flips through.
|
|
17
|
+
- Testimonials, featured articles or templates where only a few need to show at once.
|
|
18
|
+
- A row of cards that doesn't fit the width on small screens.
|
|
19
|
+
|
|
20
|
+
### When not to use
|
|
21
|
+
|
|
22
|
+
- Every item should be visible and comparable → use [Card](./card.md) in a grid, or [Table](./table.md).
|
|
23
|
+
- Switching between views of the same content → use [Tabs](./tabs.md) or [SegmentedControl](./segmented-control.md).
|
|
24
|
+
- Steps the user must complete in order → use [Stepper](./stepper.md).
|
|
25
|
+
- One important message → show it directly; a [Banner](./banner.md) for announcements.
|
|
26
|
+
- Paging through a long list of records → use [Pagination](./pagination.md).
|
|
27
|
+
|
|
28
|
+
## 3. Anatomy
|
|
29
|
+
|
|
30
|
+
1. **Carousel**: the root region. Holds the Embla instance and handles arrow keys.
|
|
31
|
+
2. **CarouselContent**: the clipping viewport and the track of slides. Slides are spaced `--spacing-md` apart.
|
|
32
|
+
3. **CarouselItem**: one slide. `basis` sets how much of the viewport it takes.
|
|
33
|
+
4. **CarouselPrevious** and **CarouselNext**: round ghost icon [Buttons](./button.md) with arrow icons, positioned outside the viewport's edges (above and below for vertical carousels).
|
|
34
|
+
|
|
35
|
+
## 4. Variants
|
|
36
|
+
|
|
37
|
+
| Orientation | Use for |
|
|
38
|
+
| --- | --- |
|
|
39
|
+
| `horizontal` (default) | Almost every carousel. Slides move left and right. |
|
|
40
|
+
| `vertical` | A narrow column of stacked items, such as a side rail. Needs `viewportHeight` on CarouselContent. |
|
|
41
|
+
|
|
42
|
+
## 5. Sizes
|
|
43
|
+
|
|
44
|
+
Carousel has no size prop. It fills its parent's width. CarouselItem `basis` sets slides per view:
|
|
45
|
+
|
|
46
|
+
| Basis | Use in |
|
|
47
|
+
| --- | --- |
|
|
48
|
+
| `full` (default) | One slide at a time: screenshots, hero images. |
|
|
49
|
+
| `half` | Two at a time: testimonials, larger cards. |
|
|
50
|
+
| `third` | Three at a time: product or template cards. |
|
|
51
|
+
|
|
52
|
+
## 6. States
|
|
53
|
+
|
|
54
|
+
| State | Looks like | Notes |
|
|
55
|
+
| --- | --- | --- |
|
|
56
|
+
| Default | Slides with both controls shown | |
|
|
57
|
+
| At first or last slide | The control for that direction is disabled (50% opacity) | Unless `opts={{ loop: true }}`. If the focused control becomes disabled, focus is lost. |
|
|
58
|
+
| Hover | Controls take the ghost Button hover | |
|
|
59
|
+
| Focus | Controls show the Button focus outline | Never remove or restyle the focus ring. |
|
|
60
|
+
| Dragging | Slides follow the pointer and snap on release | Embla handles this. |
|
|
61
|
+
|
|
62
|
+
## 7. Content guidelines
|
|
63
|
+
|
|
64
|
+
- Keep slides parallel: same component, same parts, similar length.
|
|
65
|
+
- Make each slide make sense on its own; users may never see the others.
|
|
66
|
+
- Put the most important slide first.
|
|
67
|
+
- Label the carousel with what it holds ("Product screenshots") and each slide with its position ("2 of 5").
|
|
68
|
+
|
|
69
|
+
| Do | Don't |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| `aria-label="Customer stories"` | No label |
|
|
72
|
+
| `aria-label="2 of 5"` on a slide | `aria-label="Slide"` |
|
|
73
|
+
|
|
74
|
+
## 8. Rules
|
|
75
|
+
|
|
76
|
+
1. Give Carousel an `aria-label`. It renders a `region` that needs a name.
|
|
77
|
+
2. Give each CarouselItem an `aria-label` with its position, such as "2 of 5".
|
|
78
|
+
3. Leave room for the controls: they sit outside the viewport, `--size-xl` plus `--spacing-md` past each edge. Pad the wrapper with at least `--size-2xl` on those sides.
|
|
79
|
+
4. Don't pass `onClick` or `disabled` to CarouselPrevious or CarouselNext; your props replace the scroll handler and the end-of-track state.
|
|
80
|
+
5. Set `viewportHeight` on CarouselContent for vertical carousels, with a size token string such as `"var(--size-4xl)"`.
|
|
81
|
+
6. Don't autoplay. If you add an autoplay plugin, add a visible pause control and stop on hover and focus.
|
|
82
|
+
7. Don't put text inputs inside slides; the carousel captures Arrow Left and Arrow Right from anything inside it.
|
|
83
|
+
8. Never pass `className` or `style`; they're dropped. Size the carousel with a wrapper.
|
|
84
|
+
|
|
85
|
+
## 9. Dos and don'ts
|
|
86
|
+
|
|
87
|
+
**Do:** label the carousel and its slides, and leave room for the controls.
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
<div style={{ paddingInline: "var(--size-2xl)" }}>
|
|
91
|
+
<Carousel aria-label="Product screenshots">
|
|
92
|
+
<CarouselContent>
|
|
93
|
+
{shots.map((shot, i) => (
|
|
94
|
+
<CarouselItem key={shot.id} aria-label={`${i + 1} of ${shots.length}`}>
|
|
95
|
+
<Image src={shot.src} alt={shot.alt} />
|
|
96
|
+
</CarouselItem>
|
|
97
|
+
))}
|
|
98
|
+
</CarouselContent>
|
|
99
|
+
<CarouselPrevious />
|
|
100
|
+
<CarouselNext />
|
|
101
|
+
</Carousel>
|
|
102
|
+
</div>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Don't:** leave it unnamed in a tight container, or override the controls.
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
<div style={{ overflow: "hidden" }}>
|
|
109
|
+
<Carousel>
|
|
110
|
+
<CarouselContent>{slides}</CarouselContent>
|
|
111
|
+
<CarouselPrevious onClick={() => track("prev")} />
|
|
112
|
+
<CarouselNext />
|
|
113
|
+
</Carousel>
|
|
114
|
+
</div>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Do:** use a grid when everything should be visible.
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
<div style={{ display: "grid", gridTemplateColumns: "repeat(3, minmax(0, 1fr))", gap: "var(--spacing-lg)" }}>
|
|
121
|
+
{plans.map((plan) => (
|
|
122
|
+
<Card key={plan.id}>{/* … */}</Card>
|
|
123
|
+
))}
|
|
124
|
+
</div>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Don't:** hide three pricing plans in a carousel.
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
<Carousel>
|
|
131
|
+
<CarouselContent>
|
|
132
|
+
{plans.map((plan) => (
|
|
133
|
+
<CarouselItem key={plan.id}><Card>{/* … */}</Card></CarouselItem>
|
|
134
|
+
))}
|
|
135
|
+
</CarouselContent>
|
|
136
|
+
</Carousel>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## 10. Accessibility
|
|
140
|
+
|
|
141
|
+
- Role: Carousel is a `region` with `aria-roledescription="carousel"`; each CarouselItem is a `group` with `aria-roledescription="slide"`.
|
|
142
|
+
- Label: pass `aria-label` to Carousel and to each CarouselItem; neither has a default. The controls are named "Previous slide" and "Next slide" with visually hidden text.
|
|
143
|
+
- Keyboard: Tab reaches the controls and any interactive slide content. While focus is anywhere inside the carousel, Arrow Left and Arrow Right move to the previous and next slide, in vertical carousels too.
|
|
144
|
+
- Focus: stays where it is when slides move. Off-screen slides stay in the Tab order, so links in hidden slides can receive focus.
|
|
145
|
+
- Focus ring: the controls use Button's outline.
|
|
146
|
+
- Contrast: handled by the theme. Don't override colours.
|
|
147
|
+
|
|
148
|
+
## 11. Behaviour
|
|
149
|
+
|
|
150
|
+
- Responsive: fills its parent's width; `basis` is a fraction of that width, so slides shrink with it. Change `basis` at small widths in your own code if three slides get too narrow.
|
|
151
|
+
- Overflow and truncation: the viewport clips off-screen slides. Slide content isn't truncated.
|
|
152
|
+
- Motion: Embla animates snapping and drag. Eluan adds no reduced-motion handling; pass Embla's `duration` option if you need faster scrolling.
|
|
153
|
+
- Looping and alignment: pass Embla options through `opts`, for example `opts={{ loop: true, align: "start" }}`. Orientation always comes from `orientation`, not `opts.axis`.
|
|
154
|
+
- Counters and custom controls: use `setApi` to get the Embla API, then read `api.selectedScrollSnap()` and `api.scrollSnapList()` and listen for `"select"`.
|
|
155
|
+
|
|
156
|
+
## 12. API
|
|
157
|
+
|
|
158
|
+
<!-- api:start -->
|
|
159
|
+
### Carousel
|
|
160
|
+
|
|
161
|
+
| Prop | Type | Default | Description |
|
|
162
|
+
| --- | --- | --- | --- |
|
|
163
|
+
| `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | Scroll axis. |
|
|
164
|
+
| `opts` | `CarouselOptions` | | Passed to Embla: `loop`, `align`, `dragFree`, `startIndex`, `duration`. `axis` is overridden by `orientation`. |
|
|
165
|
+
| `plugins` | `CarouselPlugin` | | Passed to Embla. |
|
|
166
|
+
| `setApi` | `(api: CarouselApi) => void` | | Receives the Embla API for counters and custom controls. |
|
|
167
|
+
| `aria-label` | `string` | | Names the carousel region. |
|
|
168
|
+
| `...props` | `HTMLAttributes<HTMLDivElement>` without `className`, `style` | | Native div attributes on the root. |
|
|
169
|
+
|
|
170
|
+
### CarouselContent
|
|
171
|
+
|
|
172
|
+
| Prop | Type | Default | Description |
|
|
173
|
+
| --- | --- | --- | --- |
|
|
174
|
+
| `viewportHeight` | `number \| string` | | Fixed viewport height. Required for vertical carousels; pass a size token string. |
|
|
175
|
+
| `...props` | `HTMLAttributes<HTMLDivElement>` without `className`, `style` | | Applied to the slide track. |
|
|
176
|
+
|
|
177
|
+
### CarouselItem
|
|
178
|
+
|
|
179
|
+
| Prop | Type | Default | Description |
|
|
180
|
+
| --- | --- | --- | --- |
|
|
181
|
+
| `basis` | `"full" \| "half" \| "third"` | `"full"` | Share of the viewport each slide takes. |
|
|
182
|
+
| `aria-label` | `string` | | The slide's position, such as "2 of 5". |
|
|
183
|
+
| `...props` | `HTMLAttributes<HTMLDivElement>` without `className`, `style` | | Native div attributes. |
|
|
184
|
+
|
|
185
|
+
### CarouselPrevious, CarouselNext
|
|
186
|
+
|
|
187
|
+
| Prop | Type | Default | Description |
|
|
188
|
+
| --- | --- | --- | --- |
|
|
189
|
+
| `aria-label` | `string` | | Replaces the built-in "Previous slide" / "Next slide" name, for example when translating. |
|
|
190
|
+
| `...props` | `ButtonHTMLAttributes` without `className`, `style` | | Spread last onto the Button, so `onClick` and `disabled` replace the built-in behaviour. Don't pass them. |
|
|
191
|
+
<!-- api:end -->
|
|
192
|
+
|
|
193
|
+
`CarouselApi` and `CarouselProps` are exported as types.
|
|
194
|
+
|
|
195
|
+
## 13. Examples
|
|
196
|
+
|
|
197
|
+
Customer stories, two per view, with a slide counter.
|
|
198
|
+
|
|
199
|
+
```tsx
|
|
200
|
+
import * as React from "react";
|
|
201
|
+
import {
|
|
202
|
+
Card,
|
|
203
|
+
CardContent,
|
|
204
|
+
Carousel,
|
|
205
|
+
CarouselContent,
|
|
206
|
+
CarouselItem,
|
|
207
|
+
CarouselNext,
|
|
208
|
+
CarouselPrevious,
|
|
209
|
+
Typography,
|
|
210
|
+
type CarouselApi,
|
|
211
|
+
} from "@eluan/core";
|
|
212
|
+
|
|
213
|
+
const stories = [
|
|
214
|
+
{ id: "northwind", quote: "We moved our whole dashboard over in a week.", person: "Priya Raman, Northwind" },
|
|
215
|
+
{ id: "lumen", quote: "Dark mode came for free once the theme was set.", person: "Tomás Ortega, Lumen Health" },
|
|
216
|
+
{ id: "harbor", quote: "Designers and engineers finally use the same names.", person: "Grace Kim, Harbor" },
|
|
217
|
+
{ id: "fieldnote", quote: "Our forms passed the accessibility audit first time.", person: "Daniel Mensah, Fieldnote" },
|
|
218
|
+
];
|
|
219
|
+
|
|
220
|
+
export function CustomerStories() {
|
|
221
|
+
const [api, setApi] = React.useState<CarouselApi>();
|
|
222
|
+
const [current, setCurrent] = React.useState(1);
|
|
223
|
+
|
|
224
|
+
React.useEffect(() => {
|
|
225
|
+
if (!api) return;
|
|
226
|
+
const update = () => setCurrent(api.selectedScrollSnap() + 1);
|
|
227
|
+
update();
|
|
228
|
+
api.on("select", update);
|
|
229
|
+
return () => {
|
|
230
|
+
api.off("select", update);
|
|
231
|
+
};
|
|
232
|
+
}, [api]);
|
|
233
|
+
|
|
234
|
+
return (
|
|
235
|
+
<section style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-md)" }}>
|
|
236
|
+
<Typography variant="heading" as="h2">What teams say</Typography>
|
|
237
|
+
<div style={{ paddingInline: "var(--size-2xl)" }}>
|
|
238
|
+
<Carousel aria-label="Customer stories" setApi={setApi} opts={{ align: "start" }}>
|
|
239
|
+
<CarouselContent>
|
|
240
|
+
{stories.map((story, i) => (
|
|
241
|
+
<CarouselItem key={story.id} basis="half" aria-label={`${i + 1} of ${stories.length}`}>
|
|
242
|
+
<Card elevation="none">
|
|
243
|
+
<CardContent>
|
|
244
|
+
<figure style={{ margin: 0, paddingTop: "var(--spacing-2xl)", display: "flex", flexDirection: "column", gap: "var(--spacing-sm)" }}>
|
|
245
|
+
<Typography variant="lead" as="blockquote">“{story.quote}”</Typography>
|
|
246
|
+
<Typography variant="caption" tone="muted" as="figcaption">{story.person}</Typography>
|
|
247
|
+
</figure>
|
|
248
|
+
</CardContent>
|
|
249
|
+
</Card>
|
|
250
|
+
</CarouselItem>
|
|
251
|
+
))}
|
|
252
|
+
</CarouselContent>
|
|
253
|
+
<CarouselPrevious />
|
|
254
|
+
<CarouselNext />
|
|
255
|
+
</Carousel>
|
|
256
|
+
</div>
|
|
257
|
+
<Typography variant="caption" tone="muted" align="center" aria-live="polite">
|
|
258
|
+
Story {current} of {stories.length}
|
|
259
|
+
</Typography>
|
|
260
|
+
</section>
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
## 14. Related components
|
|
266
|
+
|
|
267
|
+
- [Card](./card.md): the usual slide content, or a grid when everything should show.
|
|
268
|
+
- [Button](./button.md): the previous and next controls.
|
|
269
|
+
- [Media](./media.md): images inside slides.
|
|
270
|
+
- [Tabs](./tabs.md): switching views instead of paging through slides.
|
|
271
|
+
|
|
272
|
+
## 15. Common agent mistakes
|
|
273
|
+
|
|
274
|
+
_Filled from evals._
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: CheckboxGroup
|
|
3
|
+
use_when: The user picks any number of options from a short, visible list, such as notification channels or permissions.
|
|
4
|
+
instead_of: RadioGroup when only one option can be chosen; MultiSelect for long or searchable lists; Switch rows for settings that apply immediately.
|
|
5
|
+
source: packages/core/src/components/checkbox-group.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# CheckboxGroup
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
CheckboxGroup manages a list of checkboxes as one `string[]` value. Each CheckboxGroupItem renders a Checkbox with its own Label and an optional description. The group renders a `<div role="group">` and stacks items vertically or wraps them in a row.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- Choosing several options from a visible list: Email, SMS and Push notifications.
|
|
17
|
+
- Granting permissions: Read, Write, Admin.
|
|
18
|
+
- Short filters on one line, such as sizes S, M, L, with `orientation="horizontal"`.
|
|
19
|
+
|
|
20
|
+
### When not to use
|
|
21
|
+
|
|
22
|
+
- Only one option can be chosen → use [RadioGroup](./radio-group.md).
|
|
23
|
+
- A long or searchable list → use [MultiSelect](./multi-select.md).
|
|
24
|
+
- A single yes/no choice → use [Checkbox](./checkbox.md).
|
|
25
|
+
- Settings that apply the moment they change → use a list of [Switch](./switch.md) rows.
|
|
26
|
+
- A row of pressable toolbar options → use [ToggleGroup](./toggle-group.md).
|
|
27
|
+
|
|
28
|
+
## 3. Anatomy
|
|
29
|
+
|
|
30
|
+
1. **Group**: the `<div role="group">`. A grid with a `--spacing-md` gap when vertical; a wrapping row with a `--spacing-lg` gap when horizontal.
|
|
31
|
+
2. **Item row**: one CheckboxGroupItem. A flex row with a `--spacing-sm` gap; centred when it has no description, top-aligned when it has one.
|
|
32
|
+
3. **Checkbox**: a [Checkbox](./checkbox.md) with `id` defaulting to `checkbox-{value}`.
|
|
33
|
+
4. **Label**: a Label wired to the checkbox, from `label`. It sits in a box with a `--size-xxs` minimum height, so the label stays centred on the checkbox even when a description flows below it. This is deliberate; keep it.
|
|
34
|
+
5. **Description** (optional): a `<p>` from `description`, in `--interactive-fg-alt` at `--font-size-sm`.
|
|
35
|
+
|
|
36
|
+
## 4. Variants
|
|
37
|
+
|
|
38
|
+
CheckboxGroup has no variants. `orientation` sets the layout:
|
|
39
|
+
|
|
40
|
+
| Orientation | Use for |
|
|
41
|
+
| --- | --- |
|
|
42
|
+
| `vertical` (default) | Most lists, and any list with descriptions. |
|
|
43
|
+
| `horizontal` | A few short labels that fit on one line: S, M, L. |
|
|
44
|
+
|
|
45
|
+
## 5. Sizes
|
|
46
|
+
|
|
47
|
+
CheckboxGroup has no `size` prop. Checkboxes are `--size-xxs` and spacing follows density.
|
|
48
|
+
|
|
49
|
+
## 6. States
|
|
50
|
+
|
|
51
|
+
| State | Looks like | Notes |
|
|
52
|
+
| --- | --- | --- |
|
|
53
|
+
| Default, hover, checked | As [Checkbox](./checkbox.md) | |
|
|
54
|
+
| Focus | Checkbox outline in `--focus-ring` | Never remove or restyle the focus ring. |
|
|
55
|
+
| Disabled | Checkbox disabled; label and description in `--interactive-fg-disabled`, not-allowed cursor | `disabled` on the group disables every item; on an item, only that one. |
|
|
56
|
+
| Checked and disabled | Reads as unchecked: the box turns pale and the check disappears into it | A locked-on item looks off. Say it in the label or description ("Required for all admins"). |
|
|
57
|
+
| Error | No error style | Show a FormMessage under the group and point the group's `aria-describedby` at it. |
|
|
58
|
+
|
|
59
|
+
## 7. Content guidelines
|
|
60
|
+
|
|
61
|
+
- Name the group with a visible heading: "Notify me by", "Permissions".
|
|
62
|
+
- Label each option with a short noun phrase: "Email notifications", "SMS notifications".
|
|
63
|
+
- Use the description for one sentence on what the option does: "Receive updates about your account via email."
|
|
64
|
+
- Keep option labels parallel in form and order them logically.
|
|
65
|
+
|
|
66
|
+
| Do | Don't |
|
|
67
|
+
| --- | --- |
|
|
68
|
+
| Email notifications | Would you like to receive email? |
|
|
69
|
+
| Receive updates about your account via email. | Email. |
|
|
70
|
+
| Read · Write · Admin | Read · Can write things · ADMIN |
|
|
71
|
+
|
|
72
|
+
## 8. Rules
|
|
73
|
+
|
|
74
|
+
1. Name the group: `aria-labelledby` pointing at a visible heading, or `aria-label`. `role="group"` has no name of its own.
|
|
75
|
+
2. Read and set the selection with `value` or `defaultValue` and `onValueChange` (a `string[]`). There's no `onChange`.
|
|
76
|
+
3. Give every item a unique `value`. If the same value appears in two groups on one page, pass a unique `id` to each item; the default `checkbox-{value}` ids would collide and wire labels to the wrong box.
|
|
77
|
+
4. Submit the array from your state. Native form data won't hold the item values: each checked item submits `"on"` under its `name`.
|
|
78
|
+
5. Put only CheckboxGroupItem, or a custom item built with `useCheckboxGroup`, inside the group.
|
|
79
|
+
6. Don't put essential information only in `description`; it isn't linked to the checkbox and isn't announced with it.
|
|
80
|
+
7. Never pass `className` or `style`; they're dropped.
|
|
81
|
+
|
|
82
|
+
## 9. Dos and don'ts
|
|
83
|
+
|
|
84
|
+
**Do:** name the group and control it with `onValueChange`.
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-sm)" }}>
|
|
88
|
+
<Typography id="notify-heading" variant="label" weight="medium">Notify me by</Typography>
|
|
89
|
+
<CheckboxGroup aria-labelledby="notify-heading" value={channels} onValueChange={setChannels}>
|
|
90
|
+
<CheckboxGroupItem value="email" label="Email" />
|
|
91
|
+
<CheckboxGroupItem value="sms" label="SMS" />
|
|
92
|
+
</CheckboxGroup>
|
|
93
|
+
</div>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Don't:** hand-roll the list with separate Checkboxes and array logic.
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
<div>
|
|
100
|
+
<Checkbox onCheckedChange={(c) => setChannels(c ? [...channels, "email"] : channels.filter((v) => v !== "email"))} /> Email
|
|
101
|
+
<Checkbox onCheckedChange={(c) => setChannels(c ? [...channels, "sms"] : channels.filter((v) => v !== "sms"))} /> SMS
|
|
102
|
+
</div>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Do:** give items unique ids when two groups share values.
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
<CheckboxGroup aria-label="Comment notifications">
|
|
109
|
+
<CheckboxGroupItem id="comments-email" value="email" label="Email" />
|
|
110
|
+
</CheckboxGroup>
|
|
111
|
+
<CheckboxGroup aria-label="Mention notifications">
|
|
112
|
+
<CheckboxGroupItem id="mentions-email" value="email" label="Email" />
|
|
113
|
+
</CheckboxGroup>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Don't:** let two items default to the same id.
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
<CheckboxGroup aria-label="Comment notifications">
|
|
120
|
+
<CheckboxGroupItem value="email" label="Email" />
|
|
121
|
+
</CheckboxGroup>
|
|
122
|
+
<CheckboxGroup aria-label="Mention notifications">
|
|
123
|
+
<CheckboxGroupItem value="email" label="Email" />
|
|
124
|
+
</CheckboxGroup>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## 10. Accessibility
|
|
128
|
+
|
|
129
|
+
- Role: `group` on the container; each item is a `checkbox`.
|
|
130
|
+
- Label: the group needs `aria-labelledby` or `aria-label`. Each checkbox is named by its `label`. The `description` has no id and isn't linked, so screen readers don't read it with the checkbox.
|
|
131
|
+
- Keyboard: every checkbox is its own Tab stop. Space toggles; Enter does nothing. There's no arrow-key navigation.
|
|
132
|
+
- Focus: the Checkbox focus outline.
|
|
133
|
+
- Contrast: handled by the theme. Don't override colours.
|
|
134
|
+
|
|
135
|
+
## 11. Behaviour
|
|
136
|
+
|
|
137
|
+
- Responsive: vertical stacks items; horizontal wraps them onto new lines when they don't fit.
|
|
138
|
+
- Overflow and truncation: labels and descriptions wrap.
|
|
139
|
+
- Order: a newly checked value is appended, so the array follows click order. Sort it yourself if order matters.
|
|
140
|
+
- Motion: from Checkbox (150ms). Don't add your own.
|
|
141
|
+
|
|
142
|
+
## 12. API
|
|
143
|
+
|
|
144
|
+
<!-- api:start -->
|
|
145
|
+
### CheckboxGroup
|
|
146
|
+
|
|
147
|
+
| Prop | Type | Default | Description |
|
|
148
|
+
| --- | --- | --- | --- |
|
|
149
|
+
| `value` | `string[]` | | Controlled selection. Pair with `onValueChange`. |
|
|
150
|
+
| `defaultValue` | `string[]` | `[]` | Uncontrolled starting selection. |
|
|
151
|
+
| `onValueChange` | `(value: string[]) => void` | | Called with the next selection, in both modes. |
|
|
152
|
+
| `disabled` | `boolean` | | Disables every item. |
|
|
153
|
+
| `orientation` | `"vertical" \| "horizontal"` | `"vertical"` | Stack or wrap the items. |
|
|
154
|
+
| `...props` | `HTMLAttributes<HTMLDivElement>` without `className`, `style`, `onChange`, `defaultValue` | | `aria-labelledby`, `aria-label`, `aria-describedby`, `id`. `ref` goes to the group `<div>`. |
|
|
155
|
+
|
|
156
|
+
### CheckboxGroupItem
|
|
157
|
+
|
|
158
|
+
| Prop | Type | Default | Description |
|
|
159
|
+
| --- | --- | --- | --- |
|
|
160
|
+
| `value` | `string` | required | The value added to the group's array when checked. |
|
|
161
|
+
| `label` | `string` | required | Visible label, wired to the checkbox. |
|
|
162
|
+
| `description` | `string` | | One line of supporting text under the label. Not linked to the checkbox. |
|
|
163
|
+
| `disabled` | `boolean` | | Disables this item. The group's `disabled` also applies. |
|
|
164
|
+
| `id` | `string` | `checkbox-{value}` | The checkbox id. Set it when values repeat on a page. |
|
|
165
|
+
| `...props` | Checkbox props without `checked`, `onCheckedChange`, `value`, `className`, `style` | | `name`, `required`, `aria-*`, passed to the Checkbox. `ref` goes to the checkbox `<button>`. |
|
|
166
|
+
|
|
167
|
+
### useCheckboxGroup
|
|
168
|
+
|
|
169
|
+
| Prop | Type | Default | Description |
|
|
170
|
+
| --- | --- | --- | --- |
|
|
171
|
+
| returns | `{ value: string[]; onItemChange: (itemValue: string, checked: boolean) => void; disabled?: boolean }` | | Reads the nearest CheckboxGroup. Throws outside one. Use it to build a custom item. |
|
|
172
|
+
<!-- api:end -->
|
|
173
|
+
|
|
174
|
+
## 13. Examples
|
|
175
|
+
|
|
176
|
+
```tsx
|
|
177
|
+
import { CheckboxGroup, CheckboxGroupItem, Typography } from "@eluan/core";
|
|
178
|
+
import * as React from "react";
|
|
179
|
+
|
|
180
|
+
export function NotificationChannels({ onChange }: { onChange: (channels: string[]) => void }) {
|
|
181
|
+
const [channels, setChannels] = React.useState<string[]>(["email", "security"]);
|
|
182
|
+
|
|
183
|
+
return (
|
|
184
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-md)" }}>
|
|
185
|
+
<Typography id="channels-heading" variant="label" weight="medium">
|
|
186
|
+
Notify me by
|
|
187
|
+
</Typography>
|
|
188
|
+
<CheckboxGroup
|
|
189
|
+
aria-labelledby="channels-heading"
|
|
190
|
+
value={channels}
|
|
191
|
+
onValueChange={(next) => {
|
|
192
|
+
setChannels(next);
|
|
193
|
+
onChange(next);
|
|
194
|
+
}}
|
|
195
|
+
>
|
|
196
|
+
<CheckboxGroupItem
|
|
197
|
+
value="email"
|
|
198
|
+
label="Email notifications"
|
|
199
|
+
description="Receive updates about your account via email."
|
|
200
|
+
/>
|
|
201
|
+
<CheckboxGroupItem
|
|
202
|
+
value="sms"
|
|
203
|
+
label="SMS notifications"
|
|
204
|
+
description="Get text messages for important alerts."
|
|
205
|
+
/>
|
|
206
|
+
<CheckboxGroupItem
|
|
207
|
+
value="security"
|
|
208
|
+
label="Security alerts (always on)"
|
|
209
|
+
description="Required for every account. Contact your admin to change it."
|
|
210
|
+
disabled
|
|
211
|
+
/>
|
|
212
|
+
</CheckboxGroup>
|
|
213
|
+
</div>
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## 14. Related components
|
|
219
|
+
|
|
220
|
+
- [Checkbox](./checkbox.md): the single control each item renders.
|
|
221
|
+
- [RadioGroup](./radio-group.md): the single-choice equivalent.
|
|
222
|
+
- [MultiSelect](./multi-select.md): multiple choice from a long list.
|
|
223
|
+
- [Fieldset](./fieldset.md): titles the group alongside related fields.
|
|
224
|
+
- See [../patterns/forms.md](../patterns/forms.md) for grouping and labelling options.
|
|
225
|
+
|
|
226
|
+
## 15. Common agent mistakes
|
|
227
|
+
|
|
228
|
+
_Filled from evals._
|