-
Notifications
You must be signed in to change notification settings - Fork 13.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: [7.5.0] Assumes html font size is 16px. Html font-size: 10px
makes the text small for all ionic components.
#28361
Comments
Thanks for the issue. I am going to close this as this is not a bug in Ionic Framework. While setting Ionic looks to the root font size to determine how to size the text in its components by using I'd recommend using CSS variables instead of overriding the font sizes for this purpose. Your margins are tightly coupled to the root font size, so this means that any component (not just Ionic components) that uses Instead, I'd recommend doing the following: :root {
--custom-margin-sm: 8px;
--custom-margin: 10px;
--custom-margin-md: 14px;
--custom-margin-lg: 16px;
} These are just example sizes, so you can set them to whatever you want. If you are using SASS, you can use a SASS variable so that the generated CSS variables update as you change the base SASS variable: $default-margin: 10px;
:root {
--custom-margin-sm: $default-margin * 0.8;
--custom-margin: $default-margin;
--custom-margin-md: $default-margin * 1.4;
--custom-margin-lg: $default-margin * 1.6;
} |
@liamdebeasi Take Bootstrap for example. They have a For us, this change in 7.5.0 created hundreds of UI errors without any warning of this side effect in your release notes or blog. Therefore, I saw it as a bug. Since, forcing everyone to use an html font size of 16px is constricting, should I pose this as a feature request? |
This is not simple for Ionic to implement, and we think this would degrade the developer experience. The only option to both avoid this problem and support Dynamic Font Scaling is to use Your application would likely run into this problem too if you used
This change is mentioned on both the announcement blog ("As part of this change most Ionic UI components have been updated to use rem units instead of px units where appropriate.") and on the Dynamic Font Scaling documentation.
Ionic does not force anyone to use a root font size of 16px. The I understand this is causing an undesired change in your application, but Ionic is working as intended here. Your application is telling the browser to set the root font size to The approach your application takes makes it very challenging to customize font sizes since you can not use |
These reference expresses the change in components but does not warn of side effects (and for us, this is a breaking change). We desire to opt out of Dynamic Font Scaling and set the root font size to utilize rem for sizing like The only workaround I see here is to have a shared style sheet between all of our apps, explicitly setting the font size of all Ionic components. (Which is an undesired maintenance as it will have to be updated with Ionic updates). Btw, Bootstrap does both font-size-root/font-size-base and dynamic font scaling. So it is possible. |
My main argument was that this isn't a great practice in mobile applications and will lead to other issues that I've detailed in previous comments. Typically in mobile apps the text scales and related elements scale in size to accommodate the larger text size. However, things like margins and paddings typically don't increase in size except for specific circumstances (such as with complex components like a date picker).
According to twbs/bootstrap#34107, Bootstrap does not support font scaling on iOS which is what Ionic's Dynamic Font Scaling feature was primarily designed for.
The other solution is to implement design tokens instead of relying on font size for padding and margin. Design tokens are very common in applications for implementing a consistent design system. I think this thread has served its purpose, so I'm going to lock it. |
Prerequisites
Ionic Framework Version
v7.x
Current Behavior
For the past 3 years of using Ionic, we have always used rem for font sizes and styling dimensions. However, we set the html font size to 10px and the body font size to 1.6rem. This allows us to write
margin: 1rem
for a 10px margin.After upgrading to 7.5.0, component font sizes are small due to the html font size being 10px. There should be a way to denote to the Ionic framework what the html font size is instead of the framework assuming that the html font size is 16px.
Expected Behavior
ion-header > ion-toolbar > ion-title font size is 12.5px
Expected: 20px
ion-button font-size is 8.75px
Expected: 14px
Steps to Reproduce
Code Reproduction URL
https://github.com/fieldscage/ionic-component-sizes
Ionic Info
Ionic:
Ionic CLI : 7.1.1 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/vue 7.5.0
Utility:
cordova-res : not installed globally
native-run : not installed globally
System:
NodeJS : v18.18.0 (/usr/local/bin/node)
npm : 9.8.1
OS : macOS 14.0
Additional Information
No response
The text was updated successfully, but these errors were encountered: