Svelte Material Ripple is a library for adding ripple effects to interactive elements.
Installation
Usage
Import the Ripple component and place it in a position: relative container.
By default, the ripple is attached to the parent element, but some elements like <input> don't accept children. You can attach the ripple to a reference element by passing the id of that element to the for prop.
You can also just pass the element directly to the for prop.
Checkbox Example
Theming
Ripples can be customized globally using CSS variables.
Token
Description
Default
--ripple-hover-color
The color of the ripple when hovered
currentColor
--ripple-hover-opacity
The opacity of the ripple when hovered
0.08
--ripple-pressed-color
The color of the ripple when pressed
currentColor
--ripple-pressed-opacity
The opacity of the ripple when pressed
0.12
You can also pass a theme object to the component, which will override the global styles.