Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

Improve CheckboxList docs page and block examples (#1690)

rubyycheung7081cb0e5d32
diff --git a/packages/cli/templates/blocks/components/CheckboxList/CheckboxListDynamicItems.doc.mjs b/packages/cli/templates/blocks/components/CheckboxList/CheckboxListDynamicItems.doc.mjs
deleted file mode 100644
index 0ad4e6352e..0000000000
--- a/packages/cli/templates/blocks/components/CheckboxList/CheckboxListDynamicItems.doc.mjs
+++ /dev/null
@@ -1,10 +0,0 @@
-/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */
-export const doc = {
- type: 'block',
- name: 'CheckboxList — Dynamic Items',
- description:
- 'Checkbox list rendered from an array of data with pre-selected defaults.',
- isReady: true,
- aspectRatio: 4 / 3,
- componentsUsed: ['CheckboxList'],
-};
diff --git a/packages/cli/templates/blocks/components/CheckboxList/CheckboxListDynamicItems.tsx b/packages/cli/templates/blocks/components/CheckboxList/CheckboxListDynamicItems.tsx
deleted file mode 100644
index afa0d83fee..0000000000
--- a/packages/cli/templates/blocks/components/CheckboxList/CheckboxListDynamicItems.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-'use client';
-
-import {useState} from 'react';
-import {XDSCheckboxList, XDSCheckboxListItem} from '@xds/core/CheckboxList';
-
-const frameworks = [
- {id: 'react', label: 'React'},
- {id: 'vue', label: 'Vue'},
- {id: 'angular', label: 'Angular'},
- {id: 'svelte', label: 'Svelte'},
-];
-
-export default function CheckboxListDynamicItems() {
- const [value, setValue] = useState<string[]>(['react']);
- return (
- <XDSCheckboxList label="Frameworks" value={value} onChange={setValue}>
- {frameworks.map(item => (
- <XDSCheckboxListItem
- key={item.id}
- label={item.label}
- value={item.id}
- />
- ))}
- </XDSCheckboxList>
- );
-}
diff --git a/packages/cli/templates/blocks/components/CheckboxList/CheckboxListInsideCard.doc.mjs b/packages/cli/templates/blocks/components/CheckboxList/CheckboxListInsideCard.doc.mjs
deleted file mode 100644
index 6d190b744a..0000000000
--- a/packages/cli/templates/blocks/components/CheckboxList/CheckboxListInsideCard.doc.mjs
+++ /dev/null
@@ -1,10 +0,0 @@
-/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */
-export const doc = {
- type: 'block',
- name: 'CheckboxList — Inside Card',
- description:
- 'Checkbox list inside a card with mixed item states including a disabled option.',
- isReady: true,
- aspectRatio: 4 / 3,
- componentsUsed: ['CheckboxList', 'Card'],
-};
diff --git a/packages/cli/templates/blocks/components/CheckboxList/CheckboxListInsideCard.tsx b/packages/cli/templates/blocks/components/CheckboxList/CheckboxListInsideCard.tsx
deleted file mode 100644
index db50c51f0f..0000000000
--- a/packages/cli/templates/blocks/components/CheckboxList/CheckboxListInsideCard.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-'use client';
-
-import {useState} from 'react';
-import {XDSCheckboxList, XDSCheckboxListItem} from '@xds/core/CheckboxList';
-import {XDSCard} from '@xds/core/Card';
-
-export default function CheckboxListInsideCard() {
- const [selected, setSelected] = useState<string[]>(['email']);
- return (
- <div style={{maxWidth: 400}}>
- <XDSCard>
- <XDSCheckboxList
- label="Notifications"
- description="Choose how to be notified"
- value={selected}
- onChange={setSelected}>
- <XDSCheckboxListItem
- value="email"
- label="Email"
- description="Weekly digest"
- />
- <XDSCheckboxListItem value="push" label="Push notifications" />
- <XDSCheckboxListItem value="sms" label="SMS" isDisabled />
- </XDSCheckboxList>
- </XDSCard>
- </div>
- );
-}
diff --git a/packages/cli/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.doc.mjs b/packages/cli/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.doc.mjs
index ecf970a958..ebfab8ed40 100644
--- a/packages/cli/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.doc.mjs
+++ b/packages/cli/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.doc.mjs
@@ -3,8 +3,8 @@ export const doc = {
type: 'block',
name: 'CheckboxList — Select All With Indeterminate',
description:
- 'Checkbox list with a "select all" item that shows indeterminate state for partial selection.',
+ 'A "select all" toggle at the top of a checkbox list that switches to an indeterminate dash when only some items are checked — useful for bulk actions like exporting documents or assigning permissions where users often want everything at once.',
isReady: true,
- aspectRatio: 4 / 3,
- componentsUsed: ['CheckboxList'],
+ aspectRatio: 16 / 9,
+ componentsUsed: ['CheckboxList', 'Divider'],
};
diff --git a/packages/cli/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.tsx b/packages/cli/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.tsx
index 9d0a82f039..a15d818a80 100644
--- a/packages/cli/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.tsx
+++ b/packages/cli/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.tsx
@@ -2,13 +2,21 @@
import {useState} from 'react';
import {XDSCheckboxList, XDSCheckboxListItem} from '@xds/core/CheckboxList';
+import {XDSDivider} from '@xds/core/Divider';
-const allItems = ['email', 'sms', 'push'];
+const DOCUMENTS = [
+ {id: 'transactions', label: 'Transaction history'},
+ {id: 'statements', label: 'Account statements'},
+ {id: 'tax', label: 'Tax documents'},
+ {id: 'invoices', label: 'Invoices'},
+];
+
+const ALL_IDS = DOCUMENTS.map(d => d.id);
export default function CheckboxListSelectAllPattern() {
- const [selected, setSelected] = useState<string[]>(['email']);
+ const [selected, setSelected] = useState<string[]>(['transactions']);
- const allChecked = allItems.every(item => selected.includes(item));
+ const allChecked = ALL_IDS.every(id => selected.includes(id));
const noneChecked = selected.length === 0;
const selectAllState = allChecked
? true
@@ -16,25 +24,24 @@ export default function CheckboxListSelectAllPattern() {
? false
: ('indeterminate' as const);
- const handleSelectAll = (checked: boolean) => {
- setSelected(checked ? [...allItems] : []);
- };
-
return (
- <XDSCheckboxList label="Notifications" hasDividers>
+ <XDSCheckboxList label="Include in export">
<XDSCheckboxListItem
label="Select all"
isChecked={selectAllState}
- onCheck={handleSelectAll}
+ onCheck={checked => {
+ setSelected(checked ? [...ALL_IDS] : []);
+ }}
/>
- {allItems.map(item => (
+ <XDSDivider />
+ {DOCUMENTS.map(doc => (
<XDSCheckboxListItem
- key={item}
- label={item.charAt(0).toUpperCase() + item.slice(1)}
- isChecked={selected.includes(item)}
+ key={doc.id}
+ label={doc.label}
+ isChecked={selected.includes(doc.id)}
onCheck={checked => {
setSelected(prev =>
- checked ? [...prev, item] : prev.filter(v => v !== item),
+ checked ? [...prev, doc.id] : prev.filter(v => v !== doc.id),
);
}}
/>
diff --git a/packages/cli/templates/blocks/components/CheckboxList/CheckboxListShowcase.tsx b/packages/cli/templates/blocks/components/CheckboxList/CheckboxListShowcase.tsx
index ca02f03add..c6f478c327 100644
--- a/packages/cli/templates/blocks/components/CheckboxList/CheckboxListShowcase.tsx
+++ b/packages/cli/templates/blocks/components/CheckboxList/CheckboxListShowcase.tsx
@@ -1,13 +1,31 @@
'use client';
+import {useState} from 'react';
import {XDSCheckboxList, XDSCheckboxListItem} from '@xds/core/CheckboxList';
-
export default function CheckboxListShowcase() {
+ const [value, setValue] = useState<string[]>(['email']);
return (
- <XDSCheckboxList label="Notification preferences" value={[]} onChange={() => {}}>
- <XDSCheckboxListItem label="Email" value="email" />
- <XDSCheckboxListItem label="SMS" value="sms" />
- <XDSCheckboxListItem label="Push notification" value="push" />
+ <XDSCheckboxList
+ label="Notification preferences"
+ description="Choose how you would like to be notified"
+ value={value}
+ onChange={setValue}
+ hasDividers>
+ <XDSCheckboxListItem
+ label="Email"
+ value="email"
+ description="Weekly digest every Monday"
+ />
+ <XDSCheckboxListItem
+ label="Push notification"
+ value="push"
+ description="Instant alerts on your device"
+ />
+ <XDSCheckboxListItem
+ label="SMS"
+ value="sms"
+ description="Standard messaging rates apply"
+ />
</XDSCheckboxList>
);
}
diff --git a/packages/cli/templates/blocks/components/CheckboxList/CheckboxListWithDescriptions.doc.mjs b/packages/cli/templates/blocks/components/CheckboxList/CheckboxListWithDescriptions.doc.mjs
deleted file mode 100644
index 4f2aac4211..0000000000
--- a/packages/cli/templates/blocks/components/CheckboxList/CheckboxListWithDescriptions.doc.mjs
+++ /dev/null
@@ -1,10 +0,0 @@
-/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */
-export const doc = {
- type: 'block',
- name: 'CheckboxList — With Descriptions',
- description:
- 'Checkbox list with item descriptions and dividers for a notification preferences form.',
- isReady: true,
- aspectRatio: 4 / 3,
- componentsUsed: ['CheckboxList'],
-};
diff --git a/packages/cli/templates/blocks/components/CheckboxList/CheckboxListWithDescriptions.tsx b/packages/cli/templates/blocks/components/CheckboxList/CheckboxListWithDescriptions.tsx
deleted file mode 100644
index a6a66a137f..0000000000
--- a/packages/cli/templates/blocks/components/CheckboxList/CheckboxListWithDescriptions.tsx
+++ /dev/null
@@ -1,32 +0,0 @@
-'use client';
-
-import {useState} from 'react';
-import {XDSCheckboxList, XDSCheckboxListItem} from '@xds/core/CheckboxList';
-
-export default function CheckboxListWithDescriptions() {
- const [value, setValue] = useState<string[]>([]);
- return (
- <XDSCheckboxList
- label="Notification preferences"
- description="Choose how you would like to be notified"
- value={value}
- onChange={setValue}
- hasDividers>
- <XDSCheckboxListItem
- label="Email"
- value="email"
- description="Receive notifications via email"
- />
- <XDSCheckboxListItem
- label="SMS"
- value="sms"
- description="Standard messaging rates apply"
- />
- <XDSCheckboxListItem
- label="Push notification"
- value="push"
- description="Instant alerts on your device"
- />
- </XDSCheckboxList>
- );
-}
diff --git a/packages/cli/templates/blocks/components/CheckboxList/CheckboxListWithEndContent.doc.mjs b/packages/cli/templates/blocks/components/CheckboxList/CheckboxListWithEndContent.doc.mjs
index ca5d0b0a06..a5ac55f88f 100644
--- a/packages/cli/templates/blocks/components/CheckboxList/CheckboxListWithEndContent.doc.mjs
+++ b/packages/cli/templates/blocks/components/CheckboxList/CheckboxListWithEndContent.doc.mjs
@@ -3,8 +3,8 @@ export const doc = {
type: 'block',
name: 'CheckboxList — With End Content',
description:
- 'Checkbox list items with pricing labels as end content for an add-on selection pattern.',
+ 'Badges in the trailing slot show contextual info — like a price or status — next to each option without cluttering the label, so users can compare choices at a glance.',
isReady: true,
- aspectRatio: 4 / 3,
- componentsUsed: ['CheckboxList'],
+ aspectRatio: 16 / 9,
+ componentsUsed: ['CheckboxList', 'Badge'],
};
diff --git a/packages/cli/templates/blocks/components/CheckboxList/CheckboxListWithEndContent.tsx b/packages/cli/templates/blocks/components/CheckboxList/CheckboxListWithEndContent.tsx
index dbbeecf24e..5966966b21 100644
--- a/packages/cli/templates/blocks/components/CheckboxList/CheckboxListWithEndContent.tsx
+++ b/packages/cli/templates/blocks/components/CheckboxList/CheckboxListWithEndContent.tsx
@@ -2,6 +2,7 @@
import {useState} from 'react';
import {XDSCheckboxList, XDSCheckboxListItem} from '@xds/core/CheckboxList';
+import {XDSBadge} from '@xds/core/Badge';
export default function CheckboxListWithEndContent() {
const [value, setValue] = useState<string[]>(['free']);
@@ -15,19 +16,19 @@ export default function CheckboxListWithEndContent() {
label="Free tier"
value="free"
description="Basic features included"
- endContent={<span style={{color: '#0D8626'}}>$0/mo</span>}
+ endContent={<XDSBadge variant="success" label="$0/mo" />}
/>
<XDSCheckboxListItem
label="Pro tier"
value="pro"
- description="Advanced features"
- endContent={<span style={{color: '#0064E0'}}>$9/mo</span>}
+ description="Advanced analytics and integrations"
+ endContent={<XDSBadge variant="info" label="$9/mo" />}
/>
<XDSCheckboxListItem
label="Enterprise"
value="enterprise"
- description="Custom solutions"
- endContent={<span style={{color: '#5B08D8'}}>Custom</span>}
+ description="Custom solutions and dedicated support"
+ endContent={<XDSBadge variant="purple" label="Custom" />}
/>
</XDSCheckboxList>
);
diff --git a/packages/core/src/CheckboxList/CheckboxList.doc.mjs b/packages/core/src/CheckboxList/CheckboxList.doc.mjs
index 94c73bbb54..744a24329a 100644
--- a/packages/core/src/CheckboxList/CheckboxList.doc.mjs
+++ b/packages/core/src/CheckboxList/CheckboxList.doc.mjs
@@ -131,12 +131,13 @@ export const docs = {
},
],
usage: {
- description: 'CheckboxList is a grouped set of checkboxes for selecting multiple options from a visible list. Use it when users need to pick several items at once. For single selection use RadioList; for long option sets consider MultiSelector.',
+ description: 'CheckboxList shows a small group of checkboxes so users can turn several options on or off at once. Place it in settings pages, filter panels, or forms where every choice should be visible without scrolling. For a single standalone checkbox — like "I agree to the terms" — use CheckboxInput instead. If only one option can be picked, use RadioList. If the list is long enough to need searching or scrolling, use MultiSelector instead.',
bestPractices: [
- { guidance: true, description: 'Provide a clear group label that describes what the options represent.' },
- { guidance: true, description: 'Use collection mode (value/onChange on the group) to let the parent manage selected state as a string array.' },
- { guidance: false, description: 'Use CheckboxList when only one option can be selected — use RadioList instead.' },
- { guidance: false, description: 'Place interactive elements in endContent that conflict with the full-row click target.' },
+ { guidance: true, description: 'Keep the list short — three to seven options is the sweet spot. Beyond that, switch to MultiSelector which adds search and scrolling.' },
+ { guidance: true, description: 'Turn on dividers (hasDividers) when items have helper text underneath — without them the labels and descriptions blur together.' },
+ { guidance: true, description: 'Write a group label that says what the choices represent — "Export formats" tells users more than "Options".' },
+ { guidance: false, description: 'Show a CheckboxList when the user can only pick one thing — that is what RadioList is for.' },
+ { guidance: false, description: 'Put buttons or links inside the trailing slot (endContent) — the whole row is already tappable, so a nested button creates two competing click targets.' },
],
},
};
@@ -145,12 +146,13 @@ export const docs = {
export const docsZh = {
name: 'CheckboxList',
usage: {
- description: 'CheckboxList is a grouped set of checkboxes for selecting multiple options from a visible list. Use it when users need to pick several items at once. For single selection use RadioList; for long option sets consider MultiSelector.',
+ description: 'CheckboxList shows a small group of checkboxes so users can turn several options on or off at once. Place it in settings pages, filter panels, or forms where every choice should be visible without scrolling. For a single standalone checkbox — like "I agree to the terms" — use CheckboxInput instead. If only one option can be picked, use RadioList. If the list is long enough to need searching or scrolling, use MultiSelector instead.',
bestPractices: [
- { guidance: true, description: 'Provide a clear group label that describes what the options represent.' },
- { guidance: true, description: 'Use collection mode (value/onChange on the group) to let the parent manage selected state as a string array.' },
- { guidance: false, description: 'Use CheckboxList when only one option can be selected — use RadioList instead.' },
- { guidance: false, description: 'Place interactive elements in endContent that conflict with the full-row click target.' },
+ { guidance: true, description: 'Keep the list short — three to seven options is the sweet spot. Beyond that, switch to MultiSelector which adds search and scrolling.' },
+ { guidance: true, description: 'Turn on dividers (hasDividers) when items have helper text underneath — without them the labels and descriptions blur together.' },
+ { guidance: true, description: 'Write a group label that says what the choices represent — "Export formats" tells users more than "Options".' },
+ { guidance: false, description: 'Show a CheckboxList when the user can only pick one thing — that is what RadioList is for.' },
+ { guidance: false, description: 'Put buttons or links inside the trailing slot (endContent) — the whole row is already tappable, so a nested button creates two competing click targets.' },
],
},
components: [
@@ -194,12 +196,13 @@ export const docsDense = {
description:
'Checkbox group component for multi-value selection. Collection mode (parent state) + standalone mode (per-item state).',
usage: {
- description: 'CheckboxList is a grouped set of checkboxes for selecting multiple options from a visible list. Use it when users need to pick several items at once. For single selection use RadioList; for long option sets consider MultiSelector.',
+ description: 'CheckboxList shows a small group of checkboxes so users can turn several options on or off at once. Place it in settings pages, filter panels, or forms where every choice should be visible without scrolling. For a single standalone checkbox — like "I agree to the terms" — use CheckboxInput instead. If only one option can be picked, use RadioList. If the list is long enough to need searching or scrolling, use MultiSelector instead.',
bestPractices: [
- { guidance: true, description: 'Provide a clear group label that describes what the options represent.' },
- { guidance: true, description: 'Use collection mode (value/onChange on the group) to let the parent manage selected state as a string array.' },
- { guidance: false, description: 'Use CheckboxList when only one option can be selected — use RadioList instead.' },
- { guidance: false, description: 'Place interactive elements in endContent that conflict with the full-row click target.' },
+ { guidance: true, description: 'Keep the list short — three to seven options is the sweet spot. Beyond that, switch to MultiSelector which adds search and scrolling.' },
+ { guidance: true, description: 'Turn on dividers (hasDividers) when items have helper text underneath — without them the labels and descriptions blur together.' },
+ { guidance: true, description: 'Write a group label that says what the choices represent — "Export formats" tells users more than "Options".' },
+ { guidance: false, description: 'Show a CheckboxList when the user can only pick one thing — that is what RadioList is for.' },
+ { guidance: false, description: 'Put buttons or links inside the trailing slot (endContent) — the whole row is already tappable, so a nested button creates two competing click targets.' },
],
},
components: [