-
Notifications
You must be signed in to change notification settings - Fork 13.5k
feat: Wrap label text in ion-select, ion-toggle and other input components #27621
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
Comments
Thanks for the report. With the exception of one component, you can already get the label text to wrap:
These components support passing in custom HTML as the label. This means you can use the Example: <!-- the 300px width is just to emphasize the overflow. You don't need to use 300px for this to work -->
<ion-toggle style="width: 300px">
<div class="ion-text-wrap">This is my really really really really really long text</div>
</ion-toggle>
Currently this is difficult to do. However, we have implemented both #27112 and #26838 which will make this much easier to do. These features will be in the next minor release of Ionic. Example usage once this feature ships: <!-- the 300px width is just to emphasize the overflow. You don't need to use 300px for this to work -->
<!-- You can also use the shadow part -->
<ion-select style="width: 300px">
<div slot="label" class="ion-text-wrap">This is my really really really really really long text</div>
</ion-select>
You can set the text wrapping by using CSS since these components do not use the shadow DOM: <ion-input
class="my-input"
style="width: 300px"
label="This is my really really really really really long text"
></ion-input> .my-input .label-text {
white-space: normal;
} However, I recognize this is an inconsistent developer experience. We plan to implement #27061 which will let you pass custom HTML as the label. Once this feature ships the behavior will be consistent. Example usage once this feature ships: <!-- the 300px width is just to emphasize the overflow. You don't need to use 300px for this to work -->
<!-- Note: The previous approach still works too -->
<ion-input style="width: 300px">
<div slot="label" class="ion-text-wrap">This is my really really really really really long text</div>
</ion-input> I am going to close this in favor of #27061 since that is the outstanding feature required to make this behavior consistent. Let me know if you have questions. |
Also we've gotten this question a couple times so I think it makes sense to add some playgrounds on our docs that show how to do this. |
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. |
Prerequisites
Describe the Feature Request
With the v7 syntax for setting an ion-select label via the label property, or an ion-toggle label via its inner text, it appears impossible to make long label text wrap instead of being truncated.
The fix using the previous syntax would be:
Describe the Use Case
Long label text in select, toggle and other input elements sometimes needs to wrap instead of being truncated.
Describe Preferred Solution
Potential solutions would include:
Describe Alternatives
No response
Related Code
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: