简体   繁体   中英

Ionic 4 - How to change font-size of button inside a Toast

I'm building an app with Ionic 4 + React.

Using a toast component when the user delete an element to show the message "deleted successfully", but adding a button inside to give the possibility to undo the action.

I need to change the font-size of that button, but almost all the toast DOM is inside a shadow-root :

在此处输入图像描述

Reading articles like this , I understand that everything inside shadow-root it can't be styled by css selectors and must be styled using CSS4 Ionic variables.

But I can't find a css variable to change de font-size of the button, this is what Ionic does (not with variables):

在此处输入图像描述

Read some people that said that could work with a custom class, I already tried that but without any luck:

Toast component:

<IonToast
  cssClass="e7-toast"
  isOpen={showToastDeshacer}
  color="dark"
  onDidDismiss={() => setShowToastDeshacer(false)}
  message="Deleted successfully"
  position="bottom"
  buttons={[
    {
      text: 'Undo',
      role: 'cancel',
      handler: () => {
        console.log('Undo clicked');
      }
    }
  ]}
/>

CSS:

.e7-toast .toast-button-inner {
  font-size: 44px!important;
}

Anyone with more experience in Ionic 4 knows a way to change the font-size of that button?

Thanks!

you can change the shadow dom by using ::part . There is the article for your reference: https://css-tricks.com/styling-in-the-shadow-dom-with-css-shadow-parts/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM