An open source design system that's fully customizable and agent ready
TypeScript
Improve Card docs page and block examples (#1556)
rubyycheung0a836a78abf9
diff --git a/packages/cli/templates/blocks/components/Card/CardCallout.doc.mjs b/packages/cli/templates/blocks/components/Card/CardCallout.doc.mjsindex 6e18adf6cb..086f3aa5f6 100644--- a/packages/cli/templates/blocks/components/Card/CardCallout.doc.mjs+++ b/packages/cli/templates/blocks/components/Card/CardCallout.doc.mjs@@ -1,10 +1,9 @@/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */export const doc = {type: 'block',- name: 'Card — Callout Cards',- description:- 'Muted-variant cards used as callout or highlight areas for tips and warnings.',+ name: 'Card — Callout',+ description: 'Muted-variant cards for tips, notes, or supplementary information. Use when content should be visually distinct but not prominent. The muted variant uses a wash background instead of the elevated default, making it feel recessed rather than raised. Works well in sidebars, help panels, or inline callouts.',isReady: true,- aspectRatio: 4 / 3,+ aspectRatio: 16 / 9,componentsUsed: ['Card', 'Layout', 'Text'],};diff --git a/packages/cli/templates/blocks/components/Card/CardCallout.tsx b/packages/cli/templates/blocks/components/Card/CardCallout.tsxindex 74b5daf010..db42eb7492 100644--- a/packages/cli/templates/blocks/components/Card/CardCallout.tsx+++ b/packages/cli/templates/blocks/components/Card/CardCallout.tsx@@ -1,30 +1,28 @@'use client';import {XDSCard} from '@xds/core/Card';-import {XDSVStack} from '@xds/core/Layout';-import {XDSHeading} from '@xds/core/Text';+import {XDSStack} from '@xds/core/Layout';+import {XDSHeading, XDSText} from '@xds/core/Text';export default function CardCallout() {return (- <div style={{display: 'flex', gap: 24, flexWrap: 'wrap'}}>- <XDSCard width={350} variant="muted">- <XDSVStack gap={2}>+ <XDSStack direction="horizontal" gap={4}>+ <XDSCard width={270} variant="muted">+ <XDSStack direction="vertical" gap={2}><XDSHeading level={3}>Tip</XDSHeading>- <p style={{margin: 0, fontSize: 14, color: '#666'}}>- Use the muted variant for callouts, tips, or highlighted- information. The muted background provides visual contrast without- needing a nested section.- </p>- </XDSVStack>+ <XDSText type="body" color="secondary">+ Use the muted variant for callouts or supplementary information.+ </XDSText>+ </XDSStack></XDSCard>- <XDSCard width={350} variant="muted">- <XDSVStack gap={2}>- <XDSHeading level={3}>Warning</XDSHeading>- <p style={{margin: 0, fontSize: 14, color: '#666'}}>- Muted cards work well for alerts and warnings too.- </p>- </XDSVStack>+ <XDSCard width={270} variant="muted">+ <XDSStack direction="vertical" gap={2}>+ <XDSHeading level={3}>Note</XDSHeading>+ <XDSText type="body" color="secondary">+ Muted cards work well in sidebars or help panels.+ </XDSText>+ </XDSStack></XDSCard>- </div>+ </XDSStack>);}diff --git a/packages/cli/templates/blocks/components/Card/CardNestedCards.doc.mjs b/packages/cli/templates/blocks/components/Card/CardNestedCards.doc.mjsdeleted file mode 100644index 8d369d8acd..0000000000--- a/packages/cli/templates/blocks/components/Card/CardNestedCards.doc.mjs+++ /dev/null@@ -1,10 +0,0 @@-/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */-export const doc = {- type: 'block',- name: 'Card — Nested Cards',- description:- 'Parent card containing nested child cards that reset their own padding.',- isReady: true,- aspectRatio: 4 / 3,- componentsUsed: ['Card', 'Layout', 'Text'],-};diff --git a/packages/cli/templates/blocks/components/Card/CardNestedCards.tsx b/packages/cli/templates/blocks/components/Card/CardNestedCards.tsxdeleted file mode 100644index 7dcc4f6ed0..0000000000--- a/packages/cli/templates/blocks/components/Card/CardNestedCards.tsx+++ /dev/null@@ -1,25 +0,0 @@-'use client';--import {XDSCard} from '@xds/core/Card';-import {XDSVStack} from '@xds/core/Layout';-import {XDSHeading} from '@xds/core/Text';--export default function CardNestedCards() {- return (- <XDSCard width={400}>- <XDSVStack gap={3}>- <XDSHeading level={3}>Parent Card</XDSHeading>- <XDSCard width="100%">- <p style={{margin: 0, fontSize: 14, color: '#666'}}>- Nested card resets container padding and gets its own padding.- </p>- </XDSCard>- <XDSCard width="100%">- <p style={{margin: 0, fontSize: 14, color: '#666'}}>- Another nested card with independent padding.- </p>- </XDSCard>- </XDSVStack>- </XDSCard>- );-}diff --git a/packages/cli/templates/blocks/components/Card/CardVariants.doc.mjs b/packages/cli/templates/blocks/components/Card/CardVariants.doc.mjsnew file mode 100644index 0000000000..2ace4f0192--- /dev/null+++ b/packages/cli/templates/blocks/components/Card/CardVariants.doc.mjs@@ -0,0 +1,9 @@+/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */+export const doc = {+ type: 'block',+ name: 'Card — Variants',+ description: 'Default, muted, and color variants side by side. Use color variants to categorize cards visually, like team colors, project tags, or content types. Each color uses the corresponding background token from the theme, so they adapt to light and dark mode automatically.',+ isReady: true,+ aspectRatio: 16 / 9,+ componentsUsed: ['Card', 'Layout', 'Text'],+};diff --git a/packages/cli/templates/blocks/components/Card/CardVariants.tsx b/packages/cli/templates/blocks/components/Card/CardVariants.tsxnew file mode 100644index 0000000000..6cc4037677--- /dev/null+++ b/packages/cli/templates/blocks/components/Card/CardVariants.tsx@@ -0,0 +1,37 @@+'use client';++import {XDSCard} from '@xds/core/Card';+import {XDSStack} from '@xds/core/Layout';+import {XDSText} from '@xds/core/Text';++const VARIANTS = [+ {variant: 'default' as const, label: 'General', note: '4 tasks due today'},+ {+ variant: 'muted' as const,+ label: 'Archived',+ note: 'No activity in 30 days',+ },+ {variant: 'blue' as const, label: 'Engineering', note: '12 open issues'},+ {variant: 'green' as const, label: 'Marketing', note: '3 campaigns active'},+ {variant: 'orange' as const, label: 'Urgent', note: '2 items need review'},+ {variant: 'purple' as const, label: 'Design', note: '5 drafts in progress'},+];++export default function CardVariants() {+ return (+ <XDSStack direction="horizontal" gap={3} style={{flexWrap: 'wrap'}}>+ {VARIANTS.map(({variant, label, note}) => (+ <XDSCard key={variant} variant={variant} width={160}>+ <XDSStack direction="vertical" gap={1}>+ <XDSText type="body" weight="bold">+ {label}+ </XDSText>+ <XDSText type="supporting" color="secondary">+ {note}+ </XDSText>+ </XDSStack>+ </XDSCard>+ ))}+ </XDSStack>+ );+}diff --git a/packages/cli/templates/blocks/components/Card/CardWithInnerLayout.doc.mjs b/packages/cli/templates/blocks/components/Card/CardWithInnerLayout.doc.mjsindex e15ec6fe9c..04749c0196 100644--- a/packages/cli/templates/blocks/components/Card/CardWithInnerLayout.doc.mjs+++ b/packages/cli/templates/blocks/components/Card/CardWithInnerLayout.doc.mjs@@ -1,10 +1,9 @@/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */export const doc = {type: 'block',- name: 'Card — With Inner Layout',- description:- 'Card using XDSLayout with header, scrollable content, and footer with action buttons.',+ name: 'Card — Layout',+ description: 'A card with a structured header, content area, and footer with action buttons. Use for forms, dialogs, or settings panels that need clear sections. Pair XDSCard with XDSLayout to get automatic dividers between header, content, and footer. The footer aligns actions to the right by default.',isReady: true,- aspectRatio: 4 / 3,+ aspectRatio: 16 / 9,componentsUsed: ['Card', 'Layout', 'Button', 'Text'],};diff --git a/packages/cli/templates/blocks/components/Card/CardWithInnerLayout.tsx b/packages/cli/templates/blocks/components/Card/CardWithInnerLayout.tsxindex 78e1706a26..074070a180 100644--- a/packages/cli/templates/blocks/components/Card/CardWithInnerLayout.tsx+++ b/packages/cli/templates/blocks/components/Card/CardWithInnerLayout.tsx@@ -9,30 +9,30 @@ import {XDSHStack,} from '@xds/core/Layout';import {XDSButton} from '@xds/core/Button';-import {XDSHeading} from '@xds/core/Text';+import {XDSHeading, XDSText} from '@xds/core/Text';export default function CardWithInnerLayout() {return (- <XDSCard width={350}>+ <XDSCard width={380}><XDSLayoutheader={<XDSLayoutHeader hasDivider>- <XDSHeading level={3}>Card with Layout</XDSHeading>+ <XDSHeading level={3}>Edit Profile</XDSHeading></XDSLayoutHeader>}content={<XDSLayoutContent>- <p style={{margin: 0, fontSize: 14, color: '#666'}}>- When using XDSLayout inside a card, the layout manages its own- padding and provides structured header, content, and footer areas.- </p>+ <XDSText type="body" color="secondary">+ Update your display name, bio, and profile photo. Changes are+ saved immediately.+ </XDSText></XDSLayoutContent>}footer={<XDSLayoutFooter hasDivider><XDSHStack gap={2} hAlign="end">- <XDSButton label="Cancel" variant="secondary" />- <XDSButton label="Save" variant="primary" />+ <XDSButton label="Cancel" variant="ghost" />+ <XDSButton label="Save changes" variant="primary" /></XDSHStack></XDSLayoutFooter>}diff --git a/packages/cli/templates/blocks/components/Card/CardWithSimpleContent.doc.mjs b/packages/cli/templates/blocks/components/Card/CardWithSimpleContent.doc.mjsindex 8ec9cac304..7501b6c729 100644--- a/packages/cli/templates/blocks/components/Card/CardWithSimpleContent.doc.mjs+++ b/packages/cli/templates/blocks/components/Card/CardWithSimpleContent.doc.mjs@@ -1,9 +1,9 @@/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */export const doc = {type: 'block',- name: 'Card — Simple Content',- description: 'Card with a heading and body text using the layout stack.',+ name: 'Card — Simple',+ description: 'A card with a heading and body text. Use for summaries, descriptions, or any grouped content that needs visual separation from the page. The card handles its own border, background, and padding — just pass your content as children. Set a width to constrain it, or leave it to fill the parent.',isReady: true,- aspectRatio: 4 / 3,+ aspectRatio: 16 / 9,componentsUsed: ['Card', 'Layout', 'Text'],};diff --git a/packages/cli/templates/blocks/components/Card/CardWithSimpleContent.tsx b/packages/cli/templates/blocks/components/Card/CardWithSimpleContent.tsxindex 1f93ade8b6..612bdfcfb8 100644--- a/packages/cli/templates/blocks/components/Card/CardWithSimpleContent.tsx+++ b/packages/cli/templates/blocks/components/Card/CardWithSimpleContent.tsx@@ -1,19 +1,22 @@'use client';import {XDSCard} from '@xds/core/Card';-import {XDSVStack} from '@xds/core/Layout';-import {XDSHeading} from '@xds/core/Text';+import {XDSStack} from '@xds/core/Layout';+import {XDSHeading, XDSText} from '@xds/core/Text';export default function CardWithSimpleContent() {return (- <XDSCard width={320}>- <XDSVStack gap={2}>- <XDSHeading level={3}>Card Title</XDSHeading>- <p style={{margin: 0, fontSize: 14, color: '#666'}}>- This card contains simple content with a heading and body text. The- container padding is applied automatically.- </p>- </XDSVStack>+ <XDSCard width={360}>+ <XDSStack direction="vertical" gap={2}>+ <XDSHeading level={3}>Project Overview</XDSHeading>+ <XDSText type="body" color="secondary">+ This project tracks the redesign of the onboarding flow. The goal is+ to reduce drop-off by 15% in Q2.+ </XDSText>+ <XDSText type="supporting" color="secondary">+ Last updated 2 hours ago+ </XDSText>+ </XDSStack></XDSCard>);}diff --git a/packages/core/src/Card/Card.doc.mjs b/packages/core/src/Card/Card.doc.mjsindex f652f6305c..21e4f32e2d 100644--- a/packages/core/src/Card/Card.doc.mjs+++ b/packages/core/src/Card/Card.doc.mjs@@ -5,16 +5,18 @@ export const docs = {keywords: ["card","surface","panel","container","elevated","shadow","box","paper","tile","well"],usage: {description:- 'Card is an elevated container that groups related information for visual organization. Use cards when explicit grouping is needed and sections alone do not provide enough visual distinction.',+ 'Card groups related content into a visually distinct container with a border and background. Use it for profile cards, settings panels, data summaries, or any content that needs to stand out from the page.',bestPractices: [- {guidance: true, description: 'Reserve cards for content that benefits from visual separation — default to sections first.'},- {guidance: true, description: 'Use a consistent padding value across sibling cards to maintain visual alignment.'},- {guidance: false, description: 'Nest cards inside other cards — flatten the hierarchy or use a different container.'},+ {guidance: true, description: 'Try a section first — only use a card when you need the visual separation of a border and elevated background.'},+ {guidance: true, description: 'Keep padding consistent across sibling cards so they align visually in a grid or list.'},+ {guidance: true, description: 'Use the muted variant for secondary content like tips, callouts, or background information.'},+ {guidance: true, description: 'Pair a card with XDSLayout when you need a structured header, scrollable content, and footer with actions.'},+ {guidance: false, description: 'Nest cards inside other cards — flatten the hierarchy or use a section instead.'},+ {guidance: false, description: 'Use color variants for status — use Banner or Badge for that. Color cards are for categorization.'},],anatomy: [- {name: 'Card Header', required: false, description: 'Displays a title and optional end content.'},- {name: 'Card Body', required: true, description: 'Accepts any content.'},- {name: 'Card Footer', required: false, description: 'Contains actions.'},+ {name: 'Container', required: true, description: 'The outer box with border, background, border-radius, and padding.'},+ {name: 'Content', required: true, description: 'Any children rendered inside the card. Often a stack of heading, text, and actions.'},],},props: [@@ -77,16 +79,18 @@ export const docsZh = {name: 'Card',usage: {description:- 'Card is an elevated container that groups related information for visual organization. Use cards when explicit grouping is needed and sections alone do not provide enough visual distinction.',+ 'Card groups related content into a visually distinct container with a border and background. Use it for profile cards, settings panels, data summaries, or any content that needs to stand out from the page.',bestPractices: [- {guidance: true, description: 'Reserve cards for content that benefits from visual separation — default to sections first.'},- {guidance: true, description: 'Use a consistent padding value across sibling cards to maintain visual alignment.'},- {guidance: false, description: 'Nest cards inside other cards — flatten the hierarchy or use a different container.'},+ {guidance: true, description: 'Try a section first — only use a card when you need the visual separation of a border and elevated background.'},+ {guidance: true, description: 'Keep padding consistent across sibling cards so they align visually in a grid or list.'},+ {guidance: true, description: 'Use the muted variant for secondary content like tips, callouts, or background information.'},+ {guidance: true, description: 'Pair a card with XDSLayout when you need a structured header, scrollable content, and footer with actions.'},+ {guidance: false, description: 'Nest cards inside other cards — flatten the hierarchy or use a section instead.'},+ {guidance: false, description: 'Use color variants for status — use Banner or Badge for that. Color cards are for categorization.'},],anatomy: [- {name: 'Card Header', required: false, description: 'Displays a title and optional end content.'},- {name: 'Card Body', required: true, description: 'Accepts any content.'},- {name: 'Card Footer', required: false, description: 'Contains actions.'},+ {name: 'Container', required: true, description: 'The outer box with border, background, border-radius, and padding.'},+ {name: 'Content', required: true, description: 'Any children rendered inside the card. Often a stack of heading, text, and actions.'},],},props: [@@ -114,19 +118,13 @@ export const docsZh = {/** @type {import('../docs-types').TranslationDoc} */export const docsDense = {- description: 'elevated container w/ themed styling',+ description: 'bordered container for grouping related content',usage: {description:- 'Card is an elevated container that groups related information for visual organization. Use cards when explicit grouping is needed and sections alone do not provide enough visual distinction.',+ 'Card groups related content with a border and background. Use for profile cards, settings panels, data summaries.',bestPractices: [- {guidance: true, description: 'Reserve cards for content that benefits from visual separation — default to sections first.'},- {guidance: true, description: 'Use a consistent padding value across sibling cards to maintain visual alignment.'},- {guidance: false, description: 'Nest cards inside other cards — flatten the hierarchy or use a different container.'},- ],- anatomy: [- {name: 'Card Header', required: false, description: 'Displays a title and optional end content.'},- {name: 'Card Body', required: true, description: 'Accepts any content.'},- {name: 'Card Footer', required: false, description: 'Contains actions.'},+ {guidance: true, description: 'Try a section first. Use muted variant for secondary content. Pair with XDSLayout for header/content/footer.'},+ {guidance: false, description: 'Nest cards. Use color variants for status — use Banner or Badge instead.'},],},propDescriptions: {