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
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..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('takes the glyph size from `size`, not `iconSize`', async () => {
+it('sizes the TextInput.Icon glyph with `iconSize`', async () => {
await render(
(
- // @ts-expect-error `iconSize` 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(
+ (
+
)}
/>
);