Rate these docs

Vue waves effect

Vue Bootstrap waves effect

Vue Bootstrap waves effect is an impression of circular overlay movement, triggered by clicking the object, flowing from the center of the click. By default, waves are added and active on elements such as buttons and navbar's links, on some they wait for waves prop, as is the case with masks. Ultimately, it is failrly easy to add them onto any custom component -- see how you may attach it in the API section.


Example


          <template>
            <section class="preview">
              <mdb-row>
                <mdb-col md="3">
                    <mdb-btn color="primary">
                      click me
                    </mdb-btn>
                </mdb-col>
                <mdb-col md="5">
                  <mdb-view src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/6-col/img%20(54).jpg" hover>
                    <mdb-mask overlay="white-slight" waves/>
                  </mdb-view>
                </mdb-col>
              </mdb-row>
            </section>
          </template>
        

          <script>
            import { mdbRow, mdbCol, mdbBtn, mdbView, mdbMask } from 'mdbvue';
            export default {
              name: "WavesExample",
              componens: {
                mdbRow,
                mdbVol,
                mdbBtn,
                mdbView,
                mdbMask
              }
            }
          </script>
        

          <style>
            section.preview {
              border: 1px solid #e0e0e0;
              padding: 15px;
            }
          </style>
        

Install MDB CLI
It's the fastest way to create and host MDB projects
Free Download

Vue Waves Effect - API

In this section you will find advanced information Waves Effect, including how the Waves Effect mixin works, how to use it in your custom components and where the effect is enabled by default in the library.


Basics

Wave or 'ripple' effect is widely used in the Material Design standard - it is elegant, indicates user interacion and adds additional depth to surfaces.

Generally, it takes mouse/tap coordinates returned by a click event and renders a CSS-based effect in the pin-pointed location on .ripple-parent parent element.

In mdbvue, wave effect is implemented as a mixin, meaning that most of the heavy lifting (methods, calculation, props declaration) is done for us and encapsulated. Below we present necessary steps to use the effect in a custom component.


Customization

Let's be completely honest - wave effect is awesome. It is very easy to use the mixin for custom components, too! This is why here we present steps you need to take to apply it whenever you want.

Step 1: import the mixin and list in the adequate property of exported object


            import { waves } from 'mdbvue';
    
            export default {
                name: 'MyComponent',
                ...,
                mixins: [waves]
            }
            

Step 2: designate the .ripple-parent

Use the CSS class to declare the ancestor, on which the wave-effect will be taking place.


                <div class="my-component ripple-parent">
                    {{message}}
                </div>
              
            

            import { waves } from 'mdbvue';
    
            export default {
                name: 'MyComponent',
                props: {
                    message: {
                        type: String,
                        default: 'yay!'
                    }
                },
                mixins: [waves]
            }
            

                .my-component {
                    width: 100px;
                    height: 100px;
                    background-color: red;
                    color: white
                }
            

Step 3: Handle the click event

If wave-effect triggering part of your component does not emit a click event natively, add an event listener with wave function callback like so: @click="wave". The function is available for components that are using the waves mixin.


                <div class="my-component ripple-parent" @click="wave">
                    {{message}}
                </div>
              
            

            import { waves } from 'mdbvue';
    
            export default {
                name: 'MyComponent',
                props: {
                    message: {
                        type: String,
                        default: 'yay!'
                    }
                },
                mixins: [waves]
            }
            

                .my-component {
                    width: 100px;
                    height: 100px;
                    background-color: red;
                    color: white
                }
            

Step 4 (optional): darkWaves

In case there is a bright-ish background for waves effect, consider using its dark variant by the darkWaves prop. All components with the mixin present on them are ready to receive it.


                <MyComponent message="keep it dark" darkWaves/>
            

Components using waves

Wave effect is implemented in a number of components. In some of them, like mdbBtn buttons, they are enabled by default. Some, say, mdbMask overlay mask, require initialization through the waves prop. Here is a table of you can find the mixin used:

Component Name Implementation
mdbBtn by default
mdbCardImage requires waves prop
mdbDropdownToggle by default
mdbInput requires waves prop
mdbMask requires waves prop
mdbNavbarBrand requires waves prop
mdbNavItem by default
mdbPageItem by default
mdbPageNav by default
mdbChip by default, darkWaves too
mdbChipInput requires waves prop, darkWaves by default
mdbSideNav enabled by default in logo
mdbSideNavCat by default
mdbSideNavItem by default
mdbTabs by default