You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: built-in 'underline' for form control #27239
As I mentioned, it should be customizable, especially the length (where you want it to underline, the whole, or exclude label and just the fill in area).
Reacted by Lucas Mateus, Pablo Martins, ckubitza, Wasenshi, Mario, Wilfredo Pomier, Jan Adamski, Klavdij Oberstar and Jonathan Christian
Outside of the small visual adjustments between legacy and modern to align with the Material design spec, I don't currently see an issue with the underline between the displays.
Outside of the small visual adjustments between legacy and modern to align with the Material design spec, I don't currently see an issue with the underline between the displays.
I mean to have the ability to set this on the form control
As I demonstrated, I tried to add it manually with css on the new syntax one, but that's not quite the exact feeling because it underline the whole thing. So I think the built-in feature for this would be nice.
Please see this screen shot, my desired structure has the behavior to change label placement based on screen size. So at wider screen, the difference is noticeable:
My example is also updated to dynamically change label placement now.
Thank you for the extra detail + screenshots! I understand the differences now 👍
The underline border always being visible could be accomplished if Ionic exposed shadow parts for the native wrapper on each control (or CSS variables for border, since not all controls use shadow dom).
The underline width is a much larger task.
For ion-input, the input highlight would need to be conditionally rendered either at the host level (to fill the entire width) or within the .native-wrapper when only wanting to display the highlight under the control. The .native-wrapper would also need: position: relative to contain the element positioning.
Here is an example concept with manually modifying the DOM and adjusting styling:
Lastly, the .input-wrapper styles could be refactored to make use of the border styles, applying the border on the bottom instead of the helper/error text applying a border top:
This would allow the default implementation to apply the border style/color when the helper/error text is used, but developers could optionally override and apply the border at any time through the --border-width, --border-style and --border-color CSS variables.
I am going to move this request into a labeled feature request.
I am keep coming to this issue but it is not solving my problem. Since Ionic v7 you removed slot="error" which was option to display error in input. Now you put errorText which looks good at first glance. But when you go deeper you can see that it completely breaks existing logic. So there is no way to use this with list because it makes double line. So all the documentation is, put inputs in a list. But now with this new errorText official statement is don't use it in a list. And explanation is:
If you need to provide more context on a input, consider using an ion-note underneath the ion-list.
So I would have 10 inputs in a list and then at the en of the list I will put wall of text for each input what is wrong with entered data? Or I should make a list for each input separately? It totally breaks validation messages for inputs in a list. Or I am missing something essential.
On top of it all select doesn't even have errorText or helperText. All my forms are broken, probably only solution is to go back to v6. And in v8 nothing was done about this topic.
Reacted by Paco Pérez Pineda, Scott and Galen Howlett
Is there any intention to support this? Right now the documentation shows most inputs inside an ion-item element, which breaks the errorText functionality. In my opinion, input validation is a requirement for inputs, so the input has been broken for 2 major releases. The documentation doesn't demonstrate a valid way to add realistic input scenarios.
The only workaround right now seems to be use lines="none" on all ion-item elements or use ion-input elements without any list. In addition, you have to stub in errorText="void" or some other valid string to all inputs that aren't required just to get matching user interface.
Is there any plans to get form functionality working or at least document input usage in a way that reflects real world scenarios?
Reacted by Paco Pérez Pineda, Jonathan Christian, Jamie Holding, Stefan Trauth, Adrien Jacquard, Murat Çorlu, Dustin, Guy Simmons and Emb1ter
This is still a big frustration for developers to handle error messages well in Ionic. Hopefully we'll have a built-in solution to this. But I wanted to just share my workaround anyway.
I add an ion-note element with "error-message" class next to the ion-list item where I want to show an error message:
<ion-listinset><ion-item-group><ion-item><ion-inputlabel="Default From Address" placeholder="hello"><ion-noteslot="end">{{ '@' }}example.com</ion-note></ion-input></ion-item></ion-item-group></ion-list><ion-notecolor="danger" class="list-note error-message">Please enter a valid email handle</ion-note><ion-notecolor="medium" class="list-note">This is the default sender address for your emails.</ion-note>
And in my global.scss file, I defined this style to show error state when an input is changed:
I found two separate issues related to supporting text inside ion-item.
1. Configuring errorText renders the bottom container even when there is no visible error
The current condition is based only on whether helperText or errorText is configured:
consthasHintText=!!helperText||!!errorText;
As a result, configuring errorText renders the bottom container before the control has both the ion-invalid and ion-touched classes.
The error text itself is correctly hidden, but the empty bottom container remains. This causes its border or padding to be applied even when there is no visible error.
The rendering condition should instead reflect the supporting text that is visible in the current validation state:
2. A parent cannot reliably detect whether a Shadow DOM form control is displaying supporting text
A parent can detect the ion-invalid and ion-touched classes on the host. However, those classes do not indicate whether errorText is configured or whether supporting text is actually being displayed.
This distinction matters when a third-party theme needs to adjust the surrounding ion-item, for example by removing the item border when the form control displays its own border and supporting text.
For ion-input and ion-textarea, which use scoped encapsulation, the theme can inspect the rendered content:
The equivalent approach is not possible for ion-select, ion-checkbox, or ion-toggle because their supporting text is inside Shadow DOM.
CSS parts allow styling internal elements, but they do not allow inspecting their content or selecting a parent ion-item. Attribute selectors are also unreliable when helperText or errorText is assigned dynamically as a JavaScript property.
Fixing the first issue would remove the empty bottom container. The remaining requirement is a reliable way for parent elements and third-party themes to determine whether a Shadow DOM form control is currently displaying supporting text.
If these directions are acceptable, I would be happy to submit a PR with tests.
Activity
sean-perkins commentedon Apr 19, 2023
Hello @Wasenshi123 thanks for this feature request.
Can you perhaps take a screenshot from your example of which behavior you are referring to for the underline form control?
In your original desired UI you are using floating labels, but in the modern syntax you are using fixed labels instead. I forked your example to make them consistent: https://stackblitz.com/edit/3we1ad-a1b8sd?file=index.html
Outside of the small visual adjustments between legacy and modern to align with the Material design spec, I don't currently see an issue with the underline between the displays.
Wasenshi123 commentedon Apr 20, 2023
I mean to have the ability to set this on the form control
As I demonstrated, I tried to add it manually with css on the new syntax one, but that's not quite the exact feeling because it underline the whole thing. So I think the built-in feature for this would be nice.
Wasenshi123 commentedon Apr 20, 2023
@sean-perkins I see now what is your point.
Please see this screen shot, my desired structure has the behavior to change label placement based on screen size. So at wider screen, the difference is noticeable:
My example is also updated to dynamically change label placement now.
sean-perkins commentedon Apr 21, 2023
Thank you for the extra detail + screenshots! I understand the differences now 👍
The underline border always being visible could be accomplished if Ionic exposed shadow parts for the native wrapper on each control (or CSS variables for border, since not all controls use shadow dom).
The underline width is a much larger task.
For
ion-input, the input highlight would need to be conditionally rendered either at the host level (to fill the entire width) or within the.native-wrapperwhen only wanting to display the highlight under the control. The.native-wrapperwould also need:position: relativeto contain the element positioning.Here is an example concept with manually modifying the DOM and adjusting styling:
Kapture.2023-04-21.at.14.12.17.mp4
ion-selectisn't as straight forward. The control does not fill the entire container space. I need to do additional investigation on our decision behind these styles, as I don't see the same thing against: https://material-components.github.io/material-components-web-catalog/#/component/select.A mock API could look like:
It would support two options
fullandcontrol, defaulting tofull.I'll discuss with the team and see if there are alternatives that I may be missing or any questions around the feature's feasibility.
sean-perkins commentedon Apr 24, 2023
Thinking through the border aspect specifically, we could do something similar to:
The helper/error text styling could be refactored to something similar to this, when active:
Lastly, the
.input-wrapperstyles could be refactored to make use of the border styles, applying the border on the bottom instead of the helper/error text applying a border top:This would allow the default implementation to apply the border style/color when the helper/error text is used, but developers could optionally override and apply the border at any time through the
--border-width,--border-styleand--border-colorCSS variables.I am going to move this request into a labeled feature request.
Majstr commentedon May 13, 2024
I am keep coming to this issue but it is not solving my problem. Since Ionic v7 you removed slot="error" which was option to display error in input. Now you put
errorTextwhich looks good at first glance. But when you go deeper you can see that it completely breaks existing logic. So there is no way to use this with list because it makes double line. So all the documentation is, put inputs in a list. But now with this newerrorTextofficial statement is don't use it in a list. And explanation is:So I would have 10 inputs in a list and then at the en of the list I will put wall of text for each input what is wrong with entered data? Or I should make a list for each input separately? It totally breaks validation messages for inputs in a list. Or I am missing something essential.
On top of it all select doesn't even have
errorTextorhelperText. All my forms are broken, probably only solution is to go back to v6. And in v8 nothing was done about this topic.howlettga commentedon Aug 15, 2024
Is there any intention to support this? Right now the documentation shows most inputs inside an
ion-itemelement, which breaks theerrorTextfunctionality. In my opinion, input validation is a requirement for inputs, so the input has been broken for 2 major releases. The documentation doesn't demonstrate a valid way to add realistic input scenarios.The only workaround right now seems to be use
lines="none"on allion-itemelements or useion-inputelements without any list. In addition, you have to stub inerrorText="void"or some other valid string to all inputs that aren't required just to get matching user interface.Is there any plans to get form functionality working or at least document input usage in a way that reflects real world scenarios?
muratcorlu commentedon Apr 1, 2026
This is still a big frustration for developers to handle error messages well in Ionic. Hopefully we'll have a built-in solution to this. But I wanted to just share my workaround anyway.
I add an ion-note element with "error-message" class next to the ion-list item where I want to show an error message:
And in my global.scss file, I defined this style to show error state when an input is changed:
This results something like this in error state:
You may need to play with coloring and make some additions if you have different items in your ion-item elements. (I use iOS 26 Theme here by @rdlabo)
rdlabo commentedon Aug 28, 2026
I found two separate issues related to supporting text inside
ion-item.1. Configuring
errorTextrenders the bottom container even when there is no visible errorThe current condition is based only on whether
helperTextorerrorTextis configured:As a result, configuring
errorTextrenders the bottom container before the control has both theion-invalidandion-touchedclasses.The error text itself is correctly hidden, but the empty bottom container remains. This causes its border or padding to be applied even when there is no visible error.
The rendering condition should instead reflect the supporting text that is visible in the current validation state:
For controls with a counter, the bottom container should continue to render when the counter is enabled:
2. A parent cannot reliably detect whether a Shadow DOM form control is displaying supporting text
A parent can detect the
ion-invalidandion-touchedclasses on the host. However, those classes do not indicate whethererrorTextis configured or whether supporting text is actually being displayed.This distinction matters when a third-party theme needs to adjust the surrounding
ion-item, for example by removing the item border when the form control displays its own border and supporting text.For
ion-inputandion-textarea, which use scoped encapsulation, the theme can inspect the rendered content:The equivalent approach is not possible for
ion-select,ion-checkbox, orion-togglebecause their supporting text is inside Shadow DOM.CSS parts allow styling internal elements, but they do not allow inspecting their content or selecting a parent
ion-item. Attribute selectors are also unreliable whenhelperTextorerrorTextis assigned dynamically as a JavaScript property.Fixing the first issue would remove the empty bottom container. The remaining requirement is a reliable way for parent elements and third-party themes to determine whether a Shadow DOM form control is currently displaying supporting text.
If these directions are acceptable, I would be happy to submit a PR with tests.