Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(core): scope the 16px input floor to iOS (#6085)

Manohar Paturi20229b56bf48
diff --git a/.changeset/input-floor-ios-only.md b/.changeset/input-floor-ios-only.md
new file mode 100644
index 0000000000..ec6863e25b
--- /dev/null
+++ b/.changeset/input-floor-ios-only.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] scope the 16px text-control font-size floor to iOS with `@supports (-webkit-touch-callout: none)` inside the coarse-pointer query, so Android and touch-screen laptops keep the theme's type scale instead of an inflated 16px (#6015)
+
+@ManoharPaturi
diff --git a/packages/core/src/Chat/ChatComposerInput.doc.mjs b/packages/core/src/Chat/ChatComposerInput.doc.mjs
index 8433c4b513..45744b42f5 100644
--- a/packages/core/src/Chat/ChatComposerInput.doc.mjs
+++ b/packages/core/src/Chat/ChatComposerInput.doc.mjs
@@ -7,7 +7,7 @@ export const docs = {
subComponentOf: 'Chat',
displayName: 'Chat Composer Input',
isHiddenFromOverview: true,
- description: "Rich text input for the chat composer. Supports trigger menus (type @ or / to open a typeahead), inline tokens rendered as badges, message history recall with ArrowUp/Down, paste/drop file handling, and a 16px touch-device font-size floor to prevent iOS input zoom. Pass it to ChatComposer's input slot when you need more than a plain textarea.",
+ description: "Rich text input for the chat composer. Supports trigger menus (type @ or / to open a typeahead), inline tokens rendered as badges, message history recall with ArrowUp/Down, paste/drop file handling, and a 16px iOS font-size floor to prevent input zoom. Pass it to ChatComposer's input slot when you need more than a plain textarea.",
props: [
{
name: 'handleRef',
@@ -92,7 +92,7 @@ export const docsZh = {
name: 'ChatComposerInput',
isHiddenFromOverview: true,
displayName: 'Chat Composer Input',
- description: '聊天编写器的富文本输入。支持触发菜单(输入 @ 或 / 打开 typeahead)、内联标记徽章、ArrowUp/Down 消息历史回溯、粘贴/拖放文件处理,并在触控设备上将字体大小保持至少 16px 以避免 iOS 输入缩放。当需要普通文本区域以外的功能时,传入 ChatComposer 的 input 插槽。',
+ description: '聊天编写器的富文本输入。支持触发菜单(输入 @ 或 / 打开 typeahead)、内联标记徽章、ArrowUp/Down 消息历史回溯、粘贴/拖放文件处理,并在 iOS 上将字体大小保持至少 16px 以避免输入缩放。当需要普通文本区域以外的功能时,传入 ChatComposer 的 input 插槽。',
propDescriptions: {
handleRef: '命令式句柄,用于编程式控制:insertToken、insertText、focus 和 getValue。',
value: '受控输入值。与 onChange 配对实现双向绑定。',
@@ -115,7 +115,7 @@ export const docsDense = {
name: 'ChatComposerInput',
isHiddenFromOverview: true,
displayName: 'Chat Composer Input',
- description: 'rich input for composer; trigger menus (@/commands), inline tokens, msg history, paste/drop files, 16px touch font-size floor to prevent iOS zoom. Use in ChatComposer input slot when you need more than plain textarea.',
+ description: 'rich input for composer; trigger menus (@/commands), inline tokens, msg history, paste/drop files, 16px iOS font-size floor to prevent zoom. Use in ChatComposer input slot when you need more than plain textarea.',
propDescriptions: {
handleRef: 'imperative handle (insertToken/insertText/focus/getValue)',
value: 'controlled value; pair w/ onChange for two-way binding',
diff --git a/packages/core/src/Chat/ChatComposerInput.tsx b/packages/core/src/Chat/ChatComposerInput.tsx
index a45cc2f65a..1855cbe208 100644
--- a/packages/core/src/Chat/ChatComposerInput.tsx
+++ b/packages/core/src/Chat/ChatComposerInput.tsx
@@ -233,9 +233,14 @@ const styles = stylex.create({
whiteSpace: 'pre-wrap',
wordBreak: 'break-word',
overflowY: 'auto',
+ // The 16px floor is iOS-only: iOS Safari zooms the page when a focused
+ // control sits under 16px, and only iOS WebKit implements
+ // -webkit-touch-callout to key the coarse-pointer floor to it.
fontSize: {
default: typeScaleVars['--text-body-size'],
- '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ },
},
lineHeight: `${LINE_HEIGHT_PX}px`,
fontFamily: typographyVars['--font-family-body'],
@@ -250,9 +255,12 @@ const styles = stylex.create({
insetInlineEnd: 0,
pointerEvents: 'none',
color: colorVars['--color-text-secondary'],
+ // Same iOS-only floor as the editable region it stands in for.
fontSize: {
default: typeScaleVars['--text-body-size'],
- '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ },
},
lineHeight: `${LINE_HEIGHT_PX}px`,
fontFamily: typographyVars['--font-family-body'],
diff --git a/packages/core/src/CommandPalette/CommandPaletteInput.tsx b/packages/core/src/CommandPalette/CommandPaletteInput.tsx
index af83638411..956072fbe7 100644
--- a/packages/core/src/CommandPalette/CommandPaletteInput.tsx
+++ b/packages/core/src/CommandPalette/CommandPaletteInput.tsx
@@ -73,9 +73,14 @@ const styles = stylex.create({
backgroundColor: 'transparent',
color: colorVars['--color-text-primary'],
fontFamily: typographyVars['--font-family-body'],
+ // The 16px floor is iOS-only: iOS Safari zooms the page when a focused
+ // control sits under 16px, and only iOS WebKit implements
+ // -webkit-touch-callout to key the coarse-pointer floor to it.
fontSize: {
default: typeScaleVars['--text-body-size'],
- '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ },
},
lineHeight: typeScaleVars['--text-body-leading'],
padding: 0,
diff --git a/packages/core/src/ComplexSelector/ComplexSelector.tsx b/packages/core/src/ComplexSelector/ComplexSelector.tsx
index ac7e289cca..5bae9a3945 100644
--- a/packages/core/src/ComplexSelector/ComplexSelector.tsx
+++ b/packages/core/src/ComplexSelector/ComplexSelector.tsx
@@ -65,9 +65,14 @@ const styles = stylex.create({
paddingBlock: spacingVars['--spacing-2'],
paddingInline: spacingVars['--spacing-3'],
fontFamily: typographyVars['--font-family-body'],
+ // The 16px floor is iOS-only: iOS Safari zooms the page when a focused
+ // control sits under 16px, and only iOS WebKit implements
+ // -webkit-touch-callout to key the coarse-pointer floor to it.
fontSize: {
default: typeScaleVars['--text-label-size'],
- '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-label-size']})`,
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': `max(1rem, ${typeScaleVars['--text-label-size']})`,
+ },
},
lineHeight: typeScaleVars['--text-label-leading'],
color: colorVars['--color-text-primary'],
diff --git a/packages/core/src/DateInput/DateInput.tsx b/packages/core/src/DateInput/DateInput.tsx
index bc270de7ed..c60fdd00d4 100644
--- a/packages/core/src/DateInput/DateInput.tsx
+++ b/packages/core/src/DateInput/DateInput.tsx
@@ -99,9 +99,14 @@ const styles = stylex.create({
borderStyle: 'none',
padding: 0,
fontFamily: typographyVars['--font-family-body'],
+ // The 16px floor is iOS-only: iOS Safari zooms the page when a focused
+ // control sits under 16px, and only iOS WebKit implements
+ // -webkit-touch-callout to key the coarse-pointer floor to it.
fontSize: {
default: typeScaleVars['--text-body-size'],
- '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ },
},
lineHeight: typeScaleVars['--text-body-leading'],
color: colorVars['--color-text-primary'],
diff --git a/packages/core/src/DateInput/NativeDateField.tsx b/packages/core/src/DateInput/NativeDateField.tsx
index ae5d87c09e..945c5af323 100644
--- a/packages/core/src/DateInput/NativeDateField.tsx
+++ b/packages/core/src/DateInput/NativeDateField.tsx
@@ -100,10 +100,14 @@ const styles = stylex.create({
borderStyle: 'none',
padding: 0,
fontFamily: typographyVars['--font-family-body'],
- // Below 16px iOS zooms the page when the field takes focus.
+ // Below 16px iOS zooms the page when the field takes focus. Only iOS
+ // WebKit implements -webkit-touch-callout, so the coarse-pointer floor is
+ // keyed to iOS alone.
fontSize: {
default: typeScaleVars['--text-body-size'],
- '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ },
},
lineHeight: typeScaleVars['--text-body-leading'],
color: colorVars['--color-text-primary'],
@@ -112,11 +116,20 @@ const styles = stylex.create({
// A date control's intrinsic height comes from its inner edit fields, not
// from `line-height`, so it renders ~2px taller than a text input and its
// value sits off the shared baseline inside the same flex row. One line
- // box is exactly what the text field occupies.
- height: stylex.firstThatWorks(
- '1lh',
- `calc(max(1rem, ${typeScaleVars['--text-body-size']}) * ${typeScaleVars['--text-body-leading']})`,
- ),
+ // box is exactly what the text field occupies. The calc fallback mirrors
+ // the iOS-only floor above; browsers with `1lh` track it for free.
+ height: {
+ default: stylex.firstThatWorks(
+ '1lh',
+ `calc(${typeScaleVars['--text-body-size']} * ${typeScaleVars['--text-body-leading']})`,
+ ),
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': stylex.firstThatWorks(
+ '1lh',
+ `calc(max(1rem, ${typeScaleVars['--text-body-size']}) * ${typeScaleVars['--text-body-leading']})`,
+ ),
+ },
+ },
// iOS gives date controls their own button-like chrome, with inner
// spacing and a centred value that no reset of ours can reach.
WebkitAppearance: 'none',
@@ -187,9 +200,12 @@ const styles = stylex.create({
// covers — one line of that leading fills its height exactly, which puts
// the glyphs on the input's own baseline.
display: 'block',
+ // ...with the input's own iOS floor, so the two baselines stay shared.
fontSize: {
default: typeScaleVars['--text-body-size'],
- '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ },
},
lineHeight: typeScaleVars['--text-body-leading'],
// A tap has to reach the control underneath — that is what raises the
diff --git a/packages/core/src/DateInput/TouchDateField.tsx b/packages/core/src/DateInput/TouchDateField.tsx
index da6b46119f..860bf2d26a 100644
--- a/packages/core/src/DateInput/TouchDateField.tsx
+++ b/packages/core/src/DateInput/TouchDateField.tsx
@@ -194,10 +194,14 @@ const styles = stylex.create({
padding: 0,
fontFamily: typographyVars['--font-family-body'],
// Below 16px iOS zooms the page on focus. The field is focusable even
- // though it is not typable, so it needs the same floor DateInput has.
+ // though it is not typable, so it needs the same floor DateInput has —
+ // keyed to iOS alone, since only iOS WebKit implements
+ // -webkit-touch-callout.
fontSize: {
default: typeScaleVars['--text-body-size'],
- '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ },
},
lineHeight: typeScaleVars['--text-body-leading'],
color: colorVars['--color-text-primary'],
diff --git a/packages/core/src/DateRangeInput/DateRangeInput.tsx b/packages/core/src/DateRangeInput/DateRangeInput.tsx
index 37707097fa..fb429c840c 100644
--- a/packages/core/src/DateRangeInput/DateRangeInput.tsx
+++ b/packages/core/src/DateRangeInput/DateRangeInput.tsx
@@ -92,9 +92,14 @@ const styles = stylex.create({
borderStyle: 'none',
padding: 0,
fontFamily: typographyVars['--font-family-body'],
+ // The 16px floor is iOS-only: iOS Safari zooms the page when a focused
+ // control sits under 16px, and only iOS WebKit implements
+ // -webkit-touch-callout to key the coarse-pointer floor to it.
fontSize: {
default: typeScaleVars['--text-body-size'],
- '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ },
},
lineHeight: typeScaleVars['--text-body-leading'],
color: colorVars['--color-text-primary'],
diff --git a/packages/core/src/DateTimeInput/DateTimeInput.tsx b/packages/core/src/DateTimeInput/DateTimeInput.tsx
index 23b69ae64e..3c77df35d9 100644
--- a/packages/core/src/DateTimeInput/DateTimeInput.tsx
+++ b/packages/core/src/DateTimeInput/DateTimeInput.tsx
@@ -173,9 +173,14 @@ const styles = stylex.create({
borderStyle: 'none',
padding: 0,
fontFamily: typographyVars['--font-family-body'],
+ // The 16px floor is iOS-only: iOS Safari zooms the page when a focused
+ // control sits under 16px, and only iOS WebKit implements
+ // -webkit-touch-callout to key the coarse-pointer floor to it.
fontSize: {
default: typeScaleVars['--text-body-size'],
- '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ },
},
lineHeight: typeScaleVars['--text-body-leading'],
color: colorVars['--color-text-primary'],
diff --git a/packages/core/src/DateTimeInput/TouchDateTimeField.tsx b/packages/core/src/DateTimeInput/TouchDateTimeField.tsx
index a47923e97e..6337d8877a 100644
--- a/packages/core/src/DateTimeInput/TouchDateTimeField.tsx
+++ b/packages/core/src/DateTimeInput/TouchDateTimeField.tsx
@@ -182,9 +182,14 @@ const styles = stylex.create({
borderStyle: 'none',
padding: 0,
fontFamily: typographyVars['--font-family-body'],
+ // The 16px floor is iOS-only: iOS Safari zooms the page when a focused
+ // control sits under 16px, and only iOS WebKit implements
+ // -webkit-touch-callout to key the coarse-pointer floor to it.
fontSize: {
default: typeScaleVars['--text-body-size'],
- '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ },
},
lineHeight: typeScaleVars['--text-body-leading'],
color: colorVars['--color-text-primary'],
diff --git a/packages/core/src/DateTimeInput/nativePickerSegmentStyles.ts b/packages/core/src/DateTimeInput/nativePickerSegmentStyles.ts
index 4f4719ca2f..2fee36db1c 100644
--- a/packages/core/src/DateTimeInput/nativePickerSegmentStyles.ts
+++ b/packages/core/src/DateTimeInput/nativePickerSegmentStyles.ts
@@ -42,21 +42,34 @@ export const nativePickerSegmentStyles = stylex.create({
borderStyle: 'none',
padding: 0,
fontFamily: typographyVars['--font-family-body'],
- // Below 16px iOS zooms the page when the field takes focus.
+ // Below 16px iOS zooms the page when the field takes focus. Only iOS
+ // WebKit implements -webkit-touch-callout, so the coarse-pointer floor is
+ // keyed to iOS alone.
fontSize: {
default: typeScaleVars['--text-body-size'],
- '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ },
},
lineHeight: typeScaleVars['--text-body-leading'],
color: colorVars['--color-text-primary'],
backgroundColor: 'transparent',
outline: 'none',
// Native date/time controls size from their internal edit fields. Pin the
- // box to one text line so both segments stay aligned.
- height: stylex.firstThatWorks(
- '1lh',
- `calc(max(1rem, ${typeScaleVars['--text-body-size']}) * ${typeScaleVars['--text-body-leading']})`,
- ),
+ // box to one text line so both segments stay aligned. The calc fallback
+ // mirrors the iOS-only floor above; browsers with `1lh` track it for free.
+ height: {
+ default: stylex.firstThatWorks(
+ '1lh',
+ `calc(${typeScaleVars['--text-body-size']} * ${typeScaleVars['--text-body-leading']})`,
+ ),
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': stylex.firstThatWorks(
+ '1lh',
+ `calc(max(1rem, ${typeScaleVars['--text-body-size']}) * ${typeScaleVars['--text-body-leading']})`,
+ ),
+ },
+ },
WebkitAppearance: 'none',
appearance: 'none',
// DateTimeInput renders its own calendar/clock affordances.
@@ -101,9 +114,12 @@ export const nativePickerSegmentStyles = stylex.create({
insetInlineEnd: 0,
insetBlock: 0,
display: 'block',
+ // The same iOS-only floor as the input it covers, shared baselines.
fontSize: {
default: typeScaleVars['--text-body-size'],
- '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ },
},
lineHeight: typeScaleVars['--text-body-leading'],
pointerEvents: 'none',
diff --git a/packages/core/src/Field/PanelSearchInput.tsx b/packages/core/src/Field/PanelSearchInput.tsx
index 6d88682065..a87492350e 100644
--- a/packages/core/src/Field/PanelSearchInput.tsx
+++ b/packages/core/src/Field/PanelSearchInput.tsx
@@ -119,10 +119,13 @@ const styles = stylex.create({
color: colorVars['--color-text-primary'],
fontFamily: typographyVars['--font-family-body'],
// Matches the option rows below it, so the query reads as the first line of
- // the list. The coarse-pointer floor keeps iOS from zooming on focus.
+ // the list. The floor keeps iOS from zooming on focus — keyed to iOS
+ // alone, since only iOS WebKit implements -webkit-touch-callout.
fontSize: {
default: typeScaleVars['--text-label-size'],
- '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-label-size']})`,
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': `max(1rem, ${typeScaleVars['--text-label-size']})`,
+ },
},
lineHeight: typeScaleVars['--text-label-leading'],
// The field draws the focus ring (see `field`), so the bare input must not
diff --git a/packages/core/src/FileInput/FileInput.tsx b/packages/core/src/FileInput/FileInput.tsx
index 8b4be7fa22..61fee82382 100644
--- a/packages/core/src/FileInput/FileInput.tsx
+++ b/packages/core/src/FileInput/FileInput.tsx
@@ -231,9 +231,14 @@ const styles = stylex.create({
},
placeholderText: {
fontFamily: typographyVars['--font-family-body'],
+ // The 16px floor is iOS-only: iOS Safari zooms the page when a focused
+ // control sits under 16px, and only iOS WebKit implements
+ // -webkit-touch-callout to key the coarse-pointer floor to it.
fontSize: {
default: typeScaleVars['--text-body-size'],
- '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ },
},
lineHeight: typeScaleVars['--text-body-leading'],
color: colorVars['--color-text-secondary'],
@@ -242,9 +247,13 @@ const styles = stylex.create({
},
fileNameText: {
fontFamily: typographyVars['--font-family-body'],
+ // ...and the filename beside it keeps the same floor, so both lines the
+ // control shows stay the same size.
fontSize: {
default: typeScaleVars['--text-body-size'],
- '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ },
},
lineHeight: typeScaleVars['--text-body-leading'],
color: colorVars['--color-text-primary'],
diff --git a/packages/core/src/NumberInput/NumberInput.tsx b/packages/core/src/NumberInput/NumberInput.tsx
index 61dfccc559..66ae43a7fd 100644
--- a/packages/core/src/NumberInput/NumberInput.tsx
+++ b/packages/core/src/NumberInput/NumberInput.tsx
@@ -105,9 +105,14 @@ const styles = stylex.create({
borderStyle: 'none',
padding: 0,
fontFamily: typographyVars['--font-family-body'],
+ // The 16px floor is iOS-only: iOS Safari zooms the page when a focused
+ // control sits under 16px, and only iOS WebKit implements
+ // -webkit-touch-callout to key the coarse-pointer floor to it.
fontSize: {
default: typeScaleVars['--text-body-size'],
- '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ },
},
lineHeight: typeScaleVars['--text-body-leading'],
color: colorVars['--color-text-primary'],
diff --git a/packages/core/src/Selector/Selector.tsx b/packages/core/src/Selector/Selector.tsx
index 4e2895140f..cbc7647fc7 100644
--- a/packages/core/src/Selector/Selector.tsx
+++ b/packages/core/src/Selector/Selector.tsx
@@ -102,9 +102,14 @@ const styles = stylex.create({
paddingBlock: spacingVars['--spacing-2'],
paddingInline: spacingVars['--spacing-3'],
fontFamily: typographyVars['--font-family-body'],
+ // The 16px floor is iOS-only: iOS Safari zooms the page when a focused
+ // control sits under 16px, and only iOS WebKit implements
+ // -webkit-touch-callout to key the coarse-pointer floor to it.
fontSize: {
default: typeScaleVars['--text-label-size'],
- '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-label-size']})`,
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': `max(1rem, ${typeScaleVars['--text-label-size']})`,
+ },
},
// A FIXED line box, not the ratio: the trigger's padding is derived from
// one line being `--spacing-5` tall, and a ratio makes the line box track
diff --git a/packages/core/src/TextArea/TextArea.tsx b/packages/core/src/TextArea/TextArea.tsx
index e8c29b6693..fa5d000155 100644
--- a/packages/core/src/TextArea/TextArea.tsx
+++ b/packages/core/src/TextArea/TextArea.tsx
@@ -95,9 +95,14 @@ const styles = stylex.create({
paddingBlock: spacingVars['--spacing-1'],
paddingInline: 'var(--_textarea-inline-padding)',
fontFamily: typographyVars['--font-family-body'],
+ // The 16px floor is iOS-only: iOS Safari zooms the page when a focused
+ // control sits under 16px, and only iOS WebKit implements
+ // -webkit-touch-callout to key the coarse-pointer floor to it.
fontSize: {
default: typeScaleVars['--text-body-size'],
- '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ },
},
lineHeight: typeScaleVars['--text-body-leading'],
color: colorVars['--color-text-primary'],
diff --git a/packages/core/src/TextInput/TextInput.test.tsx b/packages/core/src/TextInput/TextInput.test.tsx
index 4213d0b304..36ed1ca7b7 100644
--- a/packages/core/src/TextInput/TextInput.test.tsx
+++ b/packages/core/src/TextInput/TextInput.test.tsx
@@ -2,7 +2,8 @@
/**
* @file TextInput.test.tsx
- * @input Uses vitest, @testing-library/react, TextInput component
+ * @input Uses vitest, @testing-library/react, TextInput component, and the
+ * shared declaredValue StyleX read-back helper
* @output Unit tests for TextInput component behavior
* @position Testing; validates TextInput.tsx implementation
*
@@ -13,6 +14,7 @@ import {describe, it, expect, vi, beforeEach} from 'vitest';
import {render, screen, fireEvent, waitFor} from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import {TestIcon} from '../__tests__/TestIcon';
+import {declaredValue} from '../__tests__/stylexDeclarations';
import {InputGroup} from '../InputGroup';
import {TextInput} from './TextInput';
@@ -1113,3 +1115,20 @@ describe('TextInput clear button focus behavior', () => {
rafSpy.mockRestore();
});
});
+
+describe('TextInput text size', () => {
+ it('renders the theme body size outside the iOS zoom gate', () => {
+ // The 16px floor rides `@supports (-webkit-touch-callout: none)` inside
+ // `@media (pointer: coarse)` — iOS Safari is the browser that zooms on
+ // focus under 16px, so the floor targets it alone instead of every
+ // coarse pointer. jsdom's CSSOM drops at-rule-wrapped declarations it
+ // cannot parse, so the gate itself is pinned against the sources in
+ // inputFontFloor.test.ts; what this asserts is the visible result off
+ // the gate: the plain token size, not a floor.
+ render(<TextInput label="Name" value="" onChange={() => {}} />);
+ expect(declaredValue(screen.getByLabelText('Name'), 'font-size')).toBe(
+ 'var(--text-body-size)',
+ );
+ });
+});
+
diff --git a/packages/core/src/TextInput/TextInput.tsx b/packages/core/src/TextInput/TextInput.tsx
index 4714a0a85a..c1c6c8c357 100644
--- a/packages/core/src/TextInput/TextInput.tsx
+++ b/packages/core/src/TextInput/TextInput.tsx
@@ -58,9 +58,14 @@ const styles = stylex.create({
borderStyle: 'none',
padding: 0,
fontFamily: typographyVars['--font-family-body'],
+ // The 16px floor is iOS-only: iOS Safari zooms the page when a focused
+ // control sits under 16px, and only iOS WebKit implements
+ // -webkit-touch-callout to key the coarse-pointer floor to it.
fontSize: {
default: typeScaleVars['--text-body-size'],
- '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ },
},
lineHeight: typeScaleVars['--text-body-leading'],
color: colorVars['--color-text-primary'],
diff --git a/packages/core/src/TimeInput/TimeInput.tsx b/packages/core/src/TimeInput/TimeInput.tsx
index 0ba855340e..c70a071121 100644
--- a/packages/core/src/TimeInput/TimeInput.tsx
+++ b/packages/core/src/TimeInput/TimeInput.tsx
@@ -95,9 +95,14 @@ const styles = stylex.create({
borderStyle: 'none',
padding: 0,
fontFamily: typographyVars['--font-family-body'],
+ // The 16px floor is iOS-only: iOS Safari zooms the page when a focused
+ // control sits under 16px, and only iOS WebKit implements
+ // -webkit-touch-callout to key the coarse-pointer floor to it.
fontSize: {
default: typeScaleVars['--text-body-size'],
- '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ },
},
lineHeight: typeScaleVars['--text-body-leading'],
color: colorVars['--color-text-primary'],
diff --git a/packages/core/src/Typeahead/BaseTypeahead.tsx b/packages/core/src/Typeahead/BaseTypeahead.tsx
index 5ad677664f..039ce94b92 100644
--- a/packages/core/src/Typeahead/BaseTypeahead.tsx
+++ b/packages/core/src/Typeahead/BaseTypeahead.tsx
@@ -262,9 +262,14 @@ const styles = stylex.create({
borderStyle: 'none',
padding: 0,
fontFamily: typographyVars['--font-family-body'],
+ // The 16px floor is iOS-only: iOS Safari zooms the page when a focused
+ // control sits under 16px, and only iOS WebKit implements
+ // -webkit-touch-callout to key the coarse-pointer floor to it.
fontSize: {
default: typeScaleVars['--text-body-size'],
- '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ },
},
lineHeight: typeScaleVars['--text-body-leading'],
color: colorVars['--color-text-primary'],
diff --git a/packages/core/src/inputFontFloor.test.ts b/packages/core/src/inputFontFloor.test.ts
new file mode 100644
index 0000000000..44d563dfa9
--- /dev/null
+++ b/packages/core/src/inputFontFloor.test.ts
@@ -0,0 +1,106 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file inputFontFloor.test.ts
+ * @input Uses node:fs and node:path to read the text-control sources
+ * @output Invariants for the 16px input floor shared by every text control
+ * @position Family-wide source test, in the source-reading style of
+ * reset.test.ts. jsdom's CSSOM drops declarations nested inside @supports,
+ * so the iOS branch cannot be asserted against injected rules — the
+ * runtime half (no bare coarse-pointer floor) lives in TextInput.test.tsx.
+ */
+
+import {readFileSync, readdirSync} from 'node:fs';
+import path from 'node:path';
+
+import {describe, expect, it} from 'vitest';
+
+/**
+ * Every control that floors its text to 16px. iOS Safari zooms the page when
+ * a focused control renders under 16px; no other coarse-pointer browser does.
+ * `-webkit-touch-callout` is implemented by iOS WebKit alone, so each floor
+ * nests `@supports (-webkit-touch-callout: none)` inside the coarse-pointer
+ * query: iPhones and iPads keep the zoom guard, while Android and touch
+ * laptops keep the theme's own type scale instead of an inflated 16px.
+ */
+const FLOORED_CONTROLS = [
+ 'Chat/ChatComposerInput.tsx',
+ 'CommandPalette/CommandPaletteInput.tsx',
+ 'ComplexSelector/ComplexSelector.tsx',
+ 'DateInput/DateInput.tsx',
+ 'DateInput/NativeDateField.tsx',
+ 'DateInput/TouchDateField.tsx',
+ 'DateRangeInput/DateRangeInput.tsx',
+ 'DateTimeInput/DateTimeInput.tsx',
+ 'DateTimeInput/TouchDateTimeField.tsx',
+ 'DateTimeInput/nativePickerSegmentStyles.ts',
+ 'Field/PanelSearchInput.tsx',
+ 'FileInput/FileInput.tsx',
+ 'NumberInput/NumberInput.tsx',
+ 'Selector/Selector.tsx',
+ 'TextArea/TextArea.tsx',
+ 'TextInput/TextInput.tsx',
+ 'TimeInput/TimeInput.tsx',
+ 'Typeahead/BaseTypeahead.tsx',
+ // The rich-text package carries the same floor; its path is relative to
+ // packages/core/src.
+ '../../richtext/src/RichTextEditor.tsx',
+];
+
+/** A font floor applied to every coarse pointer, iOS or not. */
+const BARE_COARSE_FLOOR = `'@media (pointer: coarse)': \`max(1rem`;
+
+/** The same floor, gated to iOS WebKit inside the coarse-pointer query. */
+const IOS_GATED_FLOOR =
+ /'@media \(pointer: coarse\)': \{\s*'@supports \(-webkit-touch-callout: none\)': `max\(1rem, \$\{typeScaleVars\['--text-(?:body|label)-size'\]\}\)`/;
+
+/** Collect every non-test component source under `dir`, recursively. */
+function componentSources(dir: string): string[] {
+ const SOURCE_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx'];
+ const out: string[] = [];
+ for (const entry of readdirSync(dir, {withFileTypes: true})) {
+ const full = path.join(dir, entry.name);
+ if (entry.isDirectory()) {
+ out.push(...componentSources(full));
+ } else if (
+ SOURCE_EXTENSIONS.some(ext => entry.name.endsWith(ext)) &&
+ !entry.name.endsWith('.test.ts') &&
+ !entry.name.endsWith('.test.tsx') &&
+ !entry.name.endsWith('.doc.mjs')
+ ) {
+ out.push(full);
+ }
+ }
+ return out;
+}
+
+describe('the 16px input floor', () => {
+ it('gates every floored text control to iOS alone', () => {
+ // Guards the loop below against the list silently emptying out.
+ expect(FLOORED_CONTROLS.length).toBeGreaterThanOrEqual(18);
+ for (const file of FLOORED_CONTROLS) {
+ const source = readFileSync(path.resolve(__dirname, file), 'utf8');
+ expect(source, file).toMatch(IOS_GATED_FLOOR);
+ expect(source, file).not.toContain(BARE_COARSE_FLOOR);
+ }
+ });
+
+ it('leaves no bare coarse-pointer font floor anywhere in core or richtext', () => {
+ // Catches a new (or renamed) control reintroducing the ungated floor,
+ // wherever it lands — the list above only knows the current family. The
+ // rich-text package carries the same floor, so it is scanned too.
+ const scanRoots = [
+ __dirname,
+ path.resolve(__dirname, '../../richtext/src'),
+ ];
+ const offenders = scanRoots
+ .flatMap(root => componentSources(root))
+ .map(file => ({
+ file,
+ source: readFileSync(file, 'utf8'),
+ }))
+ .filter(({source}) => source.includes(BARE_COARSE_FLOOR))
+ .map(({file}) => path.relative(__dirname, file));
+ expect(offenders).toEqual([]);
+ });
+});
diff --git a/packages/richtext/src/RichTextEditor.tsx b/packages/richtext/src/RichTextEditor.tsx
index 4d39dd3f83..9bed8f0947 100644
--- a/packages/richtext/src/RichTextEditor.tsx
+++ b/packages/richtext/src/RichTextEditor.tsx
@@ -182,11 +182,16 @@ const styles = stylex.create({
width: '100%',
// ContentEditable and Lexical's sibling placeholder inherit one shared
// text style. This keeps their leading and coarse-pointer sizing identical
- // to TextInput/TextArea without duplicating placeholder typography.
+ // to TextInput/TextArea without duplicating placeholder typography. The
+ // 16px floor is iOS-only: iOS Safari zooms the page when a focused
+ // control sits under 16px, and only iOS WebKit implements
+ // -webkit-touch-callout to key the coarse-pointer floor to it.
fontFamily: typographyVars['--font-family-body'],
fontSize: {
default: typeScaleVars['--text-body-size'],
- '@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ '@media (pointer: coarse)': {
+ '@supports (-webkit-touch-callout: none)': `max(1rem, ${typeScaleVars['--text-body-size']})`,
+ },
},
lineHeight: typeScaleVars['--text-body-leading'],
},