Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
@material/react-ripple
Advanced tools
✨ Are you a part of the Material Design web community? Help us improve by filling out this 10 minute survey. ✨
A React version of an MDC Ripple.
npm install @material/react-ripple
with Sass:
import '@material/react-ripple/index.scss';
with CSS:
import '@material/react-ripple/dist/ripple.css';
To wrap a component with the ripple HOC, please follow this example:
import withRipple from '@material/react-ripple';
const Icon = (props) => {
const {
children,
className = '',
// You must call `initRipple` from the root element's ref. This attaches the ripple
// to the element.
initRipple,
// include `unbounded` to remove warnings when passing `otherProps` to the
// root element.
unbounded,
...otherProps
} = props;
// any classes needed on your component needs to be merged with
// `className` passed from `props`.
const classes = `ripple-icon-component ${className}`;
return (
<div
className={classes}
ref={initRipple}
{...otherProps}>
{children}
</div>
);
};
const RippleIcon = withRipple(Icon);
Wrap your Icon component with the HOC withRipple
, which returns a component
with a ripple capable surface.
You may want to apply the visual treatment (CSS classes and styles) for a ripple surface on one element, but have its activation rely on a different element. For example, putting a ripple on a <div>
which will be activated by focusing on a child <input>
element. We call the visual element the "ripple surface" and the activating element the "ripple activator".
The initRipple
callback prop can take in an extra activator
argument for the case where the ripple activator differs from the ripple surface. If the activator
argument is not provided, the ripple surface will also serve as the ripple activator.
import withRipple from '@material/react-ripple';
const MyInput = (props) => {
const {
rippleActivator,
...otherProps
} = props;
return (
<input ref={rippleActivator} {...otherProps} />
);
}
class MyComponent extends React.Component {
rippleActivator = React.createRef();
init = (el) => {
this.props.initRipple(el /* surface */, this.rippleActivator.current /* activator */);
}
render() {
const {
className,
initRipple,
unbounded,
...otherProps
} = this.props;
return (
<div
className={`my-component ${className}`}
ref={this.init}
{...otherProps}>
<MyInput rippleActivator={this.rippleActivator} />
</div>
);
}
};
const MyRippledComponent = withRipple(MyComponent);
Prop Name | Type | Description |
---|---|---|
unbounded | boolean | Ripple is unbounded if true. |
disabled | n/a | Disables ripple if true. |
style | object | Inline styles of root element. |
className | string | Classes to appear on className attribute of root element. |
Sass mixins may be available to customize various aspects of the components. Please refer to the MDC Web repository for more information on what mixins are available, and how to use them.
0.6.2 (2018-11-07)
<a name="0.6.0"></a>
FAQs
Material Components React Ripple
The npm package @material/react-ripple receives a total of 12,615 weekly downloads. As such, @material/react-ripple popularity was classified as popular.
We found that @material/react-ripple demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 13 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.