GithubHelp home page GithubHelp logo

bogacode / tailwindcss-ripple Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jamessessford/tailwindcss-ripple

0.0 1.0 0.0 1.55 MB

Ripple effect (materialize) for Tailwindcss

License: MIT License

JavaScript 100.00%

tailwindcss-ripple's Introduction

Ripple Plugin for Tailwind CSS

Inspired By

An excellent Codepen by Ben Szabo.

Installation

npm install tailwindcss-ripple

Usage

// tailwind.config.js
{
  theme: {
    ripple: theme => ({
        colors: theme('colors')
    }),
  },
  plugins: [
    require('tailwindcss-ripple')()
  ],
}

The default configuration generates the following ripple effect for each color in your theme :

...

.ripple-bg-gray-300 {
    background-color: #e2e8f0;
    background-position: center;
    transition: background 0.8s;
}

.ripple-bg-gray-300:hover {
    background: #a5b7d0 radial-gradient(circle, transparent 1%, #a5b7d0 1%) center/15000%;
}

.ripple-bg-gray-300:active {
    background-color: #e2e8f0;
    background-size: 100%;
    transition: background 0s;
}

...

Which you can then use in your HTML like this:

<button class="ripple-bg-gray-300">
    Hover me for a lighter background, click me for a ripple effect
</button>

The Ripple Effect

By default, the color generated for the ripple effect is a 20% darken of the supplied color. This can be customised by passing in a parameter in your tailwind config file.

// tailwind.config.js
{
  theme: {
    ripple: theme => ({
        colors: theme('colors'),
        darken: 0.1
    }),
  },
  plugins: [
    require('tailwindcss-ripple')()
  ],
}

You can also change the transition properties on the created class and it's active state

// tailwind.config.js
{
  theme: {
    ripple: theme => ({
        colors: theme('colors'),
        modifierTransition: 'background 0.2s',
        activeTransition: 'background 0.1s'
    }),
  },
  plugins: [
    require('tailwindcss-ripple')()
  ],
}

Would generate the following CSS

...

.ripple-bg-gray-300 {
    background-color: #e2e8f0;
    background-position: center;
    transition: background 0.2s;
}

.ripple-bg-gray-300:hover {
    background: #a5b7d0 radial-gradient(circle, transparent 1%, #a5b7d0 1%) center/15000%;
}

.ripple-bg-gray-300:active {
    background-color: #e2e8f0;
    background-size: 100%;
    transition: background 0.1s;
}

...

Build Status Coverage Status

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.