Skip to content

background gradient duration #6614

Answered by NovusOpus
CFarhad asked this question in Help
Discussion options

You must be logged in to vote

This is not posible without a work around. Since currently gradients don't support transitions. This is not just for Tailwind CSS but also for CSS in general.

One way to archive this, is to double the background size of the element and transition the background position.

By extending backgroundSize and backgroundPosition in our tailwind.config. Like this:

module.exports = {
  theme: {
    extend: {
      backgroundSize: {
        'size-200': '200% 200%',
      },
      backgroundPosition: {
        'pos-0': '0% 0%',
        'pos-100': '100% 100%',
      },
    },
  },
  plugins: [],
}

And the button should be like this:

<button class="p-10 text-white rounded duration-500 bg-gradient-to-r …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@newbelaravel
Comment options

Answer selected by CFarhad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants