@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,226 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Checkbox
|
|
3
|
+
use_when: A single yes/no choice the user confirms when they submit a form, such as accepting terms, or a select-all control above a list.
|
|
4
|
+
instead_of: Switch for settings that apply immediately; CheckboxGroup for a labelled list of options; RadioGroup when only one option can be chosen.
|
|
5
|
+
source: packages/core/src/components/checkbox.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Checkbox
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
Checkbox is a square control for one on/off choice, built on Radix Checkbox. It renders a `<button role="checkbox">` with a check icon and supports checked, unchecked and indeterminate states. It has no label of its own: pair it with a Label.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- One independent choice in a form that the user submits: "I agree to the Terms of Service", "Remember this device".
|
|
17
|
+
- A select-all control above a list, using the indeterminate state when only some items are selected.
|
|
18
|
+
- One checkbox in a layout CheckboxGroup can't produce, with your own Label.
|
|
19
|
+
|
|
20
|
+
### When not to use
|
|
21
|
+
|
|
22
|
+
- A setting that takes effect the moment it changes → use [Switch](./switch.md).
|
|
23
|
+
- A list of related options with labels and descriptions → use [CheckboxGroup](./checkbox-group.md).
|
|
24
|
+
- One choice out of several → use [RadioGroup](./radio-group.md).
|
|
25
|
+
- A pressed/unpressed toolbar button → use [Toggle](./toggle.md).
|
|
26
|
+
|
|
27
|
+
## 3. Anatomy
|
|
28
|
+
|
|
29
|
+
1. **Box**: the `<button role="checkbox">`. `--size-xxs` square, `--curves-xs` radius, 1px `--interactive-border-alt` border.
|
|
30
|
+
2. **Indicator**: always mounted; fades the check in and out with opacity.
|
|
31
|
+
3. **Check icon**: a Lucide `Check` at stroke width 3, `--spacing-md` square. White (`--interactive-fg-selected`) on the filled box when checked.
|
|
32
|
+
4. **Hidden input**: inside a `<form>`, Radix adds a hidden native checkbox so `name` and `value` submit with the form.
|
|
33
|
+
5. **Label** (yours): a Label beside the box, with `htmlFor` matching the Checkbox `id`.
|
|
34
|
+
|
|
35
|
+
## 4. Variants
|
|
36
|
+
|
|
37
|
+
Checkbox has no variants.
|
|
38
|
+
|
|
39
|
+
## 5. Sizes
|
|
40
|
+
|
|
41
|
+
Checkbox has no `size` prop. The box is `--size-xxs` and follows density.
|
|
42
|
+
|
|
43
|
+
## 6. States
|
|
44
|
+
|
|
45
|
+
| State | Looks like | Notes |
|
|
46
|
+
| --- | --- | --- |
|
|
47
|
+
| Unchecked | Transparent box, `--interactive-border-alt` border | |
|
|
48
|
+
| Hover | `--interactive-bg-hover` fill | |
|
|
49
|
+
| Focus | 1px outline in `--focus-ring`, 1px offset | Never remove or restyle the focus ring. |
|
|
50
|
+
| Checked | `--interactive-bg-selected` fill and border, white check | |
|
|
51
|
+
| Indeterminate | `aria-checked="mixed"`. The box stays unfilled and shows the check icon in the surrounding text colour; there's no dash | Use it only for a select-all parent. |
|
|
52
|
+
| Disabled | `--interactive-bg-disabled` fill, `--interactive-border-disabled` border, not-allowed cursor | Disable its Label too. |
|
|
53
|
+
| Checked and disabled | Reads as empty: the fill turns pale and the white check disappears into it | Don't rely on it to show a locked-on choice. Say it in the label ("Included in your plan") or show the value as text. |
|
|
54
|
+
| Error | No error style | Set `aria-invalid={true}` and show a FormMessage linked with `aria-describedby`. |
|
|
55
|
+
|
|
56
|
+
## 7. Content guidelines
|
|
57
|
+
|
|
58
|
+
- Write the label as what will be true when it's checked: "Email me product updates", not "Don't email me".
|
|
59
|
+
- Keep it short, in sentence case. Put details or links in a description under the label.
|
|
60
|
+
- Never make the user uncheck a box to opt out of something they didn't choose.
|
|
61
|
+
|
|
62
|
+
| Do | Don't |
|
|
63
|
+
| --- | --- |
|
|
64
|
+
| Email me product updates | Uncheck to stop receiving emails |
|
|
65
|
+
| I agree to the Terms of Service | Yes |
|
|
66
|
+
| Remember this device | Remember me? |
|
|
67
|
+
|
|
68
|
+
## 8. Rules
|
|
69
|
+
|
|
70
|
+
1. Pair every Checkbox with a Label whose `htmlFor` matches its `id`, or give it `aria-label`. The box has no text.
|
|
71
|
+
2. Read changes with `onCheckedChange`; it receives `true`, `false` or `"indeterminate"`. Native `onChange` doesn't fire (it's a button).
|
|
72
|
+
3. Control it with `checked` and `onCheckedChange` together, or leave it uncontrolled with `defaultChecked`.
|
|
73
|
+
4. Set `name` (and `value` if `"on"` isn't what your server expects) when the form submits natively.
|
|
74
|
+
5. Don't use a Checkbox for a setting that saves on change; use Switch.
|
|
75
|
+
6. Use CheckboxGroup for a list of related options instead of managing an array by hand.
|
|
76
|
+
7. Never pass `className` or `style`; they're dropped.
|
|
77
|
+
|
|
78
|
+
## 9. Dos and don'ts
|
|
79
|
+
|
|
80
|
+
**Do:** pair the box with a Label so both are clickable.
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
<div style={{ display: "flex", alignItems: "center", gap: "var(--spacing-sm)" }}>
|
|
84
|
+
<Checkbox id="remember-device" name="rememberDevice" />
|
|
85
|
+
<Label htmlFor="remember-device">Remember this device</Label>
|
|
86
|
+
</div>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Don't:** leave the text unconnected.
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
<div>
|
|
93
|
+
<Checkbox />
|
|
94
|
+
<span>Remember this device</span>
|
|
95
|
+
</div>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Do:** state a locked-on choice in words.
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
<div style={{ display: "flex", alignItems: "center", gap: "var(--spacing-sm)" }}>
|
|
102
|
+
<Checkbox id="audit-log" checked disabled />
|
|
103
|
+
<Label htmlFor="audit-log" disabled>Audit log (included in your plan)</Label>
|
|
104
|
+
</div>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Don't:** rely on a checked, disabled box alone to say it's on.
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
<Checkbox checked disabled aria-label="Audit log" />
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## 10. Accessibility
|
|
114
|
+
|
|
115
|
+
- Role: `checkbox` (Radix renders a `<button>`), with `aria-checked` set to `true`, `false` or `"mixed"`.
|
|
116
|
+
- Label: a Label with `htmlFor` matching the Checkbox `id`, or `aria-label`.
|
|
117
|
+
- Keyboard: Space toggles. Enter does nothing (Radix blocks it, following WAI-ARIA). Tab moves between checkboxes.
|
|
118
|
+
- Focus: visible outline on `:focus-visible`. Disabled checkboxes use the native `disabled` attribute and are skipped by Tab.
|
|
119
|
+
- Contrast: handled by the theme. Don't override colours.
|
|
120
|
+
|
|
121
|
+
## 11. Behaviour
|
|
122
|
+
|
|
123
|
+
- Responsive: the box has a fixed size and doesn't shrink beside long labels. Centre it on a one-line label; for a label with a description, align to the top and wrap the label in a `--size-xxs` minimum-height box, as CheckboxGroup does.
|
|
124
|
+
- Motion: colours change over 150ms and the check fades over 150ms. Don't add your own.
|
|
125
|
+
- Forms: inside a `<form>`, a hidden input submits `value` (default `"on"`) under `name` when checked.
|
|
126
|
+
|
|
127
|
+
## 12. API
|
|
128
|
+
|
|
129
|
+
<!-- api:start -->
|
|
130
|
+
| Prop | Type | Default | Description |
|
|
131
|
+
| --- | --- | --- | --- |
|
|
132
|
+
| `checked` | `boolean \| "indeterminate"` | | Controlled state. Pair with `onCheckedChange`. |
|
|
133
|
+
| `defaultChecked` | `boolean \| "indeterminate"` | | Uncontrolled starting state. |
|
|
134
|
+
| `onCheckedChange` | `(checked: boolean \| "indeterminate") => void` | | Called when the user toggles it. |
|
|
135
|
+
| `disabled` | `boolean` | `false` | Prevents interaction. |
|
|
136
|
+
| `required` | `boolean` | `false` | Marks it required for form validation. |
|
|
137
|
+
| `name` | `string` | | Field name for form submission. |
|
|
138
|
+
| `value` | `string` | `"on"` | Value submitted when checked. |
|
|
139
|
+
| `id` | `string` | | Match it with the Label's `htmlFor`. |
|
|
140
|
+
| `...props` | Radix `Checkbox.Root` props without `className`, `style` | | Button attributes and `aria-*`. `ref` goes to the `<button>`. |
|
|
141
|
+
<!-- api:end -->
|
|
142
|
+
|
|
143
|
+
## 13. Examples
|
|
144
|
+
|
|
145
|
+
```tsx
|
|
146
|
+
import { Button, Checkbox, FormDescription, FormMessage, Label } from "@eluan/core";
|
|
147
|
+
import * as React from "react";
|
|
148
|
+
|
|
149
|
+
const row = { display: "flex", alignItems: "flex-start", gap: "var(--spacing-sm)" } as const;
|
|
150
|
+
const labelLine = { display: "flex", alignItems: "center", minHeight: "var(--size-xxs)" } as const;
|
|
151
|
+
const copy = { display: "flex", flexDirection: "column", gap: "var(--spacing-xxs)" } as const;
|
|
152
|
+
|
|
153
|
+
export function SignUpConsent({ onContinue }: { onContinue: (updates: boolean) => void }) {
|
|
154
|
+
const [acceptedTerms, setAcceptedTerms] = React.useState(false);
|
|
155
|
+
const [productUpdates, setProductUpdates] = React.useState(false);
|
|
156
|
+
const [showError, setShowError] = React.useState(false);
|
|
157
|
+
|
|
158
|
+
function handleSubmit(event: React.FormEvent) {
|
|
159
|
+
event.preventDefault();
|
|
160
|
+
if (!acceptedTerms) {
|
|
161
|
+
setShowError(true);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
onContinue(productUpdates);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return (
|
|
168
|
+
<form
|
|
169
|
+
onSubmit={handleSubmit}
|
|
170
|
+
style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-lg)" }}
|
|
171
|
+
>
|
|
172
|
+
<div style={row}>
|
|
173
|
+
<Checkbox
|
|
174
|
+
id="accept-terms"
|
|
175
|
+
name="acceptTerms"
|
|
176
|
+
required
|
|
177
|
+
checked={acceptedTerms}
|
|
178
|
+
onCheckedChange={(checked) => {
|
|
179
|
+
setAcceptedTerms(checked === true);
|
|
180
|
+
setShowError(false);
|
|
181
|
+
}}
|
|
182
|
+
aria-invalid={showError ? true : undefined}
|
|
183
|
+
aria-describedby={showError ? "accept-terms-hint accept-terms-error" : "accept-terms-hint"}
|
|
184
|
+
/>
|
|
185
|
+
<div style={copy}>
|
|
186
|
+
<span style={labelLine}>
|
|
187
|
+
<Label htmlFor="accept-terms" required>I agree to the Terms of Service</Label>
|
|
188
|
+
</span>
|
|
189
|
+
<FormDescription id="accept-terms-hint">
|
|
190
|
+
You can read them at acme.com/terms before continuing.
|
|
191
|
+
</FormDescription>
|
|
192
|
+
{showError && (
|
|
193
|
+
<FormMessage id="accept-terms-error">Accept the Terms of Service to create an account</FormMessage>
|
|
194
|
+
)}
|
|
195
|
+
</div>
|
|
196
|
+
</div>
|
|
197
|
+
|
|
198
|
+
<div style={{ display: "flex", alignItems: "center", gap: "var(--spacing-sm)" }}>
|
|
199
|
+
<Checkbox
|
|
200
|
+
id="product-updates"
|
|
201
|
+
name="productUpdates"
|
|
202
|
+
checked={productUpdates}
|
|
203
|
+
onCheckedChange={(checked) => setProductUpdates(checked === true)}
|
|
204
|
+
/>
|
|
205
|
+
<Label htmlFor="product-updates">Email me product updates</Label>
|
|
206
|
+
</div>
|
|
207
|
+
|
|
208
|
+
<div style={{ display: "flex", justifyContent: "flex-end" }}>
|
|
209
|
+
<Button type="submit">Create account</Button>
|
|
210
|
+
</div>
|
|
211
|
+
</form>
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## 14. Related components
|
|
217
|
+
|
|
218
|
+
- [CheckboxGroup](./checkbox-group.md): a managed list of checkboxes with labels and descriptions.
|
|
219
|
+
- [Switch](./switch.md): an on/off control for settings that apply immediately.
|
|
220
|
+
- [RadioGroup](./radio-group.md): one choice from several.
|
|
221
|
+
- [Label](./form-label.md): the Label, FormDescription and FormMessage around the box.
|
|
222
|
+
- See [../patterns/forms.md](../patterns/forms.md) for when to use Checkbox or Switch in a form.
|
|
223
|
+
|
|
224
|
+
## 15. Common agent mistakes
|
|
225
|
+
|
|
226
|
+
_Filled from evals._
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: CodeBlock
|
|
3
|
+
use_when: Showing a multi-line code sample, config file or command with syntax highlighting and a copy button.
|
|
4
|
+
instead_of: Kbd for keyboard keys; an inline code element with the mono font for code inside a sentence; Textarea for code the user edits.
|
|
5
|
+
source: packages/core/src/components/code-block.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# CodeBlock
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
CodeBlock shows read-only code with Prism syntax highlighting. It adds an optional header with a filename, a language switcher and a copy button, and can number and highlight lines. Code is always escaped before rendering, so untrusted strings are safe to show.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- Code samples and setup instructions in docs, onboarding or settings (API keys usage, webhooks).
|
|
17
|
+
- A config file or command the user copies: `.env` values, a CLI command, a JSON payload.
|
|
18
|
+
- The same example in several languages or package managers (`languages`).
|
|
19
|
+
- Pointing at specific lines in a sample (`highlightLines`).
|
|
20
|
+
|
|
21
|
+
### When not to use
|
|
22
|
+
|
|
23
|
+
- A keyboard shortcut → use [Kbd](./kbd.md).
|
|
24
|
+
- A short code word inside a sentence → use an inline `<code>` styled with `--font-mono`; see [typography.md](../foundations/typography.md).
|
|
25
|
+
- Code or text the user edits → use [Textarea](./textarea.md) or [RichText](./rich-text.md).
|
|
26
|
+
- Long logs or streaming output → use a [ScrollArea](./scroll-area.md) with your own mono text.
|
|
27
|
+
|
|
28
|
+
## 3. Anatomy
|
|
29
|
+
|
|
30
|
+
1. **Container**: `--container-bg-alt` surface with a `--container-border` border and `--curves-lg` corners.
|
|
31
|
+
2. **Header** (shown when there's a filename, a copy button or more than one language): a row with a bottom border.
|
|
32
|
+
3. **Filename** (optional): muted `--font-size-xs` text at the start of the header.
|
|
33
|
+
4. **Language switcher** (optional): a row of small buttons, one per entry in `languages`, with the active one filled.
|
|
34
|
+
5. **Copy button**: at the end of the header. Shows "Copy", then "Copied" with a check for two seconds.
|
|
35
|
+
6. **Code area**: a horizontally scrolling `<pre><code>` in `--font-mono` at `--font-size-sm`.
|
|
36
|
+
7. **Line numbers** (optional): a muted gutter that isn't selected when copying text by hand.
|
|
37
|
+
8. **Highlighted lines** (optional): full-width rows on `--cautionary-bg-alt`.
|
|
38
|
+
|
|
39
|
+
## 4. Variants
|
|
40
|
+
|
|
41
|
+
CodeBlock has no `variant` prop. `language` picks the Prism grammar: `javascript`, `typescript`, `jsx`, `tsx`, `css`, `json`, `bash`, `python`, `java`, `go`, `rust`, `sql`, `markdown`, `yaml` or `text` (the default, no highlighting). Other languages aren't accepted; use `text`.
|
|
42
|
+
|
|
43
|
+
Syntax colours come from the package stylesheet, not theme tokens: a One Dark palette in dim and dark modes and a darker One Light palette in light mode. A custom theme doesn't change them.
|
|
44
|
+
|
|
45
|
+
## 5. Sizes
|
|
46
|
+
|
|
47
|
+
CodeBlock has no size prop. Code uses `--font-size-sm`; it fills its parent's width and grows to fit every line.
|
|
48
|
+
|
|
49
|
+
## 6. States
|
|
50
|
+
|
|
51
|
+
| State | Looks like | Notes |
|
|
52
|
+
| --- | --- | --- |
|
|
53
|
+
| Default | Highlighted code on the alt surface | |
|
|
54
|
+
| Hover | Copy button gets `--interactive-bg-hover`; inactive language buttons darken | |
|
|
55
|
+
| Focus | The browser's default focus ring on the copy and language buttons | They declare no focus style. Never remove or restyle the focus ring. |
|
|
56
|
+
| Copied | Check icon and "Copied" for two seconds | Not announced to screen readers (see Accessibility). |
|
|
57
|
+
| Active language | Filled with `--interactive-bg-selected` | |
|
|
58
|
+
|
|
59
|
+
## 7. Content guidelines
|
|
60
|
+
|
|
61
|
+
- Show complete, runnable snippets. Don't leave placeholders like `foo` or `...` in code users will copy.
|
|
62
|
+
- Set `filename` when the code belongs in a file ("next.config.ts"); leave it off for commands.
|
|
63
|
+
- Keep one command per block when users copy them one at a time.
|
|
64
|
+
- Label language variants the way users name them: "pnpm", "npm", "TypeScript", "Python".
|
|
65
|
+
- Don't put a prompt character (`$`) in commands; it gets copied.
|
|
66
|
+
|
|
67
|
+
| Do | Don't |
|
|
68
|
+
| --- | --- |
|
|
69
|
+
| `pnpm add @eluan/core` | `$ pnpm add @eluan/core` |
|
|
70
|
+
| `filename="next.config.ts"` | `filename="Code"` |
|
|
71
|
+
| Label: TypeScript | Label: ts |
|
|
72
|
+
|
|
73
|
+
## 8. Rules
|
|
74
|
+
|
|
75
|
+
1. Set `language` on every block that isn't plain text; the default is `text`, with no highlighting.
|
|
76
|
+
2. With `languages`, still pass `code` (it's required by the type but ignored); pass the first variant's code.
|
|
77
|
+
3. Pass code as a string. Never pre-highlight it or pass HTML; CodeBlock escapes it.
|
|
78
|
+
4. Turn on `showLineNumbers` when the surrounding text refers to line numbers or you use `highlightLines`.
|
|
79
|
+
5. `highlightLines` counts from 1.
|
|
80
|
+
6. Keep `showCopyButton` on (the default) for anything users run or paste.
|
|
81
|
+
7. Never pass `className` or `style`; they're dropped. Constrain width with a wrapper.
|
|
82
|
+
|
|
83
|
+
## 9. Dos and don'ts
|
|
84
|
+
|
|
85
|
+
**Do:** set the language and filename.
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
<CodeBlock language="json" filename="package.json" code={`{\n "name": "acme-dashboard",\n "private": true\n}`} />
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Don't:** rely on the default `text` language or pass HTML.
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
<CodeBlock code={`<span class="token keyword">const</span> port = 3000;`} />
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Do:** offer package-manager variants in one block.
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
<CodeBlock
|
|
101
|
+
code="pnpm add @eluan/core @eluan/tokens"
|
|
102
|
+
languages={[
|
|
103
|
+
{ language: "bash", code: "pnpm add @eluan/core @eluan/tokens", label: "pnpm" },
|
|
104
|
+
{ language: "bash", code: "npm install @eluan/core @eluan/tokens", label: "npm" },
|
|
105
|
+
]}
|
|
106
|
+
/>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Don't:** stack near-identical blocks.
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
<CodeBlock language="bash" code="pnpm add @eluan/core @eluan/tokens" />
|
|
113
|
+
<CodeBlock language="bash" code="npm install @eluan/core @eluan/tokens" />
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## 10. Accessibility
|
|
117
|
+
|
|
118
|
+
- Role: a plain `<pre><code>` block; the copy and language controls are native buttons.
|
|
119
|
+
- Label: the copy button is named by its text ("Copy", then "Copied"). Language buttons are named by their `label`. Add a heading or sentence before the block that says what the code does.
|
|
120
|
+
- Keyboard: Tab reaches the language buttons and the copy button; Enter and Space activate them. The code area scrolls horizontally but isn't focusable, so keyboard users can't scroll long lines.
|
|
121
|
+
- State: the active language isn't exposed (no `aria-pressed` or tab roles), and the "Copied" change isn't announced (no live region).
|
|
122
|
+
- Line numbers: they're real text, so screen readers read a number before each line. Leave `showLineNumbers` off unless sighted users need them.
|
|
123
|
+
- Focus: the buttons keep the browser's default ring; don't add your own.
|
|
124
|
+
- Contrast: surfaces come from the theme; syntax colours are tuned to at least 3.9:1 on the light-mode surface. Don't override them.
|
|
125
|
+
|
|
126
|
+
## 11. Behaviour
|
|
127
|
+
|
|
128
|
+
- Responsive: fills its parent's width. Long lines scroll horizontally inside the block; they never wrap.
|
|
129
|
+
- Overflow and truncation: the block grows to fit every line. For long files, show an excerpt or wrap the block in a height-limited [ScrollArea](./scroll-area.md).
|
|
130
|
+
- Copy: copies the active variant's code with the Clipboard API, which needs a secure context (HTTPS or localhost).
|
|
131
|
+
- Motion: language buttons fade colour over 150ms. Don't add your own.
|
|
132
|
+
|
|
133
|
+
## 12. API
|
|
134
|
+
|
|
135
|
+
<!-- api:start -->
|
|
136
|
+
| Prop | Type | Default | Description |
|
|
137
|
+
| --- | --- | --- | --- |
|
|
138
|
+
| `code` | `string` | | Required. The code to show. Ignored when `languages` is set. |
|
|
139
|
+
| `language` | `"javascript" \| "typescript" \| "jsx" \| "tsx" \| "css" \| "json" \| "bash" \| "python" \| "java" \| "go" \| "rust" \| "sql" \| "markdown" \| "yaml" \| "text"` | `"text"` | Prism grammar. `text` is not highlighted. |
|
|
140
|
+
| `languages` | `{ language: Language; code: string; label?: string }[]` | | Variants of the same snippet. Two or more show a switcher in the header; `label` defaults to the language id. |
|
|
141
|
+
| `filename` | `string` | | Shown at the start of the header. |
|
|
142
|
+
| `showCopyButton` | `boolean` | `true` | Shows the copy button. |
|
|
143
|
+
| `showLineNumbers` | `boolean` | `false` | Shows a line-number gutter. |
|
|
144
|
+
| `highlightLines` | `number[]` | `[]` | 1-based line numbers to highlight. |
|
|
145
|
+
| `...props` | `HTMLAttributes<HTMLDivElement>` without `className`, `style` | | Native div attributes on the container: `id`, `aria-*`. |
|
|
146
|
+
<!-- api:end -->
|
|
147
|
+
|
|
148
|
+
`Language` isn't exported as a type; write the union or use `CodeBlockProps["language"]`.
|
|
149
|
+
|
|
150
|
+
## 13. Examples
|
|
151
|
+
|
|
152
|
+
Setup instructions with package-manager variants, then a config file with the changed lines highlighted.
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
import { CodeBlock, Typography } from "@eluan/core";
|
|
156
|
+
|
|
157
|
+
const install = [
|
|
158
|
+
{ language: "bash" as const, code: "pnpm add @eluan/core @eluan/tokens", label: "pnpm" },
|
|
159
|
+
{ language: "bash" as const, code: "npm install @eluan/core @eluan/tokens", label: "npm" },
|
|
160
|
+
{ language: "bash" as const, code: "yarn add @eluan/core @eluan/tokens", label: "yarn" },
|
|
161
|
+
];
|
|
162
|
+
|
|
163
|
+
const providerCode = `import "@eluan/core/styles.css";
|
|
164
|
+
import { EluanProvider } from "@eluan/core";
|
|
165
|
+
|
|
166
|
+
export function App({ children }: { children: React.ReactNode }) {
|
|
167
|
+
return <EluanProvider defaultTheme="minimal">{children}</EluanProvider>;
|
|
168
|
+
}`;
|
|
169
|
+
|
|
170
|
+
export function InstallSteps() {
|
|
171
|
+
return (
|
|
172
|
+
<section style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-md)" }}>
|
|
173
|
+
<Typography variant="heading" as="h2">Install</Typography>
|
|
174
|
+
<Typography>Add the core package and its tokens.</Typography>
|
|
175
|
+
<CodeBlock code={install[0].code} languages={install} />
|
|
176
|
+
|
|
177
|
+
<Typography>Wrap your app in the provider and import the stylesheet once.</Typography>
|
|
178
|
+
<CodeBlock language="tsx" filename="app.tsx" code={providerCode} showLineNumbers highlightLines={[1, 5]} />
|
|
179
|
+
</section>
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## 14. Related components
|
|
185
|
+
|
|
186
|
+
- [Kbd](./kbd.md): keyboard keys and shortcuts.
|
|
187
|
+
- [ScrollArea](./scroll-area.md): limit the height of a long block.
|
|
188
|
+
- [Typography](./typography.md): the heading and sentence that introduce a block.
|
|
189
|
+
- [Tabs](./tabs.md): separate whole sections, rather than one snippet's language variants.
|
|
190
|
+
|
|
191
|
+
## 15. Common agent mistakes
|
|
192
|
+
|
|
193
|
+
_Filled from evals._
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Collapsible
|
|
3
|
+
use_when: One region of the page shows and hides in place behind a single trigger, such as advanced options or extra details.
|
|
4
|
+
instead_of: Accordion for several stacked sections; Tabs for switching views; Popover, Sheet or Drawer for content that should float or slide in.
|
|
5
|
+
source: packages/core/src/components/collapsible.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Collapsible
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
Collapsible shows and hides one region of content in place. It re-exports Radix Collapsible with no styles of its own: you supply the trigger (an Eluan Button) and the layout of the content. Unlike [Accordion](./accordion.md), it has no built-in look, icons or animation.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- "Advanced options" or "More settings" in a form, hidden by default.
|
|
17
|
+
- Extra details under a summary: order line items, release notes, a stack trace.
|
|
18
|
+
- A filter section in a sidebar that the user can fold away.
|
|
19
|
+
|
|
20
|
+
### When not to use
|
|
21
|
+
|
|
22
|
+
- Several related sections, each with a heading → use [Accordion](./accordion.md).
|
|
23
|
+
- Switching between views of the same content → use [Tabs](./tabs.md) or [SegmentedControl](./segmented-control.md).
|
|
24
|
+
- Content that floats next to a control → use [Popover](./popover.md).
|
|
25
|
+
- A side panel → use [Sheet](./sheet.md) or [Drawer](./drawer.md).
|
|
26
|
+
- A nested hierarchy of items → use [TreeView](./tree-view.md).
|
|
27
|
+
|
|
28
|
+
## 3. Anatomy
|
|
29
|
+
|
|
30
|
+
1. **Collapsible**: the root. Holds open state; renders a `div`.
|
|
31
|
+
2. **CollapsibleTrigger**: a native `<button type="button">` that toggles the content. Unstyled; wrap a [Button](./button.md) with `asChild`.
|
|
32
|
+
3. **CollapsibleContent**: the region that shows and hides. Unstyled; put your own wrapper inside it for spacing.
|
|
33
|
+
4. **Indicator** (optional): a Lucide chevron inside the trigger Button that reflects the state.
|
|
34
|
+
|
|
35
|
+
## 4. Variants
|
|
36
|
+
|
|
37
|
+
No variants. The trigger Button's `variant` and your content wrapper decide the look.
|
|
38
|
+
|
|
39
|
+
## 5. Sizes
|
|
40
|
+
|
|
41
|
+
No size prop. Use the trigger Button's `size`.
|
|
42
|
+
|
|
43
|
+
## 6. States
|
|
44
|
+
|
|
45
|
+
| State | Looks like | Notes |
|
|
46
|
+
| --- | --- | --- |
|
|
47
|
+
| Closed | Only the trigger shows | Content is unmounted. Trigger has `aria-expanded="false"` and `data-state="closed"`. |
|
|
48
|
+
| Open | Content appears below the trigger | Trigger has `aria-expanded="true"` and `data-state="open"`. |
|
|
49
|
+
| Focus | The trigger Button's focus outline | Never remove or restyle the focus ring. |
|
|
50
|
+
| Disabled | The trigger Button's disabled style | Set `disabled` on Collapsible; the trigger can't toggle. |
|
|
51
|
+
|
|
52
|
+
## 7. Content guidelines
|
|
53
|
+
|
|
54
|
+
- Label the trigger with what it reveals: "Advanced options", "Show 4 line items", "Release notes".
|
|
55
|
+
- Keep the label the same when open; the chevron and `aria-expanded` carry the state.
|
|
56
|
+
- Show the most-used settings outside the Collapsible; hide only what most users can skip.
|
|
57
|
+
- Sentence case.
|
|
58
|
+
|
|
59
|
+
| Do | Don't |
|
|
60
|
+
| --- | --- |
|
|
61
|
+
| Advanced options | More |
|
|
62
|
+
| Show 4 line items | Click to expand |
|
|
63
|
+
|
|
64
|
+
## 8. Rules
|
|
65
|
+
|
|
66
|
+
1. Use `CollapsibleTrigger asChild` around a Button. A bare trigger is an unstyled browser button.
|
|
67
|
+
2. Put spacing and layout on a wrapper `div` inside CollapsibleContent.
|
|
68
|
+
3. Never pass `className` or `style` to Collapsible parts. They aren't dropped here, unlike every other Eluan component, but styling them bypasses the system.
|
|
69
|
+
4. Mark the chevron `aria-hidden="true"` and size it with `--size-xxs`.
|
|
70
|
+
5. Don't stack Collapsibles to build an accordion; use Accordion.
|
|
71
|
+
6. Don't hide required fields or validation errors inside a closed Collapsible.
|
|
72
|
+
|
|
73
|
+
## 9. Dos and don'ts
|
|
74
|
+
|
|
75
|
+
**Do:** use a Button as the trigger and a wrapper for the content.
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
<Collapsible>
|
|
79
|
+
<CollapsibleTrigger asChild>
|
|
80
|
+
<Button type="button" variant="ghost" size="sm">Advanced options</Button>
|
|
81
|
+
</CollapsibleTrigger>
|
|
82
|
+
<CollapsibleContent>
|
|
83
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-lg)" }}>
|
|
84
|
+
{/* fields */}
|
|
85
|
+
</div>
|
|
86
|
+
</CollapsibleContent>
|
|
87
|
+
</Collapsible>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Don't:** style the parts directly or hand-roll the toggle.
|
|
91
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
<Collapsible>
|
|
94
|
+
<CollapsibleTrigger style={{ background: "none", border: 0 }}>Advanced options</CollapsibleTrigger>
|
|
95
|
+
<CollapsibleContent className="advanced-panel">{/* fields */}</CollapsibleContent>
|
|
96
|
+
</Collapsible>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Do:** use Accordion for a set of headed sections.
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
<Accordion type="single" collapsible>
|
|
103
|
+
<AccordionItem value="billing">
|
|
104
|
+
<AccordionTrigger>Billing</AccordionTrigger>
|
|
105
|
+
<AccordionContent>{/* billing settings */}</AccordionContent>
|
|
106
|
+
</AccordionItem>
|
|
107
|
+
</Accordion>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Don't:** stack Collapsibles to imitate one.
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
<Collapsible>{/* Billing */}</Collapsible>
|
|
114
|
+
<Collapsible>{/* Notifications */}</Collapsible>
|
|
115
|
+
<Collapsible>{/* Security */}</Collapsible>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## 10. Accessibility
|
|
119
|
+
|
|
120
|
+
- Role: the trigger is a native `button` with `aria-expanded` and `aria-controls` pointing at the content.
|
|
121
|
+
- Label: the trigger's text.
|
|
122
|
+
- Keyboard: Enter and Space toggle the content. Tab moves focus in DOM order.
|
|
123
|
+
- Focus: stays on the trigger when it toggles. Closed content is removed from the page, so nothing inside it can be focused.
|
|
124
|
+
- Contrast: handled by the theme. Don't override colours.
|
|
125
|
+
|
|
126
|
+
## 11. Behaviour
|
|
127
|
+
|
|
128
|
+
- Responsive: the content takes the width of its container.
|
|
129
|
+
- Overflow and truncation: the content grows to its natural height and pushes the page down.
|
|
130
|
+
- Motion: none. The content appears and disappears at once. Don't add a height animation of your own.
|
|
131
|
+
- Controlled or uncontrolled: pass `open` and `onOpenChange` to control it, or `defaultOpen` to start open.
|
|
132
|
+
- Closing unmounts the content, so uncontrolled fields inside lose what the user typed and drop out of a submitted `FormData`. Keep their values in state (controlled fields) or in your form library.
|
|
133
|
+
|
|
134
|
+
## 12. API
|
|
135
|
+
|
|
136
|
+
<!-- api:start -->
|
|
137
|
+
### Collapsible
|
|
138
|
+
|
|
139
|
+
| Prop | Type | Default | Description |
|
|
140
|
+
| --- | --- | --- | --- |
|
|
141
|
+
| `open` | `boolean` | | Controlled open state. |
|
|
142
|
+
| `defaultOpen` | `boolean` | `false` | Initial state when uncontrolled. |
|
|
143
|
+
| `onOpenChange` | `(open: boolean) => void` | | Called on every toggle. |
|
|
144
|
+
| `disabled` | `boolean` | `false` | Stops the trigger from toggling. |
|
|
145
|
+
| `asChild` | `boolean` | `false` | Renders the child element instead of the `div`. |
|
|
146
|
+
| `...props` | Radix `Collapsible.Root` props | | Don't pass `className` or `style`. |
|
|
147
|
+
|
|
148
|
+
### CollapsibleTrigger
|
|
149
|
+
|
|
150
|
+
| Prop | Type | Default | Description |
|
|
151
|
+
| --- | --- | --- | --- |
|
|
152
|
+
| `asChild` | `boolean` | `false` | Renders the child (a Button) instead of a bare `<button type="button">`. |
|
|
153
|
+
| `...props` | Radix `Collapsible.Trigger` props | | Native button attributes. Don't pass `className` or `style`. |
|
|
154
|
+
|
|
155
|
+
### CollapsibleContent
|
|
156
|
+
|
|
157
|
+
| Prop | Type | Default | Description |
|
|
158
|
+
| --- | --- | --- | --- |
|
|
159
|
+
| `forceMount` | `true` | | Keeps the content mounted and visible while closed; you'd have to hide it yourself. Avoid. |
|
|
160
|
+
| `asChild` | `boolean` | `false` | Renders the child element instead of the `div`. |
|
|
161
|
+
| `...props` | Radix `Collapsible.Content` props | | Don't pass `className` or `style`. |
|
|
162
|
+
<!-- api:end -->
|
|
163
|
+
|
|
164
|
+
## 13. Examples
|
|
165
|
+
|
|
166
|
+
Advanced options in a webhook form, closed by default. The fields are controlled so their values survive closing the section.
|
|
167
|
+
|
|
168
|
+
```tsx
|
|
169
|
+
import * as React from "react";
|
|
170
|
+
import { Button, Collapsible, CollapsibleContent, CollapsibleTrigger, Input, Label } from "@eluan/core";
|
|
171
|
+
import { ChevronDown, ChevronRight } from "lucide-react";
|
|
172
|
+
|
|
173
|
+
type AdvancedValues = { timeout: string; header: string };
|
|
174
|
+
|
|
175
|
+
export function WebhookAdvancedOptions({
|
|
176
|
+
values,
|
|
177
|
+
onChange,
|
|
178
|
+
}: {
|
|
179
|
+
values: AdvancedValues;
|
|
180
|
+
onChange: (values: AdvancedValues) => void;
|
|
181
|
+
}) {
|
|
182
|
+
const [open, setOpen] = React.useState(false);
|
|
183
|
+
const Chevron = open ? ChevronDown : ChevronRight;
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<Collapsible open={open} onOpenChange={setOpen}>
|
|
187
|
+
<CollapsibleTrigger asChild>
|
|
188
|
+
<Button type="button" variant="ghost" size="sm">
|
|
189
|
+
<Chevron aria-hidden="true" style={{ width: "var(--size-xxs)", height: "var(--size-xxs)" }} />
|
|
190
|
+
Advanced options
|
|
191
|
+
</Button>
|
|
192
|
+
</CollapsibleTrigger>
|
|
193
|
+
<CollapsibleContent>
|
|
194
|
+
<div
|
|
195
|
+
style={{
|
|
196
|
+
display: "flex",
|
|
197
|
+
flexDirection: "column",
|
|
198
|
+
gap: "var(--spacing-lg)",
|
|
199
|
+
paddingTop: "var(--spacing-md)",
|
|
200
|
+
}}
|
|
201
|
+
>
|
|
202
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-sm)" }}>
|
|
203
|
+
<Label htmlFor="webhook-timeout" hint="Seconds">
|
|
204
|
+
Request timeout
|
|
205
|
+
</Label>
|
|
206
|
+
<Input
|
|
207
|
+
id="webhook-timeout"
|
|
208
|
+
type="number"
|
|
209
|
+
value={values.timeout}
|
|
210
|
+
onChange={(event) => onChange({ ...values, timeout: event.target.value })}
|
|
211
|
+
/>
|
|
212
|
+
</div>
|
|
213
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-sm)" }}>
|
|
214
|
+
<Label htmlFor="webhook-header" optional>
|
|
215
|
+
Custom header
|
|
216
|
+
</Label>
|
|
217
|
+
<Input
|
|
218
|
+
id="webhook-header"
|
|
219
|
+
placeholder="X-Signature"
|
|
220
|
+
value={values.header}
|
|
221
|
+
onChange={(event) => onChange({ ...values, header: event.target.value })}
|
|
222
|
+
/>
|
|
223
|
+
</div>
|
|
224
|
+
</div>
|
|
225
|
+
</CollapsibleContent>
|
|
226
|
+
</Collapsible>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## 14. Related components
|
|
232
|
+
|
|
233
|
+
- [Accordion](./accordion.md): a styled set of collapsible sections.
|
|
234
|
+
- [Button](./button.md): the trigger.
|
|
235
|
+
- [Tabs](./tabs.md): switch views instead of revealing more.
|
|
236
|
+
- [Popover](./popover.md): content that floats instead of pushing the page.
|
|
237
|
+
|
|
238
|
+
## 15. Common agent mistakes
|
|
239
|
+
|
|
240
|
+
_Filled from evals._
|