-
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
ion-icons not being aligned correctly in label and button #18033
Comments
Hi there, Thanks for the issue! Would you say this is the same as #16422? Thanks! |
It looks similar but has a little difference: Besides in #16422 no buttons are mentioned. |
Thanks for the issue! Here's a workaround for this: https://codepen.io/brandyscarney/pen/WWXrLg?editors=1100 |
@brandyscarney should we be doing that globally or will that create issues? Not recommended? Edit: this issue exists anywhere you put the icon outside of an item. Headings (h1 h2), ion-text, etc. Edit 2: yeeah that fix breaks all kinds of things. For now this is my global fix:
|
I'm encountering this as well, and it's not related to ion-label, it occurs with an ion-item and any textual content (I want the ion-icon to flow as part of the text). The fix above kinda fixes it, but the padding-bottom has to be adjusted based on the text size or icon. Feels wrong! |
Hello! We have revisited this issue with the latest version of Ionic Framework (v7) and have found the following: The button alignment has been resolved since this issue was created. Below is a comparison between the button from the image in this issue and a button using the latest version of Ionic Framework: The label alignment is a bit trickier. Due to the fact that
The above could be solved by applying
In addition, adding an icon inside of a floating label does not align with the Material Design Guidelines. In both Material Design 2 (released in 2018) and Material Design 3 (released in 2021) the leading icon does not float with the text.
As a result of the above, we have decided not to change the styling on the <ion-item>
<ion-input label-placement="floating">
<div slot="label" style="display: flex; align-items: center;">
<ion-icon name="person" style="margin-right: 6px;"></ion-icon>
Benutzername
</div>
</ion-input>
</ion-item>
<ion-item>
<ion-input label-placement="floating">
<div slot="label" style="display: flex; align-items: center;">
<ion-icon name="lock-closed" style="margin-right: 6px;"></ion-icon>
Passwort
</div>
</ion-input>
</ion-item>
<ion-item>
<ion-input label-placement="floating">
<div slot="label" style="display: flex; align-items: center;">
<ion-icon name="globe" style="margin-right: 6px;"></ion-icon>
Server
</div>
</ion-input>
</ion-item> However, if you intend to match Material Design Guidelines, which we recommend, we are working on adding start and end slots to input to support icons in an input. If anyone is running into other alignment issues please create a new issue, thank you! |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Bug Report
Ionic version:
[x] 4.2.0
Current behavior:
When using ion-icon inside a button or label, text and icon are not aligned correctly.
Expected behavior:
Icon and text should be aligned.
Steps to reproduce:
Related code:
results in
Other information:
Ionic info:
The text was updated successfully, but these errors were encountered: