Topic: How to disable ripple globally?
msantosdev
pro premium priority asked a week ago
Expected behavior Disabled ripple effect in MDBSideNav (im trying to disable it per component as im unsure if there's a global toggle for ripple)
Actual behavior After trying few different methods the ripple effect still remains in MDBSideNav. I tried adding this attributes: 1. disableRipple 2. data-mdb-ripple-init="false" 3. noRipple
Resources (screenshots, code snippets etc.)
Mateusz Lazaru
staff answered a week ago
Data attributes won't change the config in mdb react. Unfortunately, there is no way to disable the ripple effect in Sidenav-related components without modifying the source code.
You can either:
1- add a style to hide the ripple effect:
.your-sidenav .ripple-wave {
display: none !important;
}
2- create and use a custom component:
import clsx from 'clsx';
import React, { useState, useEffect } from 'react';
import type { SideNavLinkProps } from 'src/pro/navigation/SideNav/SideNavLink/types';
import { MDBIcon } from 'mdb-react-ui-kit';
const SidenavLinkNoRipple: React.FC<SideNavLinkProps> = React.forwardRef<HTMLAnchorElement, SideNavLinkProps>(
(
{
className,
icon,
iconClasses,
iconAngle = 180,
shouldBeExpanded,
children,
active,
tag: Tag = 'a',
color = 'primary',
...props
},
ref
) => {
const classes = clsx('sidenav-link', active && 'active', className);
const iconClass = clsx('rotate-icon', iconClasses);
const [angle, setAngle] = useState(shouldBeExpanded ? iconAngle : 0);
useEffect(() => {
setAngle(shouldBeExpanded ? iconAngle : 0);
}, [shouldBeExpanded, iconAngle]);
return (
<Tag
onKeyDown={(e: any) => {
if (e.key === 'Enter') {
e.currentTarget.click();
}
}}
tabIndex={1}
className={classes}
ref={ref}
{...props}
>
{children}
{icon && <MDBIcon icon={icon} style={{ transform: `rotate(${angle}deg)` }} className={iconClass} />}
</Tag>
);
}
);
export default SidenavLinkNoRipple;
msantosdev
pro premium priority answered a week ago
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: Yes
- Technology: MDB React
- MDB Version: MDB5 7.2.0
- Device: Laptop
- Browser: Chrome
- OS: Windows
- Provided sample code: No
- Provided link: No