search results:

    • Standard
    • React
    Pricing Learn Community
    • + D
    • Light
    • Dark
    • System
    logo TW Elements
    • Getting started
      • Quick start
      • Tutorials
      • Design system
      • Local installation
      • Optimization
      • Dark mode
      • Theming
      • Changelog
      • Migrating to v2
      • Internationalization guide
      • Class customization
      • Icons Integration
    • CommercialNew
      • Pricing
      • License
      • Installation
      • Git & repository
      • Premium Support
    • Integrations
      • Angular
      • ASP.NET
      • Django
      • Express
      • Laravel
      • Next
      • Nuxt
      • Qwik
      • React
      • Remix
      • Solid
      • Svelte
      • SvelteKit
      • Vue
    • Content & styles
      • Animations
      • Animations Extended
      • Colors
      • Dividers
      • Figures
      • Headings
      • Hover effects
      • Icons
      • Images
      • Mask
      • Shadows
      • Typography
    • Navigation
      • Breadcrumbs
      • Footer
      • Headers
      • Mega menu
      • Navbar
      • Offcanvas
      • Pagination
      • Pills
      • Scrollspy
      • Sidenav
      • Tabs
    • Components
      • Accordion
      • Alerts
      • Avatar
      • Badges
      • Button group
      • Buttons
      • Cards
      • Carousel
      • Chips
      • Collapse
      • Dropdown
      • Gallery
      • Jumbotron
      • Lightbox
      • Link
      • List group
      • Modal
      • Notifications
      • Paragraphs
      • Placeholders
      • Popconfirm
      • Popover
      • Progress
      • Rating
      • Scroll back to top button
      • Social buttons
      • Spinners
      • Stepper
      • Testimonials
      • Timeline
      • Toast
      • Tooltip
      • Video
      • Video carousel
    • Forms
      • Autocomplete
      • Checkbox
      • Datepicker
      • Datetimepicker
      • File input
      • Form templates
      • Input Group
      • Inputs
      • Login form
      • Multi range slider
      • Radio
      • Range
      • Registration form
      • Search
      • Select
      • Switch
      • Textarea
      • Timepicker
      • Validation
    • Data
      • Charts
      • Charts advanced
      • Datatables
      • Tables
    • Methods
      • Clipboard
      • Infinite scroll
      • Lazy loading
      • Loading management
      • Ripple
      • Scrollbar
      • Smooth scroll
      • Sticky
      • Touch
    • Design Blocks
      • Admin Charts
      • Admin Complex
      • Admin Forms
      • Admin Maps
      • Admin Navigation
      • Admin tables
      • Banners
      • Contact
      • Content
      • CTA
      • FAQ
      • Features
      • Headers
      • Hero / Intro sections
      • Logo clouds
      • Mega menu
      • News
      • Newsletter
      • Pricing
      • Projects
      • Stats
      • Stats admin
      • Team
      • Testimonials
    • Tools
      • Button generator
      • Card generator
      • Flexbox generator
      • Footer generator
      • Form builder
      • Grid generator
      • Icon generator
      • Instagram Filters generator
      • Logo generator
      • Table generator
      • Typography generator
    • Coming Soon
      • Angular
      • Builder
      • Templates
      • Vue
    • Resources
      • Playground
      • YouTube Channel
      • Private FB Group
      • Newsletter
      • UI Design course New
      • UI / UX tips
    • Overview
    • API

    Tailwind Ripple method

    Tailwind CSS Ripple

    Use responsive ripple effect with helper examples for button ripple on click, waives effect on images, custom ripple color and duration. Easy to customize.

    Required ES init: Ripple *
    * UMD autoinits are enabled by default. This means that you don't need to initialize the component manually. However if you are using TW Elements ES format then you should pass the required components to the initTWE method.

    Basic example

    The ripple effect is a way to let the user know that there has been a click interaction. You can easily add a ripple effect to the buttons component.

    • HTML
    • javascript
            
                
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="light"
            class="inline-block rounded bg-primary px-7 pb-2.5 pt-3 text-sm font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Button
          </button>
          
            
        
            
                
          // Initialization for ES Users
          import {
            Ripple,
            initTWE,
          } from "tw-elements";
          
          initTWE({ Ripple });
          
            
        

    Hey there 👋 we're excited about TW elements and want to see it grow! If you enjoy it, help the project grow by sharing it with your peers. Every share counts, thank you!

    Image

    Using data-twe-ripple-init attribute you can also easily add the ripple effect to images.

    • HTML
    • javascript
            
                
          <a href="#!" data-twe-ripple-init>
            <img
              src="https://tecdn.b-cdn.net/img/new/standard/city/043.jpg"
              class="h-auto max-w-sm"
              alt="" />
          </a>
          
            
        
            
                
          // Initialization for ES Users
          import {
            Ripple,
            initTWE,
          } from "tw-elements";
          
          initTWE({ Ripple });
          
            
        

    Colors

    You can easily manipulate the color of the ripple effect to suit your needs. By using data-twe-ripple-color attribute you can change its color.

    • HTML
    • javascript
            
                
          <!-- Primary ripple color -->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="primary"
            class="inline-block rounded bg-neutral-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-neutral-600 shadow-light-3 transition duration-150 ease-in-out hover:bg-neutral-200 hover:shadow-light-2 focus:bg-neutral-200 focus:shadow-light-2 focus:outline-none focus:ring-0 active:bg-neutral-200 active:shadow-light-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Primary
          </button>
    
          <!-- Secondary ripple color -->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="secondary"
            class="inline-block rounded bg-neutral-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-neutral-600 shadow-light-3 transition duration-150 ease-in-out hover:bg-neutral-200 hover:shadow-light-2 focus:bg-neutral-200 focus:shadow-light-2 focus:outline-none focus:ring-0 active:bg-neutral-200 active:shadow-light-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Secondary
          </button>
    
          <!-- Success ripple color -->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="success"
            class="inline-block rounded bg-neutral-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-neutral-600 shadow-light-3 transition duration-150 ease-in-out hover:bg-neutral-200 hover:shadow-light-2 focus:bg-neutral-200 focus:shadow-light-2 focus:outline-none focus:ring-0 active:bg-neutral-200 active:shadow-light-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Success
          </button>
    
          <!-- Danger ripple color -->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="danger"
            class="inline-block rounded bg-neutral-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-neutral-600 shadow-light-3 transition duration-150 ease-in-out hover:bg-neutral-200 hover:shadow-light-2 focus:bg-neutral-200 focus:shadow-light-2 focus:outline-none focus:ring-0 active:bg-neutral-200 active:shadow-light-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Danger
          </button>
    
          <!-- Info ripple color -->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="info"
            class="inline-block rounded bg-neutral-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-neutral-600 shadow-light-3 transition duration-150 ease-in-out hover:bg-neutral-200 hover:shadow-light-2 focus:bg-neutral-200 focus:shadow-light-2 focus:outline-none focus:ring-0 active:bg-neutral-200 active:shadow-light-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Info
          </button>
    
          <!-- Light ripple color -->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="light"
            class="inline-block rounded bg-neutral-800 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-neutral-50 shadow-dark-3 transition duration-150 ease-in-out hover:bg-neutral-700 hover:shadow-dark-2 focus:bg-neutral-700 focus:shadow-dark-2 focus:outline-none focus:ring-0 active:bg-neutral-900 active:shadow-dark-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Light
          </button>
    
          <!-- Dark ripple color -->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="dark"
            class="inline-block rounded bg-neutral-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-neutral-600 shadow-light-3 transition duration-150 ease-in-out hover:bg-neutral-200 hover:shadow-light-2 focus:bg-neutral-200 focus:shadow-light-2 focus:outline-none focus:ring-0 active:bg-neutral-200 active:shadow-light-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Dark
          </button>
          
            
        
            
                
          // Initialization for ES Users
          import {
            Ripple,
            initTWE,
          } from "tw-elements";
          
          initTWE({ Ripple });
          
            
        

    • HTML
    • javascript
            
                
          <!-- Red ripple color button -->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="red"
            class="inline-block rounded bg-neutral-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-neutral-600 shadow-light-3 transition duration-150 ease-in-out hover:bg-neutral-200 hover:shadow-light-2 focus:bg-neutral-200 focus:shadow-light-2 focus:outline-none focus:ring-0 active:bg-neutral-200 active:shadow-light-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Red
          </button>
    
          <!-- Green ripple color button -->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="green"
            class="inline-block rounded bg-neutral-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-neutral-600 shadow-light-3 transition duration-150 ease-in-out hover:bg-neutral-200 hover:shadow-light-2 focus:bg-neutral-200 focus:shadow-light-2 focus:outline-none focus:ring-0 active:bg-neutral-200 active:shadow-light-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Green
          </button>
    
          <!-- Primary ripple color button -->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="primary"
            class="inline-block rounded bg-neutral-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-neutral-600 shadow-light-3 transition duration-150 ease-in-out hover:bg-neutral-200 hover:shadow-light-2 focus:bg-neutral-200 focus:shadow-light-2 focus:outline-none focus:ring-0 active:bg-neutral-200 active:shadow-light-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            primary
          </button>
    
          <!-- Yellow ripple color button -->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="yellow"
            class="inline-block rounded bg-neutral-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-neutral-600 shadow-light-3 transition duration-150 ease-in-out hover:bg-neutral-200 hover:shadow-light-2 focus:bg-neutral-200 focus:shadow-light-2 focus:outline-none focus:ring-0 active:bg-neutral-200 active:shadow-light-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Yellow
          </button>
    
          <!-- Orange ripple color button -->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="orange"
            class="inline-block rounded bg-neutral-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-neutral-600 shadow-light-3 transition duration-150 ease-in-out hover:bg-neutral-200 hover:shadow-light-2 focus:bg-neutral-200 focus:shadow-light-2 focus:outline-none focus:ring-0 active:bg-neutral-200 active:shadow-light-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Orange
          </button>
    
          <!-- Purple ripple color button -->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="purple"
            class="inline-block rounded bg-neutral-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-neutral-600 shadow-light-3 transition duration-150 ease-in-out hover:bg-neutral-200 hover:shadow-light-2 focus:bg-neutral-200 focus:shadow-light-2 focus:outline-none focus:ring-0 active:bg-neutral-200 active:shadow-light-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Purple
          </button>
    
          <!-- Aqua ripple color button -->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="aqua"
            class="inline-block rounded bg-neutral-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-neutral-600 shadow-light-3 transition duration-150 ease-in-out hover:bg-neutral-200 hover:shadow-light-2 focus:bg-neutral-200 focus:shadow-light-2 focus:outline-none focus:ring-0 active:bg-neutral-200 active:shadow-light-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Aqua
          </button>
          
            
        
            
                
          // Initialization for ES Users
          import {
            Ripple,
            initTWE,
          } from "tw-elements";
          
          initTWE({ Ripple });
          
            
        

    • HTML
    • javascript
            
                
          <!-- Ripple color: #c953d6 -->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="#c953d6"
            class="inline-block rounded bg-neutral-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-neutral-600 shadow-light-3 transition duration-150 ease-in-out hover:bg-neutral-200 hover:shadow-light-2 focus:bg-neutral-200 focus:shadow-light-2 focus:outline-none focus:ring-0 active:bg-neutral-200 active:shadow-light-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            #c953d6
          </button>
    
          <!-- Ripple color: #44c6e3 -->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="#44c6e3"
            class="inline-block rounded bg-neutral-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-neutral-600 shadow-light-3 transition duration-150 ease-in-out hover:bg-neutral-200 hover:shadow-light-2 focus:bg-neutral-200 focus:shadow-light-2 focus:outline-none focus:ring-0 active:bg-neutral-200 active:shadow-light-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            #44c6e3
          </button>
    
          <!-- Ripple color: #fcc834 -->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="#fcc834"
            class="inline-block rounded bg-neutral-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-neutral-600 shadow-light-3 transition duration-150 ease-in-out hover:bg-neutral-200 hover:shadow-light-2 focus:bg-neutral-200 focus:shadow-light-2 focus:outline-none focus:ring-0 active:bg-neutral-200 active:shadow-light-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            #fcc834
          </button>
    
          <!-- Ripple color: #386f06 -->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="#386f06"
            class="inline-block rounded bg-neutral-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-neutral-600 shadow-light-3 transition duration-150 ease-in-out hover:bg-neutral-200 hover:shadow-light-2 focus:bg-neutral-200 focus:shadow-light-2 focus:outline-none focus:ring-0 active:bg-neutral-200 active:shadow-light-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            #386f06
          </button>
    
          <!-- Ripple color: #c1303a -->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="#c1303a"
            class="inline-block rounded bg-neutral-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-neutral-600 shadow-light-3 transition duration-150 ease-in-out hover:bg-neutral-200 hover:shadow-light-2 focus:bg-neutral-200 focus:shadow-light-2 focus:outline-none focus:ring-0 active:bg-neutral-200 active:shadow-light-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            #c1303a
          </button>
    
          <!-- Ripple color: #a57c3e -->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="#a57c3e"
            class="inline-block rounded bg-neutral-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-neutral-600 shadow-light-3 transition duration-150 ease-in-out hover:bg-neutral-200 hover:shadow-light-2 focus:bg-neutral-200 focus:shadow-light-2 focus:outline-none focus:ring-0 active:bg-neutral-200 active:shadow-light-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            #a57c3e
          </button>
    
          <!-- Ripple color: #192ced -->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="#192ced"
            class="inline-block rounded bg-neutral-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-neutral-600 shadow-light-3 transition duration-150 ease-in-out hover:bg-neutral-200 hover:shadow-light-2 focus:bg-neutral-200 focus:shadow-light-2 focus:outline-none focus:ring-0 active:bg-neutral-200 active:shadow-light-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            #192ced
          </button>
          
            
        
            
                
          // Initialization for ES Users
          import {
            Ripple,
            initTWE,
          } from "tw-elements";
          
          initTWE({ Ripple });
          
            
        

    Duration

    If you don't want the ripple effect to move on the button too quickly, use data-twe-ripple-duration attribute and modify the duration of the ripple.

    • HTML
    • javascript
            
                
          <!--Ripple duration: default-->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="light"
            class="inline-block rounded bg-primary px-7 pb-2.5 pt-3 text-sm font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Default (500ms)
          </button>
    
          <!--Ripple duration: 1s-->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="light"
            data-twe-ripple-duration="1000ms"
            class="inline-block rounded bg-primary px-7 pb-2.5 pt-3 text-sm font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Duration 1s
          </button>
    
          <!--Ripple duration: 3s-->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="light"
            data-twe-ripple-duration="3s"
            class="inline-block rounded bg-primary px-7 pb-2.5 pt-3 text-sm font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Duration 3s
          </button>
    
          <!--Ripple duration: 5s-->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="light"
            data-twe-ripple-duration="5s"
            class="inline-block rounded bg-primary px-7 pb-2.5 pt-3 text-sm font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Duration 5s
          </button>
    
          <!--Ripple duration: 10s-->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="light"
            data-twe-ripple-duration="10s"
            class="inline-block rounded bg-primary px-7 pb-2.5 pt-3 text-sm font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Duration 10s
          </button>
          
            
        
            
                
          // Initialization for ES Users
          import {
            Ripple,
            initTWE,
          } from "tw-elements";
          
          initTWE({ Ripple });
          
            
        

    Centered

    If you add the attribute data-twe-ripple-centered="true", the ripple will always start at the center of the element, not at the affected location.

    • HTML
    • javascript
            
                
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="light"
            data-twe-ripple-centered="true"
            class="inline-block rounded bg-primary px-7 pb-2.5 pt-3 text-sm font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Button
          </button>
          
            
        
            
                
          // Initialization for ES Users
          import {
            Ripple,
            initTWE,
          } from "tw-elements";
          
          initTWE({ Ripple });
          
            
        

    Unbound

    If you use the data-twe-ripple-unbound="true" attribute, the ripple will not be bound to the element and will extend beyond its boundaries.

    • HTML
    • javascript
            
                
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-unbound="true"
            class="inline-block rounded bg-primary px-7 pb-2.5 pt-3 text-sm font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Button
          </button>
          
            
        
            
                
          // Initialization for ES Users
          import {
            Ripple,
            initTWE,
          } from "tw-elements";
          
          initTWE({ Ripple });
          
            
        

    Radius

    The data-twe-ripple-radius attribute can be used to modify the ripple radius. The numeric value is expressed in pixels, for example: data-twe-ripple-radius="10"

    • HTML
    • javascript
            
                
          <!--Ripple radius: default-->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="light"
            class="inline-block rounded bg-primary px-7 pb-2.5 pt-3 text-sm font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            Default
          </button>
    
          <!--Ripple radius: 10-->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="light"
            data-twe-ripple-radius="10"
            class="inline-block rounded bg-primary px-7 pb-2.5 pt-3 text-sm font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            10
          </button>
    
          <!--Ripple radius: 25-->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="light"
            data-twe-ripple-radius="25"
            class="inline-block rounded bg-primary px-7 pb-2.5 pt-3 text-sm font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            25
          </button>
    
          <!--Ripple radius: 50-->
          <button
            type="button"
            data-twe-ripple-init
            data-twe-ripple-color="light"
            data-twe-ripple-radius="50"
            class="inline-block rounded bg-primary px-7 pb-2.5 pt-3 text-sm font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
            50
          </button>
          
            
        
            
                
          // Initialization for ES Users
          import {
            Ripple,
            initTWE,
          } from "tw-elements";
          
          initTWE({ Ripple });
          
            
        

    Related resources

    Tutorials:

    colors focus active and others dark mode fullscreen background image masks hsla colors buttons ripple effect

    Extended Docs:

    animations colors hover effects images mask headers pills tabs accordion avatar button group buttons carousel collapse dropdown gallery jumbotron list group video video carousel background image color picker colors

    Generators and builders:

    Form drag & drop Typography SVG icon Instagram Filters button card table flexbox logo grid footer

    Design System (Figma):

    introduction de emphasize with no mercy user experience do not start with the roof project personality design system principles tips and tricks
    • Basic example
    • Image
    • Colors
    • Duration
    • Centered
    • Unbound
    • Radius
    • Related resources

    Tailwind Ripple method - API


    Import

    Importing components depends on how your application works. If you intend to use the TW elements ES format, you must first import the component and then initialize it with the initTWE method. If you are going to use the UMD format, just import the tw-elements package.

    • javascript
    • umd
            
                
            import { Ripple, initTWE } from "tw-elements";
            initTWE({ Ripple });
            
            
        
            
                
            import "tw-elements";
            
            
        

    Usage

    Via data attributes

    Add the data-twe-ripple-init attribute to the clickable element to apply the ripple effect. For ES format, you must first import and call the initTWE method.

    • HTML
            
                
            <div class="flex justify-center space-x-2">
              <button
                type="button"
                data-twe-ripple-init
                data-twe-ripple-color="light"
                class="inline-block rounded bg-primary px-7 pb-2.5 pt-3 text-sm font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
                Button
              </button>
            </div>
            
            
        

    Via JavaScript

    • javascript
    • umd
            
                
            document.querySelectorAll('[data-twe-ripple-init]').forEach((cardRipple) => {
              new Ripple(cardRipple, {
                color: 'light'
              })
            });
            
            
        
            
                
            document.querySelectorAll('[data-twe-ripple-init]').forEach((cardRipple) => {
              new twe.Ripple(cardRipple, {
                color: 'light'
              })
            });
            
            
        

    Options

    Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-twe-, as in data-twe-ripple-centered="".

    Name Type Default Description
    rippleCentered Boolean false Centers the position of ripple.
    rippleColor String "" Changes color of ripple.
    rippleDuration String '500ms' Sets duration of animation
    rippleRadius Number 0 Sets radius value.
    rippleUnbound Boolean false Sets whether the effect should go beyond the wrapper's boundaries.

    Classes

    Custom classes can be passed via data attributes or JavaScript. For data attributes, append the class name to data-twe-class, as in data-twe-class-ripple="".

    Name Default Description
    ripple relative overflow-hidden inline-block align-bottom Sets styles connected with ripple effect position.
    rippleWave rounded-[50%] opacity-50 pointer-events-none absolute touch-none scale-0 transition-[transform,_opacity] ease-[cubic-bezier(0,0,0.15,1),_cubic-bezier(0,0,0.15,1)] z-[999] Sets visual styles of the ripple effect.
    unbound overflow-visible Sets overflow styles of unbound ripple effect.

    Methods

    Method Description Example
    dispose Manually dispose of component. myRipple.dispose()
    getInstance Static method which allows you to get the alert instance associated to a DOM element. Ripple.getInstance()
    getOrCreateInstance Static method which returns an alert instance associated to a DOM element or create a new one in case it wasn't initialized. Ripple.getOrCreateInstance()
    • javascript
    • umd
            
                
            const myRippleEl = document.getElementById('myRipple')
            const myRipple = new Ripple(myRippleEl)
            myRipple.dispose();
            
            
        
            
                
            const myRippleEl = document.getElementById('myRipple')
            const myRipple = new twe.Ripple(myRippleEl)
            myRipple.dispose();
            
            
        
    • Import
    • Usage
    • Options
    • Classes
    • Methods
    Get useful tips & free resources directly to your inbox along with exclusive subscriber-only content.
    Join our mailing list now
    © 2024 Copyright: MDBootstrap.com

    Access restricted

    To view this section you must have an active PRO account

    Log in to your account or purchase an TWE subscription if you don't have one.

    Buy TWE PRO