An open source design system that's fully customizable and agent ready
TypeScript
Improve Center docs page and block examples (#1558)
rubyycheung7869daa72fcf
diff --git a/packages/cli/templates/blocks/components/Center/CenterFullSize.doc.mjs b/packages/cli/templates/blocks/components/Center/CenterFullSize.doc.mjsdeleted file mode 100644index be7efa3e66..0000000000--- a/packages/cli/templates/blocks/components/Center/CenterFullSize.doc.mjs+++ /dev/null@@ -1,10 +0,0 @@-/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */-export const doc = {- type: 'block',- name: 'Center — Full Width Container',- description:- 'Content centered in a full-width container with a fixed height.',- isReady: true,- aspectRatio: 4 / 3,- componentsUsed: ['Center'],-};diff --git a/packages/cli/templates/blocks/components/Center/CenterFullSize.tsx b/packages/cli/templates/blocks/components/Center/CenterFullSize.tsxdeleted file mode 100644index 3ba41fdfe1..0000000000--- a/packages/cli/templates/blocks/components/Center/CenterFullSize.tsx+++ /dev/null@@ -1,19 +0,0 @@-'use client';--import {XDSCenter} from '@xds/core/Center';--export default function CenterFullSize() {- return (- <XDSCenter axis="both" width="100%" height={300}>- <div- style={{- padding: '16px 24px',- backgroundColor: '#e8f0fe',- borderRadius: 8,- fontWeight: 500,- }}>- Full Width, Fixed Height- </div>- </XDSCenter>- );-}diff --git a/packages/cli/templates/blocks/components/Center/CenterHorizontal.doc.mjs b/packages/cli/templates/blocks/components/Center/CenterHorizontal.doc.mjsnew file mode 100644index 0000000000..9b3bbc6eaa--- /dev/null+++ b/packages/cli/templates/blocks/components/Center/CenterHorizontal.doc.mjs@@ -0,0 +1,9 @@+/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */+export const doc = {+ type: 'block',+ name: 'Center — Horizontal Center',+ description: 'An editor toolbar with a document title on the left and formatting actions on the right. This shows axis="horizontal" — centering in one direction only. Use when content needs to be horizontally centered while other elements are positioned independently around it.',+ isReady: true,+ aspectRatio: 16 / 9,+ componentsUsed: ['Center', 'Card', 'Icon', 'IconButton', 'Layout', 'Text'],+};diff --git a/packages/cli/templates/blocks/components/Center/CenterHorizontal.tsx b/packages/cli/templates/blocks/components/Center/CenterHorizontal.tsxnew file mode 100644index 0000000000..ceda0648d1--- /dev/null+++ b/packages/cli/templates/blocks/components/Center/CenterHorizontal.tsx@@ -0,0 +1,64 @@+'use client';++import {XDSCenter} from '@xds/core/Center';+import {XDSCard} from '@xds/core/Card';+import {XDSStack} from '@xds/core/Layout';+import {XDSHeading} from '@xds/core/Text';+import {XDSIcon} from '@xds/core/Icon';+import {XDSIconButton} from '@xds/core/IconButton';+import {+ BoldIcon,+ ItalicIcon,+ UnderlineIcon,+ ListBulletIcon,+ LinkIcon,+ PhotoIcon,+} from '@heroicons/react/24/outline';++export default function CenterHorizontal() {+ return (+ <XDSCard width={520} padding={2}>+ <XDSStack direction="horizontal" vAlign="center">+ <XDSHeading level={2}>Untitled Document</XDSHeading>+ <XDSStack direction="horizontal" gap={0} hAlign="end" style={{flex: 1}}>+ <XDSIconButton+ label="Bold"+ icon={<XDSIcon icon={BoldIcon} />}+ variant="ghost"+ size="sm"+ />+ <XDSIconButton+ label="Italic"+ icon={<XDSIcon icon={ItalicIcon} />}+ variant="ghost"+ size="sm"+ />+ <XDSIconButton+ label="Underline"+ icon={<XDSIcon icon={UnderlineIcon} />}+ variant="ghost"+ size="sm"+ />+ <XDSIconButton+ label="List"+ icon={<XDSIcon icon={ListBulletIcon} />}+ variant="ghost"+ size="sm"+ />+ <XDSIconButton+ label="Link"+ icon={<XDSIcon icon={LinkIcon} />}+ variant="ghost"+ size="sm"+ />+ <XDSIconButton+ label="Image"+ icon={<XDSIcon icon={PhotoIcon} />}+ variant="ghost"+ size="sm"+ />+ </XDSStack>+ </XDSStack>+ </XDSCard>+ );+}diff --git a/packages/cli/templates/blocks/components/Center/CenterInlineCenter.doc.mjs b/packages/cli/templates/blocks/components/Center/CenterInlineCenter.doc.mjsdeleted file mode 100644index 6707c16def..0000000000--- a/packages/cli/templates/blocks/components/Center/CenterInlineCenter.doc.mjs+++ /dev/null@@ -1,10 +0,0 @@-/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */-export const doc = {- type: 'block',- name: 'Center — Inline Centering',- description:- 'Inline-flex centering used to vertically align an icon within a line of text.',- isReady: true,- aspectRatio: 4 / 3,- componentsUsed: ['Center', 'Card', 'Text'],-};diff --git a/packages/cli/templates/blocks/components/Center/CenterInlineCenter.tsx b/packages/cli/templates/blocks/components/Center/CenterInlineCenter.tsxdeleted file mode 100644index 7c894f8be4..0000000000--- a/packages/cli/templates/blocks/components/Center/CenterInlineCenter.tsx+++ /dev/null@@ -1,37 +0,0 @@-'use client';--import {XDSCenter} from '@xds/core/Center';-import {XDSCard} from '@xds/core/Card';-import {XDSText} from '@xds/core/Text';--function CheckIcon() {- return (- <svg- width={16}- height={16}- viewBox="0 0 24 24"- fill="none"- stroke="currentColor"- strokeWidth={2}>- <path- strokeLinecap="round"- strokeLinejoin="round"- d="M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"- />- </svg>- );-}--export default function CenterInlineCenter() {- return (- <XDSCard>- <XDSText type="body">- Text with inline centered icon:{' '}- <XDSCenter isInline>- <CheckIcon />- </XDSCenter>{' '}- and more text after.- </XDSText>- </XDSCard>- );-}diff --git a/packages/cli/templates/blocks/components/Center/CenterInsideACard.doc.mjs b/packages/cli/templates/blocks/components/Center/CenterInsideACard.doc.mjsindex 39b0bf8d2e..5bc4ca1f72 100644--- a/packages/cli/templates/blocks/components/Center/CenterInsideACard.doc.mjs+++ b/packages/cli/templates/blocks/components/Center/CenterInsideACard.doc.mjs@@ -1,9 +1,9 @@/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */export const doc = {type: 'block',- name: 'Center — Inside a Card',- description: 'Content centered vertically and horizontally within a card.',+ name: 'Center — Vertical & Horizontal Center',+ description: 'An empty state with an icon, heading, and description centered both vertically and horizontally inside a card. This is the most common use of Center — placing content in the middle of a fixed-height area like a panel, card, or content region. The height prop defines the centering space.',isReady: true,aspectRatio: 4 / 3,- componentsUsed: ['Center', 'Card'],+ componentsUsed: ['Center', 'Card', 'Icon', 'Layout', 'Text'],};diff --git a/packages/cli/templates/blocks/components/Center/CenterInsideACard.tsx b/packages/cli/templates/blocks/components/Center/CenterInsideACard.tsxindex 9afa8c68aa..14b376c432 100644--- a/packages/cli/templates/blocks/components/Center/CenterInsideACard.tsx+++ b/packages/cli/templates/blocks/components/Center/CenterInsideACard.tsx@@ -2,20 +2,24 @@import {XDSCenter} from '@xds/core/Center';import {XDSCard} from '@xds/core/Card';+import {XDSStack} from '@xds/core/Layout';+import {XDSIcon} from '@xds/core/Icon';+import {XDSText} from '@xds/core/Text';+import {InboxIcon} from '@heroicons/react/24/outline';export default function CenterInsideACard() {return (- <XDSCard>- <XDSCenter height={150}>- <div- style={{- padding: '16px 24px',- backgroundColor: '#e8f0fe',- borderRadius: 8,- fontWeight: 500,- }}>- Centered in Card- </div>+ <XDSCard width={400}>+ <XDSCenter height={200}>+ <XDSStack direction="vertical" gap={2} hAlign="center">+ <XDSIcon icon={InboxIcon} size="lg" color="secondary" />+ <XDSText type="body" weight="bold">+ No messages yet+ </XDSText>+ <XDSText type="supporting" color="secondary">+ Messages from your team will appear here.+ </XDSText>+ </XDSStack></XDSCenter></XDSCard>);diff --git a/packages/core/src/Center/Center.doc.mjs b/packages/core/src/Center/Center.doc.mjsindex cec84f9026..0a79e0ce06 100644--- a/packages/core/src/Center/Center.doc.mjs+++ b/packages/core/src/Center/Center.doc.mjs@@ -45,11 +45,17 @@ export const docs = {},usage: {description:- 'Center is a layout primitive that centers its children horizontally and/or vertically using flexbox. Use it to quickly align content within a container without writing custom centering styles.',+ 'Center aligns content to the middle of its container. Use it for empty states, loading screens, login forms, or any content that should sit in the center of the available space.',bestPractices: [- {guidance: true, description: 'Use the axis prop to center only in the direction you need — avoid unnecessary centering on both axes.'},- {guidance: true, description: 'Set isInline when centering small inline content like icons or text within a line.'},- {guidance: false, description: 'Wrap large page sections in Center — use XDSLayout for page-level structure instead.'},+ {guidance: true, description: 'Use axis="horizontal" or axis="vertical" when you only need one direction — both axes is the default but not always needed.'},+ {guidance: true, description: 'Set a height when centering vertically — Center needs a defined height to know what space to center within.'},+ {guidance: true, description: 'Use isInline to center small elements like icons or badges within a line of text without breaking the text flow.'},+ {guidance: false, description: 'Wrap large page sections in Center — use XDSLayout or XDSAppShell for page-level structure.'},+ {guidance: false, description: 'Use Center for horizontal lists of items — use XDSStack with hAlign="center" instead.'},+ ],+ anatomy: [+ {name: 'Container', required: true, description: 'A flexbox wrapper that aligns its children to the center along the chosen axis.'},+ {name: 'Content', required: true, description: 'Any children passed to Center. Typically a card, form, spinner, or empty state message.'},],},};@@ -59,11 +65,13 @@ export const docsZh = {name: 'Center',usage: {description:- 'Center is a layout primitive that centers its children horizontally and/or vertically using flexbox. Use it to quickly align content within a container without writing custom centering styles.',+ 'Center aligns content to the middle of its container. Use it for empty states, loading screens, login forms, or any content that should sit in the center of the available space.',bestPractices: [- {guidance: true, description: 'Use the axis prop to center only in the direction you need — avoid unnecessary centering on both axes.'},- {guidance: true, description: 'Set isInline when centering small inline content like icons or text within a line.'},- {guidance: false, description: 'Wrap large page sections in Center — use XDSLayout for page-level structure instead.'},+ {guidance: true, description: 'Use axis="horizontal" or axis="vertical" when you only need one direction — both axes is the default but not always needed.'},+ {guidance: true, description: 'Set a height when centering vertically — Center needs a defined height to know what space to center within.'},+ {guidance: true, description: 'Use isInline to center small elements like icons or badges within a line of text without breaking the text flow.'},+ {guidance: false, description: 'Wrap large page sections in Center — use XDSLayout or XDSAppShell for page-level structure.'},+ {guidance: false, description: 'Use Center for horizontal lists of items — use XDSStack with hAlign="center" instead.'},],},props: [@@ -93,14 +101,13 @@ export const docsZh = {/** @type {import('../docs-types').TranslationDoc} */export const docsDense = {- description: 'centers children horizontally+vertically via flexbox',+ description: 'centers content horizontally and/or vertically via flexbox',usage: {description:- 'Center is a layout primitive that centers its children horizontally and/or vertically using flexbox. Use it to quickly align content within a container without writing custom centering styles.',+ 'Center aligns content to the middle of its container. Use for empty states, loading screens, login forms.',bestPractices: [- {guidance: true, description: 'Use the axis prop to center only in the direction you need — avoid unnecessary centering on both axes.'},- {guidance: true, description: 'Set isInline when centering small inline content like icons or text within a line.'},- {guidance: false, description: 'Wrap large page sections in Center — use XDSLayout for page-level structure instead.'},+ {guidance: true, description: 'Set axis when you only need one direction. Set height for vertical centering. Use isInline for icons in text.'},+ {guidance: false, description: 'Wrap page sections — use XDSLayout. Use for horizontal lists — use XDSStack with hAlign="center".'},],},propDescriptions: {