question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feat: extend ion-toast css shadow parts

See original GitHub issue

Prequisites

Describe the Feature Request

Extend ion-toast CSS shadow parts(https://ionicframework.com/docs/api/toast#css-shadow-parts) with content so that html element with class “toast-content” can be stylized.

Describe the Use Case

.toast-content element would be stylizeable, which is not not an option. In our case, it helps with making message part overflowing text displayed as ellipsis, but I could easily believe other users will find more uses to it.

Describe Preferred Solution

No response

Describe Alternatives

No response

Related Code

async showToastError(opts: ToastOptions): Promise<HTMLIonToastElement> {
   opts.duration = 3000;

   opts.color = 'danger';

   this.addErrorDetailsButton(opts);

   const toast = await this.toastController.create(opts);

   await toast.present();

   return toast;
 }
private async addErrorDetailsButton(opts: ToastOptions): Promise<void> {
    opts.cssClass = 'snap-error-toast';

    const errorDetailsButton: ToastButton = {
      side: 'end',
      text: 'More details',
      handler: () => this.presentModal(opts.message)
    };
    opts.buttons = [errorDetailsButton];
  }

in scss file we have this part:

.snap-error-toast::part(message) {
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

in order for ellipsis to work as we need it to, min-width: 0 should be added to html element that currently contains ‘toast-content’ class.

Additional Information

Screenshots with results of the code above:

What is currently the case: image

What we want to achieve: image

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
vladimirSnapAddycommented, Aug 25, 2021

Sure! I will do it as soon as possible.

0reactions
ionitron-bot[bot]commented, Sep 15, 2021

Thanks for the issue! This issue is being closed due to the lack of a reply. 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.

Thank you for using Ionic!

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS Shadow Parts - Ionic Framework
CSS Shadow Parts allow developers to style CSS properties on elements inside of a shadow tree. Read to learn more about customizing Ionic...
Read more >
Styling in the Shadow DOM With CSS Shadow Parts
Styles can be applied using HTML element selectors like <button> and <div> . These styles could break a component. Shadow DOM is the...
Read more >
Apply differents styles for buttons of ion-toast Component and ...
I´m creating an application with Ionic and i´m using the toast Component with two buttons. I have to create a different style for...
Read more >
Increase Font Size Of Ion-Input Text - ADocLib
In this tutorial you will learn how to create HTML Text input box Set Height and Width [edit] BTW the examples are larger...
Read more >
Customize your Ionic Framework app with CSS Shadow Parts!
Shadow parts make it easier to theme and customize Ionic Framework components. They replace the need for a large amount of CSS variables...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found