Skip to content

Commit 5892203

Browse files
authored
Support dynamic fontsizes in iOS devices (#10181)
<!-- ☝️How to write a good PR title: - Prefix it with [ComponentName] (if applicable), for example: [Button] - Start with a verb, for example: Add, Delete, Improve, Fix… - Give as much context as necessary and as little as possible - Prefix it with [WIP] while it’s a work in progress --> ### WHY are these changes introduced? Currently Webviews & Mobile Web in iOS don't respect the users preference for Font Scale which is quite inaccessible. <!-- Context about the problem that’s being addressed. --> This PR introduces the use of font: -apple-system-body if it is supported. Inspired by this [dev.to article](https://dev.to/colingourlay/how-to-support-apple-s-dynamic-text-in-your-web-content-with-css-40c0#:~:text=If%20you've%20never%20seen,apple%2Dsystem%2Dbody%20) ### WHAT is this pull request doing? <details> <summary>Before</summary> <img src="https://github.com/Shopify/polaris/assets/703938/f1adb621-2982-4cc0-8946-bd5403e2a558" width="300"/> </details> <details> <summary>After</summary> <img src="https://github.com/Shopify/polaris/assets/703938/a213b56e-80ba-4fca-b09a-226ec2f6bec2" width="300"/> </details> <!-- ℹ️ Delete the following for small / trivial changes --> ### How to 🎩 1. Open iOS simulator 2. Open Safari within the iOS Simulator 3. Open polaris storybook using this url https://5d559397bae39100201eedc1-krdvxqhrcy.chromatic.com/?path=/story/all-components-text--variants 4. Change Fontscale in `Settings > Accessibility > Display & Text Size > Larger Text ` (using the slider at the bottom) 5. Switch back to Safari 6. Verify the font scale has updated to match the preference in accessibility ### 🎩 checklist - [x] Tested on [mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing) - [x] Tested on [multiple browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers) - [x] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [x] Updated the component's `README.md` with documentation changes - [x] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide
1 parent 4dbfb80 commit 5892203

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

.changeset/olive-fishes-provide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': minor
3+
---
4+
5+
Added support for [Dynamic Type](https://developer.apple.com/documentation/uikit/uifont/scaling_fonts_automatically) in iOS

polaris-react/src/components/AppProvider/AppProvider.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ html {
5555
text-rendering: optimizeLegibility;
5656
}
5757

58+
/*
59+
To support dynamic type in iOS, we need to set Apple's
60+
system font and then define font-families and rem-based
61+
font-sizes on descendant elements:
62+
*/
63+
@supports (font: -apple-system-body) {
64+
html {
65+
font: -apple-system-body;
66+
}
67+
}
68+
5869
body {
5970
min-height: 100%;
6071
margin: 0;

0 commit comments

Comments
 (0)