How do I disable/remove ion-ripple effect in ion-button Ioinic 4?

偶尔善良 提交于 2019-12-06 13:40:28

I think it's only included with Android so you can set mode="ios" on the button to avoid that effect.

Yeah so I just checked the source code and it is only used with mode="md" (which is Android / Material Design):

    <TagType
      {...attrs}
      class="button-native"
      disabled={disabled}
      onFocus={this.onFocus}
      onBlur={this.onBlur}
    >
      <span class="button-inner">
        <slot name="icon-only"></slot>
        <slot name="start"></slot>
        <slot></slot>
        <slot name="end"></slot>
      </span>
      {mode === 'md' && <ion-ripple-effect type={this.rippleType}></ion-ripple-effect>}
    </TagType>

That is the only way to do it using the button itself, the rippleType only offers bounded or unbounded, not a way to disable it.

I'm not sure if the ion-ripple-effect can be hidden with css because of the web components encapsulation used in Ionic 4.

--ripple-color CSS variable could be used to turn off the ripple effect.

 <ion-button class="no-ripple">
   <ion-icon slot="icon-only" name="trash"></ion-icon>
 </ion-button>

For example, we could set --ripple-color: transparent on the button, to effectively disable the effect.

.no-ripple {
  --ripple-color: transparent;
}

Refer https://github.com/ionic-team/ionic/issues/19648

In current version on Ionic 4, this is working example:

<ion-button class="submit-btn">...</ion-button>

.submit-btn {
    --background: transparent;
    --background-hover: transparent !important;
}

https://ionicframework.com/docs/api/button#css-custom-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!