An open source design system that's fully customizable and agent ready
TypeScript
feat(button): add isIconOnly prop — explicit opt-in for icon-only mode (#1257) (#1260)
Cindy Zhang687470243f70
diff --git a/.github/scripts/codemod-verify.mjs b/.github/scripts/codemod-verify.mjsindex c1f52c4bda..59787e8ed5 100644--- a/.github/scripts/codemod-verify.mjs+++ b/.github/scripts/codemod-verify.mjs@@ -109,9 +109,16 @@ async function main() {}// Determine the version range for codemods- // Run ALL codemods up to the latest modified version to be thorough+ // Only run the new versions added in this PR — the base branch already+ // has earlier codemod changes applied to consumer files.+ const earliestVersion = codemodVersions[0];const latestVersion = codemodVersions[codemodVersions.length - 1];+ // Find the version just before the earliest modified one+ const {versions: allVersions} = await import('../../packages/cli/src/codemods/registry.mjs');+ const earliestIdx = allVersions.indexOf(earliestVersion);+ const fromVersion = earliestIdx > 0 ? allVersions[earliestIdx - 1] : '0.0.0';+// Run codemods on each affected consumer directoryconst affectedDirs = [...new Set(@@ -120,8 +127,8 @@ async function main() {];for (const dir of affectedDirs) {- console.log(`Running codemods (0.0.0 → ${latestVersion}) on ${dir}/...`);- const manifests = await getTransformsBetween('0.0.0', latestVersion);+ console.log(`Running codemods (${fromVersion} → ${latestVersion}) on ${dir}/...`);+ const manifests = await getTransformsBetween(fromVersion, latestVersion);if (manifests.length === 0) {console.log(' No applicable codemods found.');continue;diff --git a/apps/sandbox/src/app/(fullscreen)/PreviewShell.tsx b/apps/sandbox/src/app/(fullscreen)/PreviewShell.tsxindex ea9a6dadd7..2a2c8f791e 100644--- a/apps/sandbox/src/app/(fullscreen)/PreviewShell.tsx+++ b/apps/sandbox/src/app/(fullscreen)/PreviewShell.tsx@@ -408,6 +408,7 @@ export function PreviewShell({children}: {children: React.ReactNode}) {)}onClick={() => setMode(mode === 'light' ? 'dark' : 'light')}+ isIconOnly/><XDSButtonvariant="ghost"@@ -421,9 +422,9 @@ export function PreviewShell({children}: {children: React.ReactNode}) {)}onClick={handleCopy}+ isIconOnly/></div>-{/* Content */}{view === 'preview' ? (<divdiff --git a/apps/sandbox/src/app/(fullscreen)/pages/doc-docs/page.tsx b/apps/sandbox/src/app/(fullscreen)/pages/doc-docs/page.tsxindex 4078c4715a..f414251178 100644--- a/apps/sandbox/src/app/(fullscreen)/pages/doc-docs/page.tsx+++ b/apps/sandbox/src/app/(fullscreen)/pages/doc-docs/page.tsx@@ -343,6 +343,7 @@ export default function DocDocsPage() {variant="ghost"size="sm"icon={<HamburgerIcon />}+ isIconOnly/><spanstyle={{@@ -375,6 +376,7 @@ export default function DocDocsPage() {variant="ghost"size="sm"icon={<SidebarCollapseIcon />}+ isIconOnly/></div>@@ -455,7 +457,6 @@ export default function DocDocsPage() {)}</nav></aside>-{/* ================================================================= */}{/* MAIN CONTENT */}{/* ================================================================= */}@@ -524,6 +525,7 @@ export default function DocDocsPage() {variant="ghost"size="sm"icon={<ExternalLinkIcon />}+ isIconOnly/><XDSDropdownMenubutton={{@@ -556,12 +558,14 @@ export default function DocDocsPage() {size="sm"icon={<CodeIcon />}onClick={() => setShowCode(!showCode)}+ isIconOnly/><XDSButtonlabel="Fullscreen"variant="ghost"size="sm"icon={<FullscreenIcon />}+ isIconOnly/></div></div>@@ -586,9 +590,8 @@ export default function DocDocsPage() {label="Button"variant="primary"icon={<PlusIcon />}- endContent={<XDSBadge label="New" variant="info" />}>- Button- </XDSButton>+ endContent={<XDSBadge label="New" variant="info" />}+ /></div>{/* Code Panel */}@@ -690,7 +693,6 @@ export default function DocDocsPage() {</ul></div></main>-{/* ================================================================= */}{/* RIGHT SIDEBAR */}{/* ================================================================= */}diff --git a/apps/sandbox/src/app/(fullscreen)/pages/docsite/page.tsx b/apps/sandbox/src/app/(fullscreen)/pages/docsite/page.tsxindex cd142de58e..07a51c88c4 100644--- a/apps/sandbox/src/app/(fullscreen)/pages/docsite/page.tsx+++ b/apps/sandbox/src/app/(fullscreen)/pages/docsite/page.tsx@@ -698,6 +698,7 @@ function TemplateCard({size: 'sm',icon: <MoreIcon />,style: {color: '#fff'},+ isIconOnly: true,}}hasChevron={false}items={[@@ -856,6 +857,7 @@ function AIComposer() {variant="ghost"size="sm"icon={<PlusIcon />}+ isIconOnly/><XDSButtonlabel="Send"@@ -863,6 +865,7 @@ function AIComposer() {size="sm"icon={<SendIcon />}style={{borderRadius: 9999}}+ isIconOnly/></div></div>@@ -961,6 +964,7 @@ function ChatPanel({variant: 'ghost',size: 'sm',icon: <HamburgerIcon />,+ isIconOnly: true,}}hasChevron={false}items={[@@ -1008,9 +1012,9 @@ function ChatPanel({variant="ghost"size="sm"icon={<SidebarIcon />}+ isIconOnly/></div>-{/* Chat thread */}<div style={{flex: 1, padding: 16, overflow: 'auto'}}>{/* User message */}@@ -1044,7 +1048,6 @@ function ChatPanel({<ShimmerText isActive={isGenerating} /></div></div>-{/* Composer pinned to bottom */}<div style={{padding: 12}}><div@@ -1100,6 +1103,7 @@ function ChatPanel({variant="ghost"size="sm"icon={<PlusIcon />}+ isIconOnly/><XDSButtonlabel="Send"@@ -1108,6 +1112,7 @@ function ChatPanel({icon={<SendIcon />}style={{borderRadius: 9999}}onClick={onSend}+ isIconOnly/></div></div>@@ -1362,12 +1367,14 @@ function TemplatePreview({icon={<ArrowLeftIcon />}onClick={onBack}style={{marginLeft: -8}}+ isIconOnly/><XDSTooltip content="Point" placement="below"><XDSButtonlabel="Point"variant="ghost"icon={<CursorIcon />}+ isIconOnly/></XDSTooltip><XDSDropdownMenu@@ -1375,6 +1382,7 @@ function TemplatePreview({label: 'Theme',variant: 'ghost',icon: <PaletteIcon />,+ isIconOnly: true,}}hasChevron={false}items={XDS_THEMES.map(t => ({@@ -1883,6 +1891,7 @@ function AppTopNav({variant="ghost"size="sm"icon={<FilterIcon />}+ isIconOnly/><XDSButtonlabel="Search"@@ -1890,6 +1899,7 @@ function AppTopNav({size="sm"icon={<SearchIcon />}onClick={() => setIsSearchOpen(true)}+ isIconOnly/><XDSButtonlabel="Profile"@@ -1897,6 +1907,7 @@ function AppTopNav({size="sm"icon={<ProfileIcon />}onClick={() => setActiveView('profile')}+ isIconOnly/></div></nav>@@ -2154,6 +2165,7 @@ function DocsView({variant="ghost"size="sm"icon={<SidebarCollapseIcon />}+ isIconOnly/></div>@@ -2234,7 +2246,6 @@ function DocsView({)}</nav></aside>-{/* MAIN CONTENT */}<mainstyle={{@@ -2299,6 +2310,7 @@ function DocsView({variant="ghost"size="sm"icon={<ExternalLinkIcon />}+ isIconOnly/><XDSDropdownMenubutton={{@@ -2331,12 +2343,14 @@ function DocsView({size="sm"icon={<CodeIcon />}onClick={() => setShowCode(!showCode)}+ isIconOnly/><XDSButtonlabel="Fullscreen"variant="ghost"size="sm"icon={<FullscreenIcon />}+ isIconOnly/></div></div>@@ -2361,9 +2375,8 @@ function DocsView({label="Button"variant="primary"icon={<PlusIcon />}- endContent={<XDSBadge label="New" variant="info" />}>- Button- </XDSButton>+ endContent={<XDSBadge label="New" variant="info" />}+ /></div>{/* Code Panel */}@@ -2463,7 +2476,6 @@ function DocsView({</ul></div></main>-{/* RIGHT SIDEBAR */}<asidestyle={{@@ -2679,24 +2691,24 @@ function ExploreView({variant="ghost"size="sm"icon={<SearchIcon />}+ isIconOnly/><XDSButtonlabel="Create new"variant="secondary"size="sm"- icon={<PlusIcon />}>- Create new- </XDSButton>+ icon={<PlusIcon />}+ /><XDSButtonlabel="Profile"variant="ghost"size="sm"icon={<ProfileIcon />}onClick={() => setActiveView('profile')}+ isIconOnly/></div></nav>-{/* Scrollable content */}<divstyle={{@@ -3332,16 +3344,17 @@ function ProfileView({variant="ghost"size="sm"icon={<SearchIcon />}+ isIconOnly/><XDSButtonlabel="Profile"variant="ghost"size="sm"icon={<ProfileIcon />}+ isIconOnly/></div></nav>-{/* Scrollable content */}<divstyle={{@@ -3456,9 +3469,8 @@ function ProfileView({<XDSButtonlabel="New collection"variant="secondary"- icon={<PlusIcon />}>- New collection- </XDSButton>+ icon={<PlusIcon />}+ /></div><divstyle={{@@ -3563,9 +3575,8 @@ function ProfileView({label="Create new"variant="secondary"size="sm"- icon={<PlusIcon />}>- Create new- </XDSButton>+ icon={<PlusIcon />}+ /></div><divstyle={{diff --git a/apps/sandbox/src/app/(fullscreen)/pages/shell-lab/page.tsx b/apps/sandbox/src/app/(fullscreen)/pages/shell-lab/page.tsxindex 1984c6e196..fefb5bc506 100644--- a/apps/sandbox/src/app/(fullscreen)/pages/shell-lab/page.tsx+++ b/apps/sandbox/src/app/(fullscreen)/pages/shell-lab/page.tsx@@ -528,6 +528,7 @@ function SampleSideNav({</svg>}variant="ghost"+ isIconOnly/><XDSButtonlabel="Settings"@@ -545,6 +546,7 @@ function SampleSideNav({</svg>}variant="ghost"+ isIconOnly/></>) : undefined@@ -718,6 +720,7 @@ function SampleTopNav({</svg>}onClick={onToggleCollapse}+ isIconOnly/>)}</>diff --git a/apps/sandbox/src/app/(fullscreen)/pages/theme-editor/page.tsx b/apps/sandbox/src/app/(fullscreen)/pages/theme-editor/page.tsxindex 89413c526d..d528a77f0f 100644--- a/apps/sandbox/src/app/(fullscreen)/pages/theme-editor/page.tsx+++ b/apps/sandbox/src/app/(fullscreen)/pages/theme-editor/page.tsx@@ -1937,6 +1937,7 @@ function MotionPreview() {variant="ghost"size="sm"onClick={() => setOverlayOpen(false)}+ isIconOnly/></div></div>@@ -1973,6 +1974,7 @@ function MotionPreview() {variant="ghost"size="sm"onClick={() => setPushOpen(false)}+ isIconOnly/></div>{selectedUser && (@@ -3205,7 +3207,6 @@ function ThemeEditorComponent() {/></div></div>-{/* Right Panel - Preview */}<divstyle={{@@ -3349,6 +3350,7 @@ function ThemeEditorComponent() {variant="ghost"size="sm"onClick={() => setOverlayPanelOpen(false)}+ isIconOnly/></div><div style={{padding: 'var(--spacing-3)'}}>@@ -3390,6 +3392,7 @@ function ThemeEditorComponent() {variant="ghost"size="sm"onClick={() => setPushPanelOpen(false)}+ isIconOnly/></div><divdiff --git a/apps/sandbox/src/app/SandboxNav.tsx b/apps/sandbox/src/app/SandboxNav.tsxindex 70e06d73d0..b95a593d36 100644--- a/apps/sandbox/src/app/SandboxNav.tsx+++ b/apps/sandbox/src/app/SandboxNav.tsx@@ -72,6 +72,7 @@ function SandboxHeader() {<XDSDropdownMenubutton={{label: 'Theme',+icon: (<PaletteIconwidth={16}@@ -79,8 +80,10 @@ function SandboxHeader() {style={{color: 'var(--color-icon-secondary)'}}/>),+variant: 'ghost',size: 'sm',+ isIconOnly: true,}}menuWidth={160}items={themeItems}@@ -88,6 +91,7 @@ function SandboxHeader() {<XDSDropdownMenubutton={{label: mode === 'dark' ? 'Dark mode' : 'Light mode',+icon:mode === 'dark' ? (<MoonIcon@@ -102,8 +106,10 @@ function SandboxHeader() {style={{color: 'var(--color-icon-secondary)'}}/>),+variant: 'ghost',size: 'sm',+ isIconOnly: true,}}menuWidth={160}items={modeItems}diff --git a/apps/storybook/stories/AnalyticsDashboard.stories.tsx b/apps/storybook/stories/AnalyticsDashboard.stories.tsxindex 3f02809f41..cf26ba358f 100644--- a/apps/storybook/stories/AnalyticsDashboard.stories.tsx+++ b/apps/storybook/stories/AnalyticsDashboard.stories.tsx@@ -890,6 +890,7 @@ function ChartCard({size="xs"icon={<InformationCircleIcon style={{width: 14, height: 14}} />}onClick={() => setIsInfoOpen(true)}+ isIconOnly/><XDSMoreMenulabel="Refresh"@@ -911,7 +912,6 @@ function ChartCard({<div {...stylex.props(styles.chartInner)}>{children}</div></XDSVStack></XDSCard>-<XDSDialogisOpen={isInfoOpen}onOpenChange={setIsInfoOpen}@@ -960,6 +960,7 @@ function ChartCard({style={{width: 14, height: 14}}/>}+ isIconOnly/><XDSButtonlabel="Download image"@@ -969,6 +970,7 @@ function ChartCard({icon={<ArrowDownTrayIcon style={{width: 14, height: 14}} />}+ isIconOnly/></XDSHStack></XDSHStack>@@ -1099,7 +1101,6 @@ function OverviewContent() {<XDSTab value="usage" label="Overview" /><XDSTab value="ds-details" label="Design System Details" /></XDSTabList>-{ovTab === 'usage' && (<XDSVStack gap={6}><XDSVStack gap={3}>@@ -1143,7 +1144,6 @@ function OverviewContent() {</XDSVStack></XDSVStack>)}-{ovTab === 'ds-details' && (<XDSVStack gap={6}><div {...stylex.props(styles.chartsGrid)}>@@ -1285,6 +1285,7 @@ function OverviewContent() {icon={<InformationCircleIcon style={{width: 14, height: 14}} />}+ isIconOnly/><XDSMoreMenulabel="Refresh"@@ -1356,6 +1357,7 @@ function AnalyticsDashboard() {onClick={() =>window.open('https://example.com/dashboard', '_blank')}+ isIconOnly/><XDSButtonlabel="Nest"@@ -1364,11 +1366,11 @@ function AnalyticsDashboard() {onClick={() =>window.open('https://example.com/dashboard', '_blank')}+ isIconOnly/></>}/>-<div {...stylex.props(styles.page)}><XDSVStack gap={6}><OverviewContent />diff --git a/apps/storybook/stories/AppShell.stories.tsx b/apps/storybook/stories/AppShell.stories.tsxindex fa70b58b76..ea5d7178a8 100644--- a/apps/storybook/stories/AppShell.stories.tsx+++ b/apps/storybook/stories/AppShell.stories.tsx@@ -107,6 +107,7 @@ function AppTopNav({endContent}: {endContent?: React.ReactNode}) {label="Profile"variant="ghost"icon={<UserCircleIcon style={{width: 16, height: 16}} />}+ isIconOnly/>)}@@ -382,16 +383,19 @@ export const FullFeatured: Story = {icon={<QuestionMarkCircleIcon style={{width: 16, height: 16}} />}+ isIconOnly/><XDSButtonlabel="Notifications"variant="ghost"icon={<BellIcon style={{width: 16, height: 16}} />}+ isIconOnly/><XDSButtonlabel="Profile"variant="ghost"icon={<UserCircleIcon style={{width: 16, height: 16}} />}+ isIconOnly/></>}>@@ -505,6 +509,7 @@ export const ControlledCollapse: Story = {variant="ghost"icon={<Bars3Icon style={{width: 16, height: 16}} />}onClick={() => setCollapsed(!collapsed)}+ isIconOnly/>}/>@@ -639,6 +644,7 @@ export const WithMobileNav: Story = {variant="ghost"icon={<XDSIcon icon="menu" color="inherit" />}onClick={() => setMobileNavOpen(true)}+ isIconOnly/>) : (<>@@ -654,11 +660,13 @@ export const WithMobileNav: Story = {label="Notifications"variant="ghost"icon={<BellIcon style={{width: 16, height: 16}} />}+ isIconOnly/><XDSButtonlabel="Profile"variant="ghost"icon={<UserCircleIcon style={{width: 16, height: 16}} />}+ isIconOnly/></>}diff --git a/apps/storybook/stories/Button.stories.tsx b/apps/storybook/stories/Button.stories.tsxindex 1dea8407b0..7a6ae70440 100644--- a/apps/storybook/stories/Button.stories.tsx+++ b/apps/storybook/stories/Button.stories.tsx@@ -101,11 +101,13 @@ export const IconOnly: Story = {label="Settings"variant="ghost"icon={<Cog6ToothIcon style={{width: 16, height: 16}} />}+ isIconOnly/><XDSButtonlabel="Delete"variant="destructive"icon={<TrashIcon style={{width: 16, height: 16}} />}+ isIconOnly/></div>),@@ -117,15 +119,13 @@ export const IconWithText: Story = {<XDSButtonlabel="Settings"variant="secondary"- icon={<Cog6ToothIcon style={{width: 16, height: 16}} />}>- Settings- </XDSButton>+ icon={<Cog6ToothIcon style={{width: 16, height: 16}} />}+ /><XDSButtonlabel="Delete"variant="destructive"- icon={<TrashIcon style={{width: 16, height: 16}} />}>- Delete- </XDSButton>+ icon={<TrashIcon style={{width: 16, height: 16}} />}+ /></div>),};@@ -154,16 +154,14 @@ export const IconAndEndSlot: Story = {label="Settings"variant="secondary"icon={<Cog6ToothIcon style={{width: 16, height: 16}} />}- endContent={<XDSBadge variant="info" label="New" />}>- Settings- </XDSButton>+ endContent={<XDSBadge variant="info" label="New" />}+ /><XDSButtonlabel="Delete"variant="destructive"icon={<TrashIcon style={{width: 16, height: 16}} />}- endContent={<XDSBadge variant="error" label={5} />}>- Delete- </XDSButton>+ endContent={<XDSBadge variant="error" label={5} />}+ /></div>),};@@ -200,17 +198,18 @@ export const AllVariants: Story = {label="Settings"variant="ghost"icon={<Cog6ToothIcon style={{width: 16, height: 16}} />}+ isIconOnly/><XDSButtonlabel="Settings"variant="secondary"- icon={<Cog6ToothIcon style={{width: 16, height: 16}} />}>- Settings- </XDSButton>+ icon={<Cog6ToothIcon style={{width: 16, height: 16}} />}+ /><XDSButtonlabel="Delete"variant="destructive"icon={<TrashIcon style={{width: 16, height: 16}} />}+ isIconOnly/></div><div style={{display: 'flex', gap: '12px', alignItems: 'center'}}>@@ -287,14 +286,14 @@ export const LinkButton: Story = {label="Settings"href="https://example.com"variant="secondary"- icon={<Cog6ToothIcon style={{width: 16, height: 16}} />}>- Settings- </XDSButton>+ icon={<Cog6ToothIcon style={{width: 16, height: 16}} />}+ /><XDSButtonlabel="Icon-only link"href="https://example.com"variant="ghost"icon={<Cog6ToothIcon style={{width: 16, height: 16}} />}+ isIconOnly/></div></div>@@ -318,6 +317,7 @@ export const Truncation: Story = {label="A very long button label that overflows"variant="primary"icon={<Cog6ToothIcon style={{width: 16, height: 16}} />}+ isIconOnly/></div></div>@@ -344,6 +344,7 @@ export const Truncation: Story = {label="A very long button label that shows fully"variant="primary"icon={<Cog6ToothIcon style={{width: 16, height: 16}} />}+ isIconOnly/></div></div>diff --git a/apps/storybook/stories/Chat.stories.tsx b/apps/storybook/stories/Chat.stories.tsxindex ea8f2078ac..226bb2ca61 100644--- a/apps/storybook/stories/Chat.stories.tsx+++ b/apps/storybook/stories/Chat.stories.tsx@@ -555,12 +555,14 @@ For server state, use a library like **TanStack Query** or **SWR**.`}</XDSMarkdoicon={<HandThumbUpIcon style={{width: 14, height: 14}} />}variant="ghost"size="sm"+ isIconOnly/><XDSButtonlabel="Thumbs down"icon={<HandThumbDownIcon style={{width: 14, height: 14}} />}variant="ghost"size="sm"+ isIconOnly/></>}@@ -587,12 +589,14 @@ For server state, use a library like **TanStack Query** or **SWR**.`}</XDSMarkdoicon={<HandThumbUpIcon style={{width: 14, height: 14}} />}variant="ghost"size="sm"+ isIconOnly/><XDSButtonlabel="Thumbs down"icon={<HandThumbDownIcon style={{width: 14, height: 14}} />}variant="ghost"size="sm"+ isIconOnly/><XDSButtonlabel="Copy"@@ -601,6 +605,7 @@ For server state, use a library like **TanStack Query** or **SWR**.`}</XDSMarkdo}variant="ghost"size="sm"+ isIconOnly/></>}diff --git a/apps/storybook/stories/ChatComposer.stories.tsx b/apps/storybook/stories/ChatComposer.stories.tsxindex b1f6eae9f5..334331a874 100644--- a/apps/storybook/stories/ChatComposer.stories.tsx+++ b/apps/storybook/stories/ChatComposer.stories.tsx@@ -121,6 +121,7 @@ export const WithFooterActions: Story = {size="md"icon={MicIcon}iconOnly+ isIconOnly/>}/>@@ -145,6 +146,7 @@ export const WithAttachments: Story = {size="sm"icon={PaperclipIcon}iconOnly+ isIconOnly/>}headerContext={@@ -181,6 +183,7 @@ export const FullFeatured: Story = {size="sm"icon={AtSignIcon}iconOnly+ isIconOnly/><XDSButtonlabel="Attach file"@@ -188,6 +191,7 @@ export const FullFeatured: Story = {size="sm"icon={PaperclipIcon}iconOnly+ isIconOnly/></>}@@ -207,6 +211,7 @@ export const FullFeatured: Story = {size="md"icon={MicIcon}iconOnly+ isIconOnly/>}/>diff --git a/apps/storybook/stories/DropdownMenu.stories.tsx b/apps/storybook/stories/DropdownMenu.stories.tsxindex 2db644ac54..faae7c6eb5 100644--- a/apps/storybook/stories/DropdownMenu.stories.tsx+++ b/apps/storybook/stories/DropdownMenu.stories.tsx@@ -311,6 +311,7 @@ export const IconOnly: Story = {label: 'More options',icon: <EllipsisHorizontalIcon />,variant: 'ghost',+ isIconOnly: true,}}items={[{label: 'Edit', icon: PencilIcon, onClick: () => console.log('Edit')},@@ -326,6 +327,7 @@ export const IconOnly: Story = {label: 'Settings',icon: <Cog6ToothIcon />,variant: 'secondary',+ isIconOnly: true,}}items={[{label: 'Preferences', onClick: () => console.log('Preferences')},diff --git a/apps/storybook/stories/MobileNav.stories.tsx b/apps/storybook/stories/MobileNav.stories.tsxindex 0dfda8e912..a87079ddb3 100644--- a/apps/storybook/stories/MobileNav.stories.tsx+++ b/apps/storybook/stories/MobileNav.stories.tsx@@ -54,6 +54,7 @@ export const Default: Story = {icon={<XDSIcon icon="menu" color="inherit" />}variant="ghost"onClick={() => setIsOpen(true)}+ isIconOnly/><XDSMobileNavisOpen={isOpen}@@ -199,6 +200,7 @@ export const ResponsivePattern: Story = {icon={<XDSIcon icon="menu" color="inherit" />}variant="ghost"onClick={() => setDrawerOpen(true)}+ isIconOnly/><XDSMobileNavisOpen={drawerOpen}@@ -312,6 +314,7 @@ export const WithoutTitle: Story = {icon={<XDSIcon icon="menu" color="inherit" />}variant="ghost"onClick={() => setIsOpen(true)}+ isIconOnly/><XDSMobileNav isOpen={isOpen} onOpenChange={open => setIsOpen(open)}><XDSSideNavSection title="Main">diff --git a/apps/storybook/stories/SideNav.stories.tsx b/apps/storybook/stories/SideNav.stories.tsxindex 94a4cd7bb9..415103552c 100644--- a/apps/storybook/stories/SideNav.stories.tsx+++ b/apps/storybook/stories/SideNav.stories.tsx@@ -310,12 +310,14 @@ export const WithFooter: Story = {icon={<XDSIcon icon={QuestionMarkCircleIcon} size="md" />}variant="ghost"size="sm"+ isIconOnly/><XDSButtonlabel="Notifications"icon={<XDSIcon icon={BellIcon} size="md" />}variant="ghost"size="sm"+ isIconOnly/></>}>@@ -465,6 +467,7 @@ export const EndContent: Story = {}variant="ghost"size="sm"+ isIconOnly/>}/>diff --git a/apps/storybook/stories/TabList.stories.tsx b/apps/storybook/stories/TabList.stories.tsxindex 1d00db46a9..442c561e00 100644--- a/apps/storybook/stories/TabList.stories.tsx+++ b/apps/storybook/stories/TabList.stories.tsx@@ -184,14 +184,14 @@ export const WithActions: Story = {variant="ghost"size="md"icon={<FunnelIcon />}+ isIconOnly/><XDSButtonlabel="New item"variant="primary"size="md"- icon={<PlusIcon />}>- New item- </XDSButton>+ icon={<PlusIcon />}+ /></XDSHStack></XDSStackItem></XDSHStack>diff --git a/apps/storybook/stories/ThemeEditor.stories.tsx b/apps/storybook/stories/ThemeEditor.stories.tsxindex 8cdb8ef3d8..559c787a62 100644--- a/apps/storybook/stories/ThemeEditor.stories.tsx+++ b/apps/storybook/stories/ThemeEditor.stories.tsx@@ -1617,25 +1617,26 @@ function ThemeEditorComponent() {tooltip="Search"variant="ghost"icon={<MagnifyingGlassIcon style={{width: 16, height: 16}} />}+ isIconOnly/><XDSButtonlabel="Notifications"tooltip="Notifications"variant="ghost"icon={<BellIcon style={{width: 16, height: 16}} />}+ isIconOnly/><XDSButtonlabel="Profile"tooltip="Profile"variant="ghost"icon={<UserCircleIcon style={{width: 16, height: 16}} />}+ isIconOnly/></>}/>-<XDSDivider />-{/* ── Toolbar ─────────────────────────────────────── */}<div {...stylex.props(toolbarStyles.toolbar)}><div {...stylex.props(toolbarStyles.toolbarGroup)}>@@ -1667,6 +1668,7 @@ function ThemeEditorComponent() {size="sm"icon={<SunIcon style={{width: 14, height: 14}} />}onClick={() => setMode('light')}+ isIconOnly/><XDSButtonlabel="Dark mode"@@ -1675,6 +1677,7 @@ function ThemeEditorComponent() {size="sm"icon={<MoonIcon style={{width: 14, height: 14}} />}onClick={() => setMode('dark')}+ isIconOnly/><div {...stylex.props(toolbarStyles.toolbarDivider)} />@@ -1685,6 +1688,7 @@ function ThemeEditorComponent() {variant="ghost"size="sm"icon={<ArrowUturnLeftIcon style={{width: 14, height: 14}} />}+ isIconOnly/><XDSButtonlabel="Redo"@@ -1692,6 +1696,7 @@ function ThemeEditorComponent() {variant="ghost"size="sm"icon={<ArrowUturnRightIcon style={{width: 14, height: 14}} />}+ isIconOnly/><XDSButtonlabel="Reset"@@ -1709,6 +1714,7 @@ function ThemeEditorComponent() {variant="ghost"size="sm"icon={<ShareIcon style={{width: 14, height: 14}} />}+ isIconOnly/><XDSButtonlabel="Save"@@ -1716,6 +1722,7 @@ function ThemeEditorComponent() {variant="ghost"size="sm"icon={<BookmarkIcon style={{width: 14, height: 14}} />}+ isIconOnly/><div {...stylex.props(toolbarStyles.toolbarDivider)} />@@ -1733,12 +1740,10 @@ function ThemeEditorComponent() {label="Export to Figma"variant="secondary"size="sm"- icon={<ArrowDownTrayIcon style={{width: 14, height: 14}} />}>- Export to Figma- </XDSButton>+ icon={<ArrowDownTrayIcon style={{width: 14, height: 14}} />}+ /></div></div>-{/* ── Main Content ────────────────────────────────── */}<divstyle={{diff --git a/apps/storybook/stories/ToggleButton.stories.tsx b/apps/storybook/stories/ToggleButton.stories.tsxindex 21b2cc5cdf..04e1e1b2c5 100644--- a/apps/storybook/stories/ToggleButton.stories.tsx+++ b/apps/storybook/stories/ToggleButton.stories.tsx@@ -57,6 +57,7 @@ export const Standalone: Story = {icon={<BoldIcon style={iconSize} />}isPressed={isPressed}onPressedChange={setIsPressed}+ isIconOnly/>);},@@ -75,6 +76,7 @@ export const IconSwap: Story = {pressedIcon={<StarIconSolid style={iconSize} />}isPressed={isFavorited}onPressedChange={setIsFavorited}+ isIconOnly/><XDSToggleButtonlabel="Bookmark"@@ -82,6 +84,7 @@ export const IconSwap: Story = {pressedIcon={<BookmarkIconSolid style={iconSize} />}isPressed={isBookmarked}onPressedChange={setIsBookmarked}+ isIconOnly/></div>);@@ -137,6 +140,7 @@ export const Sizes: Story = {icon={<BoldIcon style={iconSize} />}isPressed={!!pressed.sm}onPressedChange={() => toggle('sm')}+ isIconOnly/><XDSToggleButtonlabel="Medium"@@ -144,6 +148,7 @@ export const Sizes: Story = {icon={<BoldIcon style={iconSize} />}isPressed={!!pressed.md}onPressedChange={() => toggle('md')}+ isIconOnly/><XDSToggleButtonlabel="Large"@@ -151,6 +156,7 @@ export const Sizes: Story = {icon={<BoldIcon style={{width: 20, height: 20}} />}isPressed={!!pressed.lg}onPressedChange={() => toggle('lg')}+ isIconOnly/></div>);@@ -171,11 +177,13 @@ export const GroupSingle: Story = {value="list"label="List view"icon={<ListBulletIcon style={iconSize} />}+ isIconOnly/><XDSToggleButtonvalue="grid"label="Grid view"icon={<Squares2X2Icon style={iconSize} />}+ isIconOnly/></XDSToggleButtonGroup>);@@ -196,16 +204,19 @@ export const GroupMultiple: Story = {value="bold"label="Bold"icon={<BoldIcon style={iconSize} />}+ isIconOnly/><XDSToggleButtonvalue="italic"label="Italic"icon={<ItalicIcon style={iconSize} />}+ isIconOnly/><XDSToggleButtonvalue="underline"label="Underline"icon={<UnderlineIcon style={iconSize} />}+ isIconOnly/></XDSToggleButtonGroup>);@@ -223,6 +234,7 @@ export const NotificationToggle: Story = {pressedIcon={<BellSlashIcon style={iconSize} />}isPressed={isMuted}onPressedChange={setIsMuted}+ isIconOnly/>);},@@ -256,6 +268,7 @@ export const ColoredIconToolbar: Story = {}isPressed={pressed.bold}onPressedChange={() => toggle('bold')}+ isIconOnly/><XDSToggleButtonlabel="Italic"@@ -265,6 +278,7 @@ export const ColoredIconToolbar: Story = {}isPressed={pressed.italic}onPressedChange={() => toggle('italic')}+ isIconOnly/><XDSToggleButtonlabel="Underline"@@ -274,6 +288,7 @@ export const ColoredIconToolbar: Story = {}isPressed={pressed.underline}onPressedChange={() => toggle('underline')}+ isIconOnly/><XDSToggleButtonlabel="Strikethrough"@@ -285,6 +300,7 @@ export const ColoredIconToolbar: Story = {}isPressed={pressed.strikethrough}onPressedChange={() => toggle('strikethrough')}+ isIconOnly/><XDSToggleButtonlabel="Link"@@ -292,6 +308,7 @@ export const ColoredIconToolbar: Story = {pressedIcon={<XDSIcon icon={LinkIcon} size="sm" color="positive" />}isPressed={pressed.link}onPressedChange={() => toggle('link')}+ isIconOnly/></div>);@@ -321,6 +338,7 @@ export const ColoredIconReactions: Story = {}isPressed={pressed.star}onPressedChange={() => toggle('star')}+ isIconOnly/><XDSToggleButtonlabel="Like"@@ -328,6 +346,7 @@ export const ColoredIconReactions: Story = {pressedIcon={<XDSIcon icon={HeartIconSolid} size="sm" color="red" />}isPressed={pressed.heart}onPressedChange={() => toggle('heart')}+ isIconOnly/><XDSToggleButtonlabel="Save"@@ -337,6 +356,7 @@ export const ColoredIconReactions: Story = {}isPressed={pressed.bookmark}onPressedChange={() => toggle('bookmark')}+ isIconOnly/><XDSToggleButtonlabel="Follow"@@ -344,6 +364,7 @@ export const ColoredIconReactions: Story = {pressedIcon={<XDSIcon icon={BellIcon} size="sm" color="accent" />}isPressed={pressed.bell}onPressedChange={() => toggle('bell')}+ isIconOnly/></div>);diff --git a/apps/storybook/stories/Toolbar.stories.tsx b/apps/storybook/stories/Toolbar.stories.tsxindex 755631136a..03d2e1e0c0 100644--- a/apps/storybook/stories/Toolbar.stories.tsx+++ b/apps/storybook/stories/Toolbar.stories.tsx@@ -63,6 +63,7 @@ export const Default: Story = {label="Settings"variant="ghost"icon={<Cog6ToothIcon style={{width: 16, height: 16}} />}+ isIconOnly/>),},@@ -78,6 +79,7 @@ export const ThreeSlot: Story = {label="Back"variant="ghost"icon={<ArrowLeftIcon style={{width: 16, height: 16}} />}+ isIconOnly/>}centerContent={<XDSHeading level={4}>Q1 Planning Document</XDSHeading>}@@ -133,6 +135,7 @@ export const Compact: Story = {variant="ghost"size="sm"icon={<Cog6ToothIcon style={{width: 14, height: 14}} />}+ isIconOnly/>),},@@ -173,11 +176,13 @@ export const InsideCard: Story = {variant="ghost"size="sm"icon={<FunnelIcon style={{width: 16, height: 16}} />}+ isIconOnly/><XDSButtonlabel="Add user"size="sm"icon={<PlusIcon style={{width: 16, height: 16}} />}+ isIconOnly/></>}@@ -243,6 +248,7 @@ export const PageHeader: Story = {label="Back to projects"variant="ghost"icon={<ArrowLeftIcon style={{width: 16, height: 16}} />}+ isIconOnly/>}centerContent={<XDSHeading level={3}>Project Settings</XDSHeading>}@@ -275,12 +281,14 @@ export const BulkActions: Story = {variant="ghost"size="sm"icon={<TrashIcon style={{width: 16, height: 16}} />}+ isIconOnly/><XDSButtonlabel="Archive"variant="ghost"size="sm"icon={<ArchiveBoxIcon style={{width: 16, height: 16}} />}+ isIconOnly/></>}@@ -306,12 +314,14 @@ export const StackedToolbars: Story = {variant="ghost"size="sm"icon={<ArrowPathIcon style={{width: 16, height: 16}} />}+ isIconOnly/><XDSButtonlabel="Export"variant="ghost"size="sm"icon={<ArrowDownTrayIcon style={{width: 16, height: 16}} />}+ isIconOnly/><XDSButton label="New order" size="sm" /></>diff --git a/apps/storybook/stories/TopNav.stories.tsx b/apps/storybook/stories/TopNav.stories.tsxindex 4d72cd10c2..587e4d0629 100644--- a/apps/storybook/stories/TopNav.stories.tsx+++ b/apps/storybook/stories/TopNav.stories.tsx@@ -48,16 +48,19 @@ export const Default: Story = {label="Search"variant="ghost"icon={<MagnifyingGlassIcon style={{width: 16, height: 16}} />}+ isIconOnly/><XDSButtonlabel="Notifications"variant="ghost"icon={<BellIcon style={{width: 16, height: 16}} />}+ isIconOnly/><XDSButtonlabel="Profile"variant="ghost"icon={<UserCircleIcon style={{width: 16, height: 16}} />}+ isIconOnly/></>),@@ -88,6 +91,7 @@ export const WithLogo: Story = {label="Profile"variant="ghost"icon={<UserCircleIcon style={{width: 16, height: 16}} />}+ isIconOnly/>),},@@ -155,11 +159,13 @@ export const CenteredNavigation: Story = {label="Search"variant="ghost"icon={<MagnifyingGlassIcon style={{width: 16, height: 16}} />}+ isIconOnly/><XDSButtonlabel="Profile"variant="ghost"icon={<UserCircleIcon style={{width: 16, height: 16}} />}+ isIconOnly/></>}@@ -201,6 +207,7 @@ export const CenteredWithStartContent: Story = {label="Profile"variant="ghost"icon={<UserCircleIcon style={{width: 16, height: 16}} />}+ isIconOnly/>}/>@@ -274,11 +281,13 @@ export const FullExample: Story = {label="Search"variant="ghost"icon={<MagnifyingGlassIcon style={{width: 16, height: 16}} />}+ isIconOnly/><XDSButtonlabel="Notifications"variant="ghost"icon={<BellIcon style={{width: 16, height: 16}} />}+ isIconOnly/><XDSButton label="Upgrade" variant="primary" /></>diff --git a/apps/storybook/stories/TopNavMenu.stories.tsx b/apps/storybook/stories/TopNavMenu.stories.tsxindex 1fe1ae5479..7d39c276bf 100644--- a/apps/storybook/stories/TopNavMenu.stories.tsx+++ b/apps/storybook/stories/TopNavMenu.stories.tsx@@ -94,6 +94,7 @@ export const Default: Story = {label="Profile"variant="ghost"icon={<UserCircleIcon style={{width: 16, height: 16}} />}+ isIconOnly/>}/>diff --git a/apps/storybook/stories/XDSMediaTheme.stories.tsx b/apps/storybook/stories/XDSMediaTheme.stories.tsxindex cfd13224ef..e817b8c413 100644--- a/apps/storybook/stories/XDSMediaTheme.stories.tsx+++ b/apps/storybook/stories/XDSMediaTheme.stories.tsx@@ -39,7 +39,8 @@ function OnDarkDemo() {return (<divstyle={{- backgroundColor: 'var(--color-surface-inverted, light-dark(#0A1317, #FFFFFF))',+ backgroundColor:+ 'var(--color-surface-inverted, light-dark(#0A1317, #FFFFFF))',borderRadius: 'var(--radius-container)',padding: 16,}}>@@ -95,7 +96,8 @@ function OnLightDemo() {<XDSText>Dark mode page background</XDSText><divstyle={{- backgroundColor: 'var(--color-surface-inverted, light-dark(#0A1317, #FFFFFF))',+ backgroundColor:+ 'var(--color-surface-inverted, light-dark(#0A1317, #FFFFFF))',borderRadius: 'var(--radius-container)',padding: 16,marginTop: 12,@@ -144,11 +146,13 @@ function ToastDemo() {{/* Info toast */}<divstyle={{- backgroundColor: 'var(--color-surface-inverted, light-dark(#0A1317, #FFFFFF))',+ backgroundColor:+ 'var(--color-surface-inverted, light-dark(#0A1317, #FFFFFF))',borderRadius: 'var(--radius-container)',padding: '12px 16px',boxShadow: 'var(--shadow-med)',- maxWidth: 400, width: '100%',+ maxWidth: 400,+ width: '100%',}}><XDSMediaTheme mode="dark"><XDSStack direction="row" gap={3} align="center" wrap="wrap">@@ -159,19 +163,21 @@ function ToastDemo() {variant="ghost"size="sm"icon={<XDSIcon icon="close" size="sm" />}+ isIconOnly/></XDSStack></XDSMediaTheme></div>-{/* Error toast */}<divstyle={{- backgroundColor: 'var(--color-error-inverted, light-dark(#AA071E, #E3193B))',+ backgroundColor:+ 'var(--color-error-inverted, light-dark(#AA071E, #E3193B))',borderRadius: 'var(--radius-container)',padding: '12px 16px',boxShadow: 'var(--shadow-med)',- maxWidth: 400, width: '100%',+ maxWidth: 400,+ width: '100%',}}><XDSMediaTheme mode="dark"><XDSStack direction="row" gap={3} align="center" wrap="wrap">@@ -183,6 +189,7 @@ function ToastDemo() {variant="ghost"size="sm"icon={<XDSIcon icon="close" size="sm" />}+ isIconOnly/></XDSStack></XDSMediaTheme>@@ -241,7 +248,8 @@ function ComponentOverrideBoundaryDemo() {{/* Inverted surface — scope boundary blocks component overrides */}<divstyle={{- backgroundColor: 'var(--color-surface-inverted, light-dark(#0A1317, #FFFFFF))',+ backgroundColor:+ 'var(--color-surface-inverted, light-dark(#0A1317, #FFFFFF))',borderRadius: 'var(--radius-element)',padding: 16,}}>@@ -311,7 +319,8 @@ function ThemedDemo() {{/* Inverted surface */}<divstyle={{- backgroundColor: 'var(--color-surface-inverted, light-dark(#0A1317, #FFFFFF))',+ backgroundColor:+ 'var(--color-surface-inverted, light-dark(#0A1317, #FFFFFF))',borderRadius: 'var(--radius-container)',padding: 16,flex: 1,@@ -373,7 +382,8 @@ function CustomOverridesDemo() {</XDSText><divstyle={{- backgroundColor: 'var(--color-surface-inverted, light-dark(#0A1317, #FFFFFF))',+ backgroundColor:+ 'var(--color-surface-inverted, light-dark(#0A1317, #FFFFFF))',borderRadius: 'var(--radius-container)',padding: 16,}}>@@ -442,7 +452,8 @@ function ImageCard({url, label}: {url: string; label: string}) {position: 'relative',borderRadius: 'var(--radius-container, 12px)',overflow: 'hidden',- maxWidth: 300, width: '100%',+ maxWidth: 300,+ width: '100%',height: 200,}}><img@@ -535,7 +546,8 @@ function RegionalDetectDemo() {position: 'relative',borderRadius: 'var(--radius-container, 12px)',overflow: 'hidden',- maxWidth: 400, width: '100%',+ maxWidth: 400,+ width: '100%',height: 260,}}><imgdiff --git a/packages/cli/src/codemods/__tests__/registry.test.mjs b/packages/cli/src/codemods/__tests__/registry.test.mjsindex 55bf9b0eb6..7d60b8e7e9 100644--- a/packages/cli/src/codemods/__tests__/registry.test.mjs+++ b/packages/cli/src/codemods/__tests__/registry.test.mjs@@ -4,7 +4,7 @@ import {versions, getTransformsBetween} from '../registry.mjs';describe('registry', () => {describe('versions', () => {test('are sorted in ascending semver order across digit boundaries', () => {- expect(versions).toEqual(['0.0.2', '0.0.6', '0.0.7', '0.0.8', '0.0.10']);+ expect(versions).toEqual(['0.0.2', '0.0.6', '0.0.7', '0.0.8', '0.0.10', '0.0.12']);});});diff --git a/packages/cli/src/codemods/registry.mjs b/packages/cli/src/codemods/registry.mjsindex 5540adcfcf..ef445bc4d2 100644--- a/packages/cli/src/codemods/registry.mjs+++ b/packages/cli/src/codemods/registry.mjs@@ -11,6 +11,7 @@ const registry = new Map([['0.0.7', () => import('./transforms/v0.0.7/index.mjs')],['0.0.8', () => import('./transforms/v0.0.8/index.mjs')],['0.0.10', () => import('./transforms/v0.0.10/index.mjs')],+ ['0.0.12', () => import('./transforms/v0.0.12/index.mjs')],]);/**diff --git a/packages/cli/src/codemods/transforms/v0.0.12/__tests__/add-is-icon-only.test.mjs b/packages/cli/src/codemods/transforms/v0.0.12/__tests__/add-is-icon-only.test.mjsnew file mode 100644index 0000000000..82a333c7c0--- /dev/null+++ b/packages/cli/src/codemods/transforms/v0.0.12/__tests__/add-is-icon-only.test.mjs@@ -0,0 +1,81 @@+import {describe, it, expect} from 'vitest';++async function applyTransform(source, filePath = 'test.tsx') {+ const {default: transform} = await import('../add-is-icon-only.mjs');+ const jscodeshift = (await import('jscodeshift')).default;+ const j = filePath.endsWith('.ts') || filePath.endsWith('.tsx') ? jscodeshift.withParser('tsx') : jscodeshift;+ const api = {jscodeshift: j, stats: () => {}, report: () => {}};+ return transform({source, path: filePath}, api) ?? source;+}++describe('add-is-icon-only', () => {+ it('adds isIconOnly to icon-only button', async () => {+ const input = '<XDSButton label="Settings" icon={<GearIcon />} variant="ghost" />';+ expect(await applyTransform(input)).toContain('isIconOnly');+ });++ it('skips button with JSX children', async () => {+ const input = '<XDSButton label="Save" icon={<SaveIcon />}>Save</XDSButton>';+ expect(await applyTransform(input)).not.toContain('isIconOnly');+ });++ it('skips button with children prop', async () => {+ const input = '<XDSButton label="Save" icon={<SaveIcon />} children="Save" />';+ expect(await applyTransform(input)).not.toContain('isIconOnly');+ });++ it('skips button without icon', async () => {+ const input = '<XDSButton label="Submit" variant="primary" />';+ expect(await applyTransform(input)).not.toContain('isIconOnly');+ });++ it('skips button that already has isIconOnly', async () => {+ const input = '<XDSButton label="Settings" icon={<GearIcon />} isIconOnly />';+ expect(await applyTransform(input)).toBe(input);+ });++ it('handles multiple buttons', async () => {+ const input = '<>\n <XDSButton label="A" icon={<I />} />\n <XDSButton label="B" />\n <XDSButton label="C" icon={<I />} />\n</>';+ expect((await applyTransform(input)).match(/isIconOnly/g)).toHaveLength(2);+ });++ it('adds isIconOnly to XDSToggleButton', async () => {+ const input = '<XDSToggleButton label="Bold" icon={<B />} value="bold" />';+ expect(await applyTransform(input)).toContain('isIconOnly');+ });++ it('removes redundant children matching label', async () => {+ const input = '<XDSButton label="Save" icon={<SaveIcon />}>Save</XDSButton>';+ const output = await applyTransform(input);+ expect(output).not.toContain('>Save<');+ expect(output).toContain('/>');+ });++ it('preserves children differing from label', async () => {+ const input = '<XDSButton label="Close dialog" icon={<X />}>Close</XDSButton>';+ expect(await applyTransform(input)).toContain('>Close<');+ });++ it('adds isIconOnly to DropdownMenu button object', async () => {+ const input = "<XDSDropdownMenu button={{ label: 'More', icon: <I /> }} items={[]} />";+ expect(await applyTransform(input)).toContain('isIconOnly: true');+ });++ it('skips DropdownMenu button object with children', async () => {+ const input = "<XDSDropdownMenu button={{ label: 'X', icon: <I />, children: 'X' }} items={[]} />";+ expect(await applyTransform(input)).not.toContain('isIconOnly');+ });++ it('skips unrelated components', async () => {+ const input = '<XDSAvatar icon={<P />} name="U" />';+ expect(await applyTransform(input)).not.toContain('isIconOnly');+ });++ it('returns undefined when no changes needed', async () => {+ const {default: transform} = await import('../add-is-icon-only.mjs');+ const jscodeshift = (await import('jscodeshift')).default;+ const j = jscodeshift.withParser('tsx');+ const result = transform({source: '<XDSButton label="X" />', path: 'test.tsx'}, {jscodeshift: j, stats: () => {}, report: () => {}});+ expect(result).toBeUndefined();+ });+});diff --git a/packages/cli/src/codemods/transforms/v0.0.12/add-is-icon-only.mjs b/packages/cli/src/codemods/transforms/v0.0.12/add-is-icon-only.mjsnew file mode 100644index 0000000000..076fcf46ae--- /dev/null+++ b/packages/cli/src/codemods/transforms/v0.0.12/add-is-icon-only.mjs@@ -0,0 +1,177 @@+/**+ * @file Codemod: Add isIconOnly prop to icon-only XDSButton and XDSToggleButton+ * @see https://github.com/facebookexperimental/xds/issues/1257+ *+ * XDSButton and XDSToggleButton now use an explicit `isIconOnly` prop instead+ * of inferring icon-only mode from `icon` present + `children` absent.+ *+ * With the new API, `label` is always rendered as visible text unless+ * `isIconOnly={true}` is set. This codemod adds `isIconOnly` to all existing+ * icon-only usages so behavior is preserved after the change.+ *+ * Detection: a JSX element is icon-only when it has:+ * 1. An `icon` prop (any value)+ * 2. No `children` prop AND no JSX children (self-closing or empty)+ * 3. No existing `isIconOnly` prop+ *+ * This codemod also handles:+ * - Object literals passed to components that forward button props+ * (e.g., XDSDropdownMenu `button={{ icon: ..., label: ... }}`)+ * - Removing redundant `children` that duplicate `label` on icon+text buttons+ * (e.g., `<XDSButton label="Save" icon={...}>Save</XDSButton>` → `<XDSButton label="Save" icon={...} />`)+ */++const TARGET_COMPONENTS = new Set([+ 'XDSButton',+ 'XDSToggleButton',+]);++/** Components whose button-like object props should also be migrated. */+const FORWARDING_COMPONENTS = new Set([+ 'XDSDropdownMenu',+ 'XDSMoreMenu',+]);++export const meta = {+ title: 'Add isIconOnly to icon-only buttons',+ description:+ 'XDSButton and XDSToggleButton now require explicit `isIconOnly` for icon-only mode. ' ++ 'Adds `isIconOnly` to all existing icon-only usages. Also removes redundant children ' ++ 'that duplicate the label prop on icon+text buttons.',+ pr: '#1257',+};++export default function transformer(file, api) {+ const j = api.jscodeshift;+ const root = j(file.source);+ let hasChanges = false;++ // ---- 1. JSX elements: add isIconOnly to icon-only buttons ----+ root.find(j.JSXOpeningElement).forEach((path) => {+ const name = path.node.name;+ const componentName =+ name.type === 'JSXIdentifier' ? name.name : null;+ if (!componentName || !TARGET_COMPONENTS.has(componentName)) return;++ const attrs = path.node.attributes;++ const hasIcon = attrs.some(+ (a) => a.type === 'JSXAttribute' && a.name?.name === 'icon',+ );+ const hasChildren = attrs.some(+ (a) => a.type === 'JSXAttribute' && a.name?.name === 'children',+ );+ const hasIsIconOnly = attrs.some(+ (a) => a.type === 'JSXAttribute' && a.name?.name === 'isIconOnly',+ );++ if (!hasIcon || hasChildren || hasIsIconOnly) return;++ // Check for JSX children (non-whitespace text or elements)+ const parent = path.parent.node;+ const hasJSXChildren =+ parent.type === 'JSXElement' &&+ parent.children &&+ parent.children.some((child) => {+ if (child.type === 'JSXText') return child.value.trim() !== '';+ return true;+ });++ if (hasJSXChildren) return;++ // This is an icon-only button — add isIconOnly+ attrs.push(j.jsxAttribute(j.jsxIdentifier('isIconOnly')));+ hasChanges = true;+ });++ // ---- 2. Remove redundant children that match label ----+ root.find(j.JSXElement).forEach((path) => {+ const opening = path.node.openingElement;+ const name = opening.name;+ const componentName =+ name.type === 'JSXIdentifier' ? name.name : null;+ if (!componentName || !TARGET_COMPONENTS.has(componentName)) return;++ const attrs = opening.attributes;+ const hasIcon = attrs.some(+ (a) => a.type === 'JSXAttribute' && a.name?.name === 'icon',+ );+ if (!hasIcon) return;++ // Get label value+ const labelAttr = attrs.find(+ (a) => a.type === 'JSXAttribute' && a.name?.name === 'label',+ );+ if (!labelAttr || !labelAttr.value) return;++ let labelValue = null;+ if (labelAttr.value.type === 'StringLiteral' || labelAttr.value.type === 'Literal') {+ labelValue = labelAttr.value.value;+ }+ if (!labelValue) return;++ // Check if children is a single text node matching label+ const children = path.node.children;+ if (!children || children.length !== 1) return;++ const child = children[0];+ if (child.type === 'JSXText' && child.value.trim() === labelValue) {+ // Remove children, make self-closing+ path.node.children = [];+ path.node.closingElement = null;+ opening.selfClosing = true;+ hasChanges = true;+ }+ // Also handle JSXExpressionContainer with a string literal+ if (+ child.type === 'JSXExpressionContainer' &&+ (child.expression.type === 'StringLiteral' || child.expression.type === 'Literal') &&+ child.expression.value === labelValue+ ) {+ path.node.children = [];+ path.node.closingElement = null;+ opening.selfClosing = true;+ hasChanges = true;+ }+ });++ // ---- 3. Object literals: add isIconOnly to button config objects ----+ root.find(j.JSXOpeningElement).forEach((path) => {+ const name = path.node.name;+ const componentName =+ name.type === 'JSXIdentifier' ? name.name : null;+ if (!componentName || !FORWARDING_COMPONENTS.has(componentName)) return;++ const attrs = path.node.attributes;+ const buttonAttr = attrs.find(+ (a) =>+ a.type === 'JSXAttribute' &&+ a.name?.name === 'button' &&+ a.value?.type === 'JSXExpressionContainer' &&+ a.value.expression.type === 'ObjectExpression',+ );+ if (!buttonAttr) return;++ const obj = buttonAttr.value.expression;+ const props = obj.properties;++ const hasIcon = props.some(+ (p) => (p.type === 'Property' || p.type === 'ObjectProperty') && p.key?.name === 'icon',+ );+ const hasChildren = props.some(+ (p) => (p.type === 'Property' || p.type === 'ObjectProperty') && p.key?.name === 'children',+ );+ const hasIsIconOnly = props.some(+ (p) => (p.type === 'Property' || p.type === 'ObjectProperty') && p.key?.name === 'isIconOnly',+ );++ if (hasIcon && !hasChildren && !hasIsIconOnly) {+ props.push(+ j.property('init', j.identifier('isIconOnly'), j.literal(true)),+ );+ hasChanges = true;+ }+ });++ return hasChanges ? root.toSource() : undefined;+}diff --git a/packages/cli/src/codemods/transforms/v0.0.12/index.mjs b/packages/cli/src/codemods/transforms/v0.0.12/index.mjsnew file mode 100644index 0000000000..1adcf8c7de--- /dev/null+++ b/packages/cli/src/codemods/transforms/v0.0.12/index.mjs@@ -0,0 +1,17 @@+/**+ * @file v0.0.12 transform manifest+ *+ * Lists all codemods for the v0.0.12 release in the order they should run.+ */++import addIsIconOnly, {+ meta as addIsIconOnlyMeta,+} from './add-is-icon-only.mjs';++export default [+ {+ name: 'add-is-icon-only',+ transform: addIsIconOnly,+ meta: addIsIconOnlyMeta,+ },+];diff --git a/packages/cli/templates/ai-chat/page.tsx b/packages/cli/templates/ai-chat/page.tsxindex fb806daeb1..61b0af6572 100644--- a/packages/cli/templates/ai-chat/page.tsx+++ b/packages/cli/templates/ai-chat/page.tsx@@ -307,12 +307,14 @@ export default function AIChatTemplate() {variant="ghost"size="sm"icon={<AtSignIcon />}+ isIconOnly/><XDSButtonlabel="Attach"variant="ghost"size="sm"icon={<PaperclipIcon />}+ isIconOnly/></>}@@ -354,6 +356,7 @@ export default function AIChatTemplate() {variant="ghost"size="md"icon={<MicIcon />}+ isIconOnly/>}/>@@ -366,36 +369,32 @@ export default function AIChatTemplate() {isPressed={selected === 'writing'}onPressedChange={() =>setSelected(prev => (prev === 'writing' ? null : 'writing'))- }>- Writing- </XDSToggleButton>+ }+ /><XDSToggleButtonlabel="Coding"icon={<CodingIcon />}isPressed={selected === 'coding'}onPressedChange={() =>setSelected(prev => (prev === 'coding' ? null : 'coding'))- }>- Coding- </XDSToggleButton>+ }+ /><XDSToggleButtonlabel="Research"icon={<ResearchIcon />}isPressed={selected === 'research'}onPressedChange={() =>setSelected(prev => (prev === 'research' ? null : 'research'))- }>- Research- </XDSToggleButton>+ }+ /><XDSToggleButtonlabel="Creative"icon={<CreativeIcon />}isPressed={selected === 'creative'}onPressedChange={() =>setSelected(prev => (prev === 'creative' ? null : 'creative'))- }>- Creative- </XDSToggleButton>+ }+ /></XDSHStack></XDSVStack></XDSAppShell>diff --git a/packages/cli/templates/dashboard/page.tsx b/packages/cli/templates/dashboard/page.tsxindex a4f33c46ab..44bc9ad3df 100644--- a/packages/cli/templates/dashboard/page.tsx+++ b/packages/cli/templates/dashboard/page.tsx@@ -759,9 +759,8 @@ export default function DashboardTemplate() {label="Reload"variant="secondary"size="md"- icon={<ArrowPathIcon style={{width: 16, height: 16}} />}>- Reload- </XDSButton>+ icon={<ArrowPathIcon style={{width: 16, height: 16}} />}+ /></XDSHStack><ActiveUsersChart /></XDSVStack>diff --git a/packages/cli/templates/detail-page/page.tsx b/packages/cli/templates/detail-page/page.tsxindex 6a359d972b..aa4d62d2e1 100644--- a/packages/cli/templates/detail-page/page.tsx+++ b/packages/cli/templates/detail-page/page.tsx@@ -209,8 +209,6 @@ const ArrowLeftIcon = (props: React.SVGProps<SVGSVGElement>) => (// ─── Styles ─────────────────────────────────────────────────────────────────const pageStyles = stylex.create({--bulletSeparator: {fontSize: 12,lineHeight: '16px',@@ -669,6 +667,7 @@ function TimelineSection() {label="Filters"variant="ghost"icon={<FilterIcon style={{width: 14, height: 14}} />}+ isIconOnly/></XDSHStack>diff --git a/packages/cli/templates/docsite-landing/page.tsx b/packages/cli/templates/docsite-landing/page.tsxindex 421b8dcec4..f7e14ce776 100644--- a/packages/cli/templates/docsite-landing/page.tsx+++ b/packages/cli/templates/docsite-landing/page.tsx@@ -561,6 +561,7 @@ function TemplateCard({size: 'sm',icon: <MoreIcon />,style: {color: '#fff'},+ isIconOnly: true,}}hasChevron={false}items={[@@ -719,6 +720,7 @@ function AIComposer() {variant="ghost"size="sm"icon={<PlusIcon />}+ isIconOnly/><XDSButtonlabel="Send"@@ -726,6 +728,7 @@ function AIComposer() {size="sm"icon={<SendIcon />}style={{borderRadius: 9999}}+ isIconOnly/></div></div>@@ -823,7 +826,6 @@ function ChatPanel({<ShimmerText isActive={isGenerating} /></div></div>-{/* Composer pinned to bottom */}<div style={{padding: 12}}><div@@ -879,6 +881,7 @@ function ChatPanel({variant="ghost"size="sm"icon={<PlusIcon />}+ isIconOnly/><XDSButtonlabel="Send"@@ -887,6 +890,7 @@ function ChatPanel({icon={<SendIcon />}style={{borderRadius: 9999}}onClick={onSend}+ isIconOnly/></div></div>@@ -1124,6 +1128,7 @@ function TemplatePreview({variant="ghost"icon={<ArrowLeftIcon />}onClick={onBack}+ isIconOnly/></div>@@ -1146,6 +1151,7 @@ function TemplatePreview({label="Point"variant="ghost"icon={<CursorIcon />}+ isIconOnly/></XDSTooltip><XDSDropdownMenu@@ -1153,6 +1159,7 @@ function TemplatePreview({label: 'Theme',variant: 'ghost',icon: <PaletteIcon />,+ isIconOnly: true,}}hasChevron={false}items={XDS_THEMES.map(t => ({@@ -1504,12 +1511,14 @@ function AppTopNav() {size="sm"icon={<SearchIcon />}onClick={() => setIsSearchOpen(true)}+ isIconOnly/><XDSButtonlabel="Profile"variant="ghost"size="sm"icon={<ProfileIcon />}+ isIconOnly/></>}diff --git a/packages/cli/templates/editor/page.tsx b/packages/cli/templates/editor/page.tsxindex 5d178c4024..bc429cb8aa 100644--- a/packages/cli/templates/editor/page.tsx+++ b/packages/cli/templates/editor/page.tsx@@ -700,6 +700,7 @@ export default function EditorPage() {e.stopPropagation();moveBlock(block.id, -1);}}+ isIconOnly/><XDSButtonlabel="Move down"@@ -710,6 +711,7 @@ export default function EditorPage() {e.stopPropagation();moveBlock(block.id, 1);}}+ isIconOnly/><XDSButtonlabel="Delete"@@ -720,6 +722,7 @@ export default function EditorPage() {e.stopPropagation();deleteBlock(block.id);}}+ isIconOnly/></XDSHStack>}@@ -1577,6 +1580,7 @@ export default function EditorPage() {size="sm"style={{marginRight: -8, marginTop: -8}}onClick={() => setIsPanelCollapsed(v => !v)}+ isIconOnly/></div>@@ -1611,7 +1615,12 @@ export default function EditorPage() {/></XDSSegmentedControl><XDSHStack gap={2}>- <XDSButton label="Preview" icon={<EyeIcon />} variant="ghost" />+ <XDSButton+ label="Preview"+ icon={<EyeIcon />}+ variant="ghost"+ isIconOnly+ /><XDSButton label="Publish" variant="primary" /></XDSHStack></div>diff --git a/packages/cli/templates/file-explorer/page.tsx b/packages/cli/templates/file-explorer/page.tsxindex 926628d0ff..f2251ad8f7 100644--- a/packages/cli/templates/file-explorer/page.tsx+++ b/packages/cli/templates/file-explorer/page.tsx@@ -874,6 +874,7 @@ export default function FileExplorerPage() {isDisabled={selectedPath.length === 0}label="Go back"aria-label="Go back"+ isIconOnly/><XDSButtonvariant="ghost"@@ -882,6 +883,7 @@ export default function FileExplorerPage() {isDisabledlabel="Go forward"aria-label="Go forward"+ isIconOnly/><XDSText type="label" style={{marginLeft: 6}}>{currentFolderName}@@ -927,6 +929,7 @@ export default function FileExplorerPage() {icon={<GroupIcon />}label="Group"aria-label="Group"+ isIconOnly/><XDSButtonvariant="ghost"@@ -934,6 +937,7 @@ export default function FileExplorerPage() {icon={<ShareIcon />}label="Share"aria-label="Share"+ isIconOnly/><XDSButtonvariant="ghost"@@ -941,6 +945,7 @@ export default function FileExplorerPage() {icon={<TagIcon />}label="Tags"aria-label="Tags"+ isIconOnly/><XDSButtonvariant="ghost"@@ -948,6 +953,7 @@ export default function FileExplorerPage() {icon={<MoreIcon />}label="More"aria-label="More"+ isIconOnly/><XDSButtonvariant="ghost"@@ -955,13 +961,12 @@ export default function FileExplorerPage() {icon={<SearchIcon />}label="Search"aria-label="Search"+ isIconOnly/></XDSHStack>}/>-<XDSDivider />-{/* Columns */}<XDSHStack style={inlineStyles.body}>{columns.map((col, colIndex) => {diff --git a/packages/cli/templates/login-card/page.tsx b/packages/cli/templates/login-card/page.tsxindex 30d1c4543c..a60d3e6925 100644--- a/packages/cli/templates/login-card/page.tsx+++ b/packages/cli/templates/login-card/page.tsx@@ -116,7 +116,6 @@ export default function LoginSimple() {Product Inc.</XDSText></XDSVStack>-{/* Card */}<XDSCard padding={8} width={400}><XDSVStack gap={4}>@@ -199,16 +198,14 @@ export default function LoginSimple() {label="Login with Apple"variant="secondary"icon={<AppleIcon />}- xstyle={styles.fullWidth}>- Login with Apple- </XDSButton>+ xstyle={styles.fullWidth}+ /><XDSButtonlabel="Login with Google"variant="secondary"icon={<GoogleIcon />}- xstyle={styles.fullWidth}>- Login with Google- </XDSButton>+ xstyle={styles.fullWidth}+ /></XDSVStack>{/* Sign up link */}@@ -222,7 +219,6 @@ export default function LoginSimple() {</XDSVStack></XDSVStack></XDSCard>-{/* Terms — outside card */}<div style={{textAlign: 'center', maxWidth: 400}}><XDSText type="supporting" color="secondary">diff --git a/packages/cli/templates/login-split/page.tsx b/packages/cli/templates/login-split/page.tsxindex b5b0c1e383..ac90868c43 100644--- a/packages/cli/templates/login-split/page.tsx+++ b/packages/cli/templates/login-split/page.tsx@@ -252,16 +252,14 @@ export default function LoginTwoColumn() {label="Apple"variant="secondary"icon={<AppleIcon />}- xstyle={styles.socialButton}>- Apple- </XDSButton>+ xstyle={styles.socialButton}+ /><XDSButtonlabel="Google"variant="secondary"icon={<GoogleIcon />}- xstyle={styles.socialButton}>- </XDSButton>+ xstyle={styles.socialButton}+ /></div><XDSVStack hAlign="center" xstyle={styles.centered}>@@ -297,7 +295,6 @@ export default function LoginTwoColumn() {</div></XDSHStack></XDSCard>-{/* Terms — outside card */}<XDSVStack hAlign="center" xstyle={styles.centered}><XDSText type="supporting" color="secondary">diff --git a/packages/cli/templates/product-detail/page.tsx b/packages/cli/templates/product-detail/page.tsxindex 09e8f8c8be..a48bfb60f5 100644--- a/packages/cli/templates/product-detail/page.tsx+++ b/packages/cli/templates/product-detail/page.tsx@@ -224,21 +224,25 @@ function StoreTopNav() {label="Search"variant="ghost"icon={<SearchIcon style={{width: 16, height: 16}} />}+ isIconOnly/><XDSButtonlabel="Wishlist"variant="ghost"icon={<HeartIcon style={{width: 16, height: 16}} />}+ isIconOnly/><XDSButtonlabel="Account"variant="ghost"icon={<UserIcon style={{width: 16, height: 16}} />}+ isIconOnly/><XDSButtonlabel="Cart"variant="ghost"icon={<BagIcon style={{width: 16, height: 16}} />}+ isIconOnly/></>}@@ -344,7 +348,6 @@ function ProductInfo() {<XDSBadge variant="error" label="Sale" /></XDSHStack></XDSVStack>-{/* Color Selector */}<XDSVStack gap={2}><XDSText type="label">Color</XDSText>@@ -360,7 +363,6 @@ function ProductInfo() {</XDSSegmentedControl></div></XDSVStack>-{/* Shade Finish Selector */}<XDSVStack gap={2}><XDSText type="label">Shade Finish</XDSText>@@ -379,7 +381,6 @@ function ProductInfo() {</XDSSegmentedControl></div></XDSVStack>-{/* Quantity */}<XDSHStack gap={1} vAlign="center"><XDSButton@@ -388,6 +389,7 @@ function ProductInfo() {icon={<MinusIcon style={{width: 16, height: 16}} />}onClickAction={decrement}isDisabled={(quantity ?? 1) <= 1}+ isIconOnly/><div style={{width: 100}}><XDSNumberInput@@ -406,9 +408,9 @@ function ProductInfo() {icon={<PlusIcon style={{width: 16, height: 16}} />}onClickAction={increment}isDisabled={(quantity ?? 1) >= 10}+ isIconOnly/></XDSHStack>-{/* Add to Cart + Buy it now (8px gap between them) */}<XDSVStack gap={2}><XDSButton@@ -433,13 +435,12 @@ function ProductInfo() {variant="ghost"size="lg"icon={<HeartIcon style={{width: 16, height: 16}} />}+ isIconOnly/></XDSHStack></XDSVStack>-{/* Description */}<XDSText type="body">{PRODUCT.description}</XDSText>-{/* Collapsible Sections */}<XDSCollapsibleGroup type="multiple" defaultValue={['composition']}><XDSDivider />diff --git a/packages/cli/templates/settings-dialog/page.tsx b/packages/cli/templates/settings-dialog/page.tsxindex dce7406ecc..467d8b0f6f 100644--- a/packages/cli/templates/settings-dialog/page.tsx+++ b/packages/cli/templates/settings-dialog/page.tsx@@ -262,7 +262,6 @@ export default function SettingsDialogTemplate() {variant="primary"onClick={() => setIsOpen(true)}/>-<XDSDialogisOpen={isOpen}onOpenChange={open => setIsOpen(open)}@@ -285,6 +284,7 @@ export default function SettingsDialogTemplate() {icon={<XMarkIcon width={20} height={20} />}variant="ghost"onClick={() => setIsOpen(false)}+ isIconOnly/></div>diff --git a/packages/core/src/Banner/XDSBanner.tsx b/packages/core/src/Banner/XDSBanner.tsxindex efeb5690f7..bb24bb8b86 100644--- a/packages/core/src/Banner/XDSBanner.tsx+++ b/packages/core/src/Banner/XDSBanner.tsx@@ -478,6 +478,7 @@ export function XDSBanner({}onClick={handleToggleExpand}aria-expanded={isExpanded}+ isIconOnly/>)}{isDismissable && (@@ -488,6 +489,7 @@ export function XDSBanner({tooltip="Dismiss"icon={<XDSIcon icon="close" size="sm" color="inherit" />}onClick={handleDismiss}+ isIconOnly/>)}</div>diff --git a/packages/core/src/Button/XDSButton.test.tsx b/packages/core/src/Button/XDSButton.test.tsxindex cc7cc2d281..ee43887a17 100644--- a/packages/core/src/Button/XDSButton.test.tsx+++ b/packages/core/src/Button/XDSButton.test.tsx@@ -41,7 +41,11 @@ describe('XDSButton', () => {it('renders icon-only button with aria-label', () => {render(- <XDSButton label="Settings" icon={<span data-testid="icon">⚙</span>} />,+ <XDSButton+ label="Settings"+ icon={<span data-testid="icon">⚙</span>}+ isIconOnly+ />,);const button = screen.getByRole('button', {name: 'Settings'});expect(button).toHaveAttribute('aria-label', 'Settings');@@ -50,9 +54,7 @@ describe('XDSButton', () => {it('renders icon with text when both icon and children provided', () => {render(- <XDSButton label="Settings" icon={<span data-testid="icon">⚙</span>}>- Settings- </XDSButton>,+ <XDSButton label="Settings" icon={<span data-testid="icon">⚙</span>} />,);const button = screen.getByRole('button');expect(button).not.toHaveAttribute('aria-label');@@ -132,9 +134,8 @@ describe('XDSButton', () => {<XDSButtonlabel="Settings"icon={<span data-testid="icon">⚙</span>}- endContent={<XDSBadge data-testid="end" label="New" />}>- Settings- </XDSButton>,+ endContent={<XDSBadge data-testid="end" label="New" />}+ />,);const button = screen.getByRole('button');expect(screen.getByTestId('icon')).toBeInTheDocument();@@ -148,6 +149,7 @@ describe('XDSButton', () => {label="Settings"icon={<span data-testid="icon">⚙</span>}endContent={<XDSBadge data-testid="end" label={3} />}+ isIconOnly/>,);expect(screen.getByTestId('icon')).toBeInTheDocument();diff --git a/packages/core/src/Button/XDSButton.tsx b/packages/core/src/Button/XDSButton.tsxindex f65b0af81f..184539112f 100644--- a/packages/core/src/Button/XDSButton.tsx+++ b/packages/core/src/Button/XDSButton.tsx@@ -12,7 +12,7 @@* - /packages/core/src/Button/index.ts (exports if types change)* - /apps/storybook/stories/Button.stories.tsx (storybook stories)*- * Last synced props: label, variant, size, isDisabled, isLoading, onClickAction, icon, children, tooltip, endContent, href, as, target, rel+ * Last synced props: label, variant, size, isDisabled, isLoading, onClickAction, icon, isIconOnly, children, tooltip, endContent, href, as, target, rel*/import {useRef, useTransition, type ReactNode} from 'react';@@ -286,7 +286,8 @@ export interface XDSButtonProps extends XDSBaseProps<HTMLButtonElement> {form?: string;/*** Accessible label for the button (required for accessibility).- * Used as visible text, or as aria-label for icon-only buttons.+ * Rendered as visible text by default. When `isIconOnly` is true,+ * used as aria-label instead.*/label: string;/**@@ -321,18 +322,23 @@ export interface XDSButtonProps extends XDSBaseProps<HTMLButtonElement> {e: React.MouseEvent<HTMLButtonElement>,) => void | Promise<void>;/**- * Icon element to render in the button.- * If provided without children, button becomes icon-only (square).+ * Icon element rendered before the label text.*/icon?: ReactNode;/**- * Optional visible content. If omitted and icon is provided,- * button becomes icon-only with label used as aria-label.+ * When true, renders as a square icon-only button with `label` as aria-label.+ * Requires `icon` to be provided.+ * @default false+ */+ isIconOnly?: boolean;+ /**+ * Optional visible content. When provided, rendered instead of `label` as the+ * visible text (label still serves as the accessible name via aria-label).*/children?: ReactNode;/*** Content rendered after the label text (badge, icon, chevron, etc.).- * Ignored for icon-only buttons to preserve square aspect ratio.+ * Ignored when `isIconOnly` is true to preserve square aspect ratio.** Wrapped in a container that inherits the button's text color,* so child elements match the button variant's color automatically.@@ -412,11 +418,11 @@ const edgeCompStyles = stylex.create({* <XDSButton label="Click me" />* <XDSButton label="Primary action" variant="primary" />* <XDSButton label="Delete" variant="destructive" />- * <XDSButton label="Settings" icon={<GearIcon />} variant="ghost" />- * <XDSButton label="Pick emoji" icon={<span>🚀</span>} variant="ghost" size="sm" />- * <XDSButton label="Edit" icon={<PencilIcon />}>Edit</XDSButton>+ * <XDSButton label="Settings" icon={<GearIcon />} variant="ghost" isIconOnly />+ * <XDSButton label="Pick emoji" icon={<span>🚀</span>} variant="ghost" size="sm" isIconOnly />+ * <XDSButton label="Edit" icon={<PencilIcon />} />* <XDSButton label="Messages" endContent={<XDSBadge label={3} />} />- * <XDSButton label="Edit" icon={<PencilIcon />} endContent={<XDSBadge label="New" />}>Edit</XDSButton>+ * <XDSButton label="Edit" icon={<PencilIcon />} endContent={<XDSBadge label="New" />} />* <XDSButton label="Visit site" href="https://example.com" variant="primary" />* <XDSButton label="Open in new tab" href="https://example.com" target="_blank" rel="noopener noreferrer" />* ```@@ -430,6 +436,7 @@ export function XDSButton({isLoading = false,onClickAction,icon,+ isIconOnly = false,children,endContent,tooltip,@@ -448,7 +455,9 @@ export function XDSButton({const isLoadingState = isLoading || isPending;const buttonDisabled = isDisabled || isLoadingState;const useLightSpinner = variant === 'primary' || variant === 'destructive';- const isIconOnly = icon != null && children == null;+ // isIconOnly prop is the source of truth for icon-only rendering.+ // When false (default), label is always rendered as visible text.+const LinkComponent = useXDSLinkComponent(as);// Render as link when href is provided and button is not disabled.@@ -560,10 +569,15 @@ export function XDSButton({</>);- const ariaLabelProp =- (isIconOnly && label !== '') || (isLoadingState && !isIconOnly)- ? {'aria-label': label}- : null;+ // aria-label is set when:+ // 1. Icon-only mode (label is the only accessible name)+ // 2. Loading state on non-icon-only (announce the button's purpose)+ // 3. Children differ from label (children are visible, label is accessible name)+ const needsAriaLabel =+ (isIconOnly && label !== '') ||+ (isLoadingState && !isIconOnly) ||+ (children != null && children !== label);+ const ariaLabelProp = needsAriaLabel ? {'aria-label': label} : null;let element: ReactNode;diff --git a/packages/core/src/Calendar/XDSCalendar.tsx b/packages/core/src/Calendar/XDSCalendar.tsxindex 1b529da5df..5abc57ca2b 100644--- a/packages/core/src/Calendar/XDSCalendar.tsx+++ b/packages/core/src/Calendar/XDSCalendar.tsx@@ -405,6 +405,7 @@ export function XDSCalendar({ref, ...props}: XDSCalendarProps) {icon={<XDSIcon icon="chevronLeft" size="sm" color="inherit" />}onClick={() => navigateMonth(-1)}isDisabled={!canNavigatePrevious}+ isIconOnly/><span {...stylex.props(calendarStyles.monthYearLabel)}>@@ -417,9 +418,9 @@ export function XDSCalendar({ref, ...props}: XDSCalendarProps) {icon={<XDSIcon icon="chevronRight" size="sm" color="inherit" />}onClick={() => navigateMonth(1)}isDisabled={!canNavigateNext}+ isIconOnly/></div>-{/* Month grids */}<div {...stylex.props(calendarStyles.monthsContainer)}>{visibleMonths.map(month => (diff --git a/packages/core/src/Dialog/XDSDialogHeader.tsx b/packages/core/src/Dialog/XDSDialogHeader.tsxindex b796b9cc86..4aed5e8c33 100644--- a/packages/core/src/Dialog/XDSDialogHeader.tsx+++ b/packages/core/src/Dialog/XDSDialogHeader.tsx@@ -162,6 +162,7 @@ export function XDSDialogHeader({tooltip="Close"icon={<XDSIcon icon="close" color="inherit" />}onClick={() => onOpenChange?.(false)}+ isIconOnly/>)}</div>diff --git a/packages/core/src/DropdownMenu/XDSDropdownMenu.test.tsx b/packages/core/src/DropdownMenu/XDSDropdownMenu.test.tsxindex 06d2f68d02..b702f839af 100644--- a/packages/core/src/DropdownMenu/XDSDropdownMenu.test.tsx+++ b/packages/core/src/DropdownMenu/XDSDropdownMenu.test.tsx@@ -359,6 +359,7 @@ describe('XDSDropdownMenu icon-only mode', () => {label: 'More options',icon: <span data-testid="icon">⋯</span>,variant: 'ghost',+ isIconOnly: true,}}items={[{label: 'Edit'}, {label: 'Delete'}]}/>,diff --git a/packages/core/src/DropdownMenu/XDSDropdownMenu.tsx b/packages/core/src/DropdownMenu/XDSDropdownMenu.tsxindex 04848c4cf1..255d289cd4 100644--- a/packages/core/src/DropdownMenu/XDSDropdownMenu.tsx+++ b/packages/core/src/DropdownMenu/XDSDropdownMenu.tsx@@ -602,9 +602,8 @@ export function XDSDropdownMenu({return elements;}, [items, renderItem]);- // Icon-only: when button has an icon and no children,- // XDSButton handles icon-only rendering natively.- const isIconOnly = button.icon != null && button.children == null;+ // Icon-only: check the explicit isIconOnly prop on the button config.+ const isIconOnly = button.isIconOnly === true;// Build endContent: use consumer's endContent if provided,// otherwise inject chevron (unless icon-only or hasChevron=false)diff --git a/packages/core/src/Layout/__tests__/edgeCompensation.test.tsx b/packages/core/src/Layout/__tests__/edgeCompensation.test.tsxindex 8bdeef2ced..f164b1ce4e 100644--- a/packages/core/src/Layout/__tests__/edgeCompensation.test.tsx+++ b/packages/core/src/Layout/__tests__/edgeCompensation.test.tsx@@ -90,7 +90,12 @@ describe('Edge Compensation', () => {it('applies edge compensation class to ghost icon-only button', () => {render(- <XDSButton label="Settings" variant="ghost" icon={<span>gear</span>} />,+ <XDSButton+ label="Settings"+ variant="ghost"+ icon={<span>gear</span>}+ isIconOnly+ />,);const button = screen.getByRole('button', {name: 'Settings'});expect(button).toBeInTheDocument();@@ -141,6 +146,7 @@ describe('Edge Compensation', () => {label="Search"variant="ghost"icon={<span>search</span>}+ isIconOnly/>}/>,@@ -171,11 +177,13 @@ describe('Edge Compensation', () => {label="Search"variant="ghost"icon={<span>search</span>}+ isIconOnly/><XDSButtonlabel="Settings"variant="ghost"icon={<span>gear</span>}+ isIconOnly/></>}diff --git a/packages/core/src/MobileNav/XDSMobileNav.tsx b/packages/core/src/MobileNav/XDSMobileNav.tsxindex 5bfa210092..34cdae62ee 100644--- a/packages/core/src/MobileNav/XDSMobileNav.tsx+++ b/packages/core/src/MobileNav/XDSMobileNav.tsx@@ -406,6 +406,7 @@ export function XDSMobileNav({label="Close navigation"icon={<XDSIcon icon="close" color="inherit" />}onClick={() => onOpenChange(false)}+ isIconOnly/></div>diff --git a/packages/core/src/MobileNav/XDSMobileNavToggle.tsx b/packages/core/src/MobileNav/XDSMobileNavToggle.tsxindex 9904c59600..92e6e7e13c 100644--- a/packages/core/src/MobileNav/XDSMobileNavToggle.tsx+++ b/packages/core/src/MobileNav/XDSMobileNavToggle.tsx@@ -11,7 +11,6 @@* Can be placed anywhere in the component tree (TopNav, content area, custom toolbar, etc.).*/-import {type ReactNode} from 'react';import {XDSButton} from '../Button';import {XDSIcon} from '../Icon';@@ -81,6 +80,7 @@ export function XDSMobileNavToggle({xstyle={xstyle}className={className}style={style}+ isIconOnly/>);}diff --git a/packages/core/src/MoreMenu/XDSMoreMenu.tsx b/packages/core/src/MoreMenu/XDSMoreMenu.tsxindex 46b7810471..4dc42bc939 100644--- a/packages/core/src/MoreMenu/XDSMoreMenu.tsx+++ b/packages/core/src/MoreMenu/XDSMoreMenu.tsx@@ -502,6 +502,7 @@ export function XDSMoreMenu({: undefined}data-testid={testId}+ isIconOnly/>{popover.render(<divdiff --git a/packages/core/src/Pagination/XDSPagination.tsx b/packages/core/src/Pagination/XDSPagination.tsxindex c0d0875043..24a2875a59 100644--- a/packages/core/src/Pagination/XDSPagination.tsx+++ b/packages/core/src/Pagination/XDSPagination.tsx@@ -541,7 +541,6 @@ export function XDSPagination({</div></div>)}-<div {...stylex.props(styles.controls)}><XDSButtonlabel="Go to previous page"@@ -550,6 +549,7 @@ export function XDSPagination({icon={<XDSIcon icon="chevronLeft" size={isSm ? 'sm' : 'md'} />}onClick={handlePrevious}isDisabled={isDisabled || !hasPrevious}+ isIconOnly/>{renderIndicator()}@@ -561,6 +561,7 @@ export function XDSPagination({icon={<XDSIcon icon="chevronRight" size={isSm ? 'sm' : 'md'} />}onClick={handleNext}isDisabled={isDisabled || !hasNext}+ isIconOnly/></div></nav>diff --git a/packages/core/src/PowerSearch/PowerSearchEditPopover.tsx b/packages/core/src/PowerSearch/PowerSearchEditPopover.tsxindex 42346c759f..b2c6efafd7 100644--- a/packages/core/src/PowerSearch/PowerSearchEditPopover.tsx+++ b/packages/core/src/PowerSearch/PowerSearchEditPopover.tsx@@ -486,6 +486,7 @@ function NestedEditor({variant="ghost"size="sm"onClick={() => handleRemove(itemPath)}+ isIconOnly/>) : undefined,};@@ -509,6 +510,7 @@ function NestedEditor({variant="ghost"size="sm"onClick={() => handleRemove(itemPath)}+ isIconOnly/>) : undefined,};diff --git a/packages/core/src/SideNav/XDSSideNavCollapseButton.tsx b/packages/core/src/SideNav/XDSSideNavCollapseButton.tsxindex 40250d3f01..7c2cf00c1d 100644--- a/packages/core/src/SideNav/XDSSideNavCollapseButton.tsx+++ b/packages/core/src/SideNav/XDSSideNavCollapseButton.tsx@@ -14,7 +14,6 @@* - /packages/core/src/SideNav/index.ts*/-import {useCallback, type ReactNode} from 'react';import * as stylex from '@stylexjs/stylex';import {durationVars, easeVars} from '../theme/tokens.stylex';@@ -127,6 +126,7 @@ export function XDSSideNavCollapseButton({</span>)}+ isIconOnly/>);}diff --git a/packages/core/src/Toast/XDSToast.tsx b/packages/core/src/Toast/XDSToast.tsxindex dfd735db50..3b1338853e 100644--- a/packages/core/src/Toast/XDSToast.tsx+++ b/packages/core/src/Toast/XDSToast.tsx@@ -180,9 +180,7 @@ export function XDSToast({)}><XDSMediaTheme mode={mediaMode}><div {...stylex.props(styles.inner)}>- <div {...stylex.props(styles.content)}>- {body}- </div>+ <div {...stylex.props(styles.content)}>{body}</div><div {...stylex.props(styles.endContent)}>{endContent}@@ -192,6 +190,7 @@ export function XDSToast({icon={<XDSIcon icon="close" size="sm" color="inherit" />}label="Dismiss notification"onClick={handleDismiss}+ isIconOnly/></div></div>diff --git a/packages/core/src/ToggleButton/XDSToggleButton.test.tsx b/packages/core/src/ToggleButton/XDSToggleButton.test.tsxindex b2c4dd3b06..8dc4243adf 100644--- a/packages/core/src/ToggleButton/XDSToggleButton.test.tsx+++ b/packages/core/src/ToggleButton/XDSToggleButton.test.tsx@@ -48,6 +48,7 @@ describe('XDSToggleButton', () => {isPressed={false}onPressedChange={() => {}}icon={<span data-testid="icon">B</span>}+ isIconOnly/>,);const button = screen.getByRole('button', {name: 'Bold'});@@ -115,6 +116,7 @@ describe('XDSToggleButton', () => {onPressedChange={() => {}}icon={<span data-testid="outline-icon">♡</span>}pressedIcon={<span data-testid="filled-icon">♥</span>}+ isIconOnly/>,);expect(screen.getByTestId('filled-icon')).toBeInTheDocument();@@ -129,6 +131,7 @@ describe('XDSToggleButton', () => {onPressedChange={() => {}}icon={<span data-testid="outline-icon">♡</span>}pressedIcon={<span data-testid="filled-icon">♥</span>}+ isIconOnly/>,);expect(screen.getByTestId('outline-icon')).toBeInTheDocument();@@ -172,6 +175,7 @@ describe('XDSToggleButton', () => {isPressed={false}onPressedChange={() => {}}icon={<span>B</span>}+ isIconOnly/>,);const button = screen.getByRole('button');@@ -201,9 +205,24 @@ describe('XDSToggleButtonGroup (single)', () => {const [value, setValue] = useState<string | null>('list');return (<XDSToggleButtonGroup value={value} onChange={setValue} label="View mode">- <XDSToggleButton value="list" label="List" icon={<span>≡</span>} />- <XDSToggleButton value="grid" label="Grid" icon={<span>⊞</span>} />- <XDSToggleButton value="card" label="Card" icon={<span>□</span>} />+ <XDSToggleButton+ value="list"+ label="List"+ icon={<span>≡</span>}+ isIconOnly+ />+ <XDSToggleButton+ value="grid"+ label="Grid"+ icon={<span>⊞</span>}+ isIconOnly+ />+ <XDSToggleButton+ value="card"+ label="Card"+ icon={<span>□</span>}+ isIconOnly+ /></XDSToggleButtonGroup>);}@@ -271,12 +290,23 @@ describe('XDSToggleButtonGroup (multiple)', () => {value={value}onChange={setValue}label="Formatting">- <XDSToggleButton value="bold" label="Bold" icon={<span>B</span>} />- <XDSToggleButton value="italic" label="Italic" icon={<span>I</span>} />+ <XDSToggleButton+ value="bold"+ label="Bold"+ icon={<span>B</span>}+ isIconOnly+ />+ <XDSToggleButton+ value="italic"+ label="Italic"+ icon={<span>I</span>}+ isIconOnly+ /><XDSToggleButtonvalue="underline"label="Underline"icon={<span>U</span>}+ isIconOnly/></XDSToggleButtonGroup>);diff --git a/packages/core/src/ToggleButton/XDSToggleButton.tsx b/packages/core/src/ToggleButton/XDSToggleButton.tsxindex db589afccb..2a5ef5792e 100644--- a/packages/core/src/ToggleButton/XDSToggleButton.tsx+++ b/packages/core/src/ToggleButton/XDSToggleButton.tsx@@ -122,12 +122,17 @@ export interface XDSToggleButtonProps {isLoading?: boolean;/**- * Icon element to render in the button.- * When provided without children, button becomes icon-only (square)- * with an automatic tooltip from the label.+ * Icon element rendered before the label text.*/icon?: ReactNode;+ /**+ * When true, renders as a square icon-only button with `label` as aria-label+ * and an automatic tooltip from the label.+ * @default false+ */+ isIconOnly?: boolean;+/*** Icon element to render when the button is pressed.* Use to swap between outline (unpressed) and filled (pressed) icon styles.@@ -142,8 +147,8 @@ export interface XDSToggleButtonProps {pressedIcon?: ReactNode;/**- * Optional visible content. If omitted and icon is provided,- * button becomes icon-only with label used as aria-label.+ * Optional visible content. When provided, rendered instead of `label`+ * as the visible text.*/children?: ReactNode;@@ -198,6 +203,7 @@ export function XDSToggleButton({isDisabled: isDisabledProp = false,isLoading = false,icon,+ isIconOnly = false,pressedIcon,children,tooltip,@@ -242,7 +248,7 @@ export function XDSToggleButton({]);// Label with font weight shift and width reservation- const isIconOnly = icon != null && children == null;+ // isIconOnly prop is the source of truth for icon-only rendering.const labelContent =children != null ? (<span {...stylex.props(labelStyles.wrapper)}>@@ -273,6 +279,7 @@ export function XDSToggleButton({size={size}isDisabled={isDisabled}isLoading={isLoading}+ isIconOnly={isIconOnly}aria-pressed={isPressed}icon={resolvedIcon}tooltip={tooltip}