UNPKG

3.54 kBMarkdownView Raw
1<!--docs:
2title: "Line Ripple"
3layout: detail
4section: components
5excerpt: "The line ripple is used to highlight user-specified input above it."
6path: /catalog/input-controls/line-ripple/
7-->
8
9# Line Ripple
10
11The line ripple is used to highlight user-specified input above it. When a line ripple is active, the line’s color and thickness changes.
12
13## Design & API Documentation
14
15<ul class="icon-list">
16 <li class="icon-list-item icon-list-item--spec">
17 <a href="https://material.io/go/design-text-fields#text-fields-layout">Material Design guidelines: Text Fields Layout</a>
18 </li>
19 <li class="icon-list-item icon-list-item--spec">
20 <a href="https://material-components.github.io/material-components-web-catalog/#/component/text-field">Demo with Line Ripple on Text Field</a>
21 </li>
22</ul>
23
24## Installation
25
26```
27npm install @material/line-ripple
28```
29
30## Basic Usage
31
32### HTML Structure
33
34```html
35<span class="mdc-line-ripple"></span>
36```
37
38### Styles
39
40```scss
41@use "@material/line-ripple/mdc-line-ripple";
42```
43
44### JavaScript Instantiation
45
46```js
47import {MDCLineRipple} from '@material/line-ripple';
48
49const lineRipple = new MDCLineRipple(document.querySelector('.mdc-line-ripple'));
50```
51
52## Style Customization
53
54### CSS Classes
55
56CSS Class | Description
57--- | ---
58`mdc-line-ripple` | Mandatory.
59`mdc-line-ripple--active` | Styles the line ripple as an active line ripple.
60`mdc-line-ripple--deactivating` | Styles the line ripple as a deactivating line ripple.
61
62### Sass Mixins
63
64Mixin | Description
65--- | ---
66`active-color($color)` | Customizes the color of the line ripple when active.
67`inactive-color($color)` | Customizes the color of the line ripple when inactive.
68
69## `MDCLineRipple` Properties and Methods
70
71Method Signature | Description
72--- | ---
73`activate() => void` | Proxies to the foundation's `activate()` method.
74`deactivate() => void` | Proxies to the foundation's `deactivate()` method.
75`setRippleCenter(xCoordinate: number) => void` | Proxies to the foundation's `setRippleCenter(xCoordinate: number)` method.
76
77## Usage Within Frameworks
78
79If you are using a JavaScript framework, such as React or Angular, you can create a Line Ripple for your framework. Depending on your needs, you can use the _Simple Approach: Wrapping MDC Web Vanilla Components_, or the _Advanced Approach: Using Foundations and Adapters_. Please follow the instructions [here](../../docs/integrating-into-frameworks.md).
80
81### `MDCLineRippleAdapter`
82
83Method Signature | Description
84--- | ---
85`addClass(className: string) => void` | Adds a class to the root element.
86`removeClass(className: string) => void` | Removes a class from the root element.
87`hasClass(className: string) => boolean` | Determines whether the root element has the given CSS class name.
88`setStyle(propertyName: string, value: string) => void` | Sets the style property with `propertyName` to `value` on the root element.
89`registerEventHandler(evtType: EventType, handler: EventListener) => void` | Registers an event listener on the root element for a given event.
90`deregisterEventHandler(evtType: EventType, handler: EventListener) => void` | Deregisters an event listener on the root element for a given event.
91
92### `MDCLineRippleFoundation`
93
94Method Signature | Description
95--- | ---
96`activate() => void` | Activates the line ripple.
97`deactivate() => void` | Deactivates the line ripple.
98`setRippleCenter(xCoordinate: number) => void` | Sets the center of the ripple to the `xCoordinate` given.
99`handleTransitionEnd(evt: Event) => void` | Handles a `transitionend` event.