From d229cb8ccb6fefba695f00b1ff13e105faa9ca46 Mon Sep 17 00:00:00 2001 From: lukewalczak Date: Fri, 20 Nov 2026 10:46:58 +0100 Subject: [PATCH 1/3] feat(text-input)!: rename TextInput.Icon size to iconSize BREAKING CHANGE: TextInput.Icon's `size` is renamed `iconSize`, matching IconButton. --- docs/6.x/docs/guides/migration.md | 12 ++++++++++++ src/components/TextInput/TextInputIcon.tsx | 11 ++--------- src/components/__tests__/TextInput.test.tsx | 6 +++--- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/docs/6.x/docs/guides/migration.md b/docs/6.x/docs/guides/migration.md index ac0a7574b9..76d1c149a8 100644 --- a/docs/6.x/docs/guides/migration.md +++ b/docs/6.x/docs/guides/migration.md @@ -933,6 +933,18 @@ const [value, setValue] = React.useState(''); /> ``` +#### Icon size + +`TextInput.Icon`'s `size` is renamed `iconSize`, as on `IconButton`, where `size` is now a named container scale. + +```tsx +// Before (v5) + + +// After (v6) + +``` + #### Label and supporting text - **`label: React.Element | string`** → **`string`** diff --git a/src/components/TextInput/TextInputIcon.tsx b/src/components/TextInput/TextInputIcon.tsx index 6d6149fc0e..120c93caa4 100644 --- a/src/components/TextInput/TextInputIcon.tsx +++ b/src/components/TextInput/TextInputIcon.tsx @@ -26,12 +26,7 @@ export type TextInputAccessoryProps = { }; export type TextInputIconProps = TextInputAccessoryProps & - Omit & { - /** - * Size of the icon. `iconSize` isn't accepted: the size comes from here. - */ - size?: number; - }; + Omit; /** * A component to render a leading / trailing icon in the TextInput @@ -79,7 +74,7 @@ export type TextInputIconProps = TextInputAccessoryProps & const TextInputIcon = ({ icon, iconColor, - size, + iconSize = ACCESSORY_SIZE, style, error, disabled, @@ -91,8 +86,6 @@ const TextInputIcon = ({ }: TextInputIconProps) => { const theme = useInternalTheme(themeOverride); - const iconSize = size ?? ACCESSORY_SIZE; - const color = getIconColor({ theme, iconColor, diff --git a/src/components/__tests__/TextInput.test.tsx b/src/components/__tests__/TextInput.test.tsx index 487cd2c48e..3eed471fbd 100644 --- a/src/components/__tests__/TextInput.test.tsx +++ b/src/components/__tests__/TextInput.test.tsx @@ -1824,14 +1824,14 @@ it('keeps the 48dp TextInput.Icon target when a forwarded hitSlop is undefined', }); }); -it('takes the glyph size from `size`, not `iconSize`', async () => { +it('accepts `iconSize` but not the named `size`', async () => { await render( ( - // @ts-expect-error `iconSize` is not a TextInput.Icon prop - + // @ts-expect-error `size` is not a TextInput.Icon prop + )} /> ); From 503dcbc6421a58b4c0e73098346d62974efcdacd Mon Sep 17 00:00:00 2001 From: lukewalczak Date: Fri, 20 Nov 2026 10:46:58 +0100 Subject: [PATCH 2/3] chore: document the size and iconSize prop naming convention --- .github/instructions/code.instructions.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/instructions/code.instructions.md b/.github/instructions/code.instructions.md index 9f0d264fef..353a7ff72b 100644 --- a/.github/instructions/code.instructions.md +++ b/.github/instructions/code.instructions.md @@ -37,6 +37,7 @@ applyTo: '**/*.{ts,tsx,js,jsx}' - Verify that components forward relevant native props and events without changing their meaning. - Ensure controlled values have callbacks to update them. Support uncontrolled input when controlled rendering causes a demonstrated performance or reliability problem. - Merge consumer styles after defaults for supported overrides. Check that computed styles preserve supplied padding, colors, dimensions, and other supported values. +- Name size props by what they size: `size` for the whole component (a named scale such as `'small'` or a number), `iconSize` for only the icon glyph inside it. A component that is itself an icon, such as `Icon`, uses `size`. - Expose test IDs for public interaction or content. Avoid IDs on internal wrappers solely for tests and default IDs that can collide across component instances. ## Design and Accessibility From 535f3ef82c92742720eb39d656f1a1bd2dfc841a Mon Sep 17 00:00:00 2001 From: lukewalczak Date: Fri, 20 Nov 2026 11:46:36 +0100 Subject: [PATCH 3/3] test(text-input): assert TextInput.Icon glyph follows iconSize --- src/components/__tests__/TextInput.test.tsx | 33 +++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/components/__tests__/TextInput.test.tsx b/src/components/__tests__/TextInput.test.tsx index 3eed471fbd..6684621fb1 100644 --- a/src/components/__tests__/TextInput.test.tsx +++ b/src/components/__tests__/TextInput.test.tsx @@ -1824,14 +1824,41 @@ it('keeps the 48dp TextInput.Icon target when a forwarded hitSlop is undefined', }); }); -it('accepts `iconSize` but not the named `size`', async () => { +it('sizes the TextInput.Icon glyph with `iconSize`', async () => { await render( ( - // @ts-expect-error `size` is not a TextInput.Icon prop - + ( + + )} + /> + )} + /> + ); + + expect(screen.getByTestId('glyph', includeHiddenElements)).toHaveStyle({ + width: 12, + height: 12, + }); +}); + +it('rejects the named `size` on TextInput.Icon', async () => { + await render( + ( + )} /> );