Giter VIP home page Giter VIP logo

Comments (18)

adamwathan avatar adamwathan commented on May 19, 2024 52

Implemented in v1.2.0.

from tailwindcss.

adamwathan avatar adamwathan commented on May 19, 2024 28

Reopened!

from tailwindcss.

fourstacks avatar fourstacks commented on May 19, 2024 16

Was just thinking this would be great to have baked in too. Like you say - best to keep things simple and reserve any utility classes to basic transitions like button hover states etc.

I've never really figured out if there's any performance downside to using the 'all' keyword when setting up css transitions e.g. transition: all 200ms ease. If not then initially it might make sense to make this the default transition property. If you assume that as a default then the two parts of the declaration left are duration and easing.

As far as easing goes it would probably be nice to be able to specify an easing type but in practise that might be kinda cumbersome (it would certainly increase the number of potential class names). If the basic use case is for buttons and other interactive elements I'd be happy with something like 'ease' which generally looks pretty good.

If that just leaves us with timing then I guess having something like the opacity property in the config file would probably work e.g.:

transition: {
    '200': '200ms',
    '400': '400ms',
    '800': '800ms'
  },

To output a class like: .transition-400

Or maybe go with a keyword based approach more like shadows, something like

transition: {
    'fast': '200ms',
    'medium': '400ms',
    'slow': '800ms'
  },

Then: .transition-fast

These are just initial thoughts - I've probably (or more likely definitely!) not considered all the angles but I agree that it would be great to see something like this in the framework

from tailwindcss.

sebastiandedeyne avatar sebastiandedeyne commented on May 19, 2024 7

I'd like to see easing in the config, even if it's simply to provide your easing method of choice as default.

Both should have a default value too to allow a shorthand.

transitionDurations: {
  default: 200,
  'slow': 1000,
  // ...
},
transitionTimingFunctions: {
  default: 'linear',
  'ease-in-out': 'ease-in-out',
  // ...
},

Some example generated classes:

.transition (uses default for both)
.transition-200 (uses default timing function)
.transition-200-ease-in-out (everything specified)

Alternative idea: split easing and durations (.transition-200 .transition-ease-in-out).This we could also add transitionProperties config key so it isn't always all. Don't know how useful this is though.

Final thought: transitionTimingFunctions is the "correct" name for the setting. Might be better to use something friendlier.

from tailwindcss.

inxilpro avatar inxilpro commented on May 19, 2024 7

This is what I currently have in my custom utilities:

.trans {
    transition: all .25s;
}

.trans-bg {
    transition-property: background;
}

.trans-slow {
    transition-duration: .5s;
}

.trans-slower {
    transition-duration: .5s;
}

.trans-fast {
    transition-duration: .15s;
}

.trans-faster {
    transition-duration: .075s;
}

That way all of these work:

<div class="trans" /> <!-- Sane default -->
<div class="trans trans-bg" /> <!-- Background instead of all, must put .trans first -->
<div class="trans trans-fast" /> <!-- Transition quicker -->

I could also see doing something like:

*, :after, :before {
    transition-duration: .25s;
    transition-property: none;
}
.trans {
    transition-property: all;
}

And then keep the rest the same (kind of how borders are currently set by tailwind). I'm not 100% sure if that would break lots of 3rd-party CSS, though.

Finally, I think that the timing functions should be their own classes:

.trans-linear {
    transition-timing-function: linear;
}
/* etc */

from tailwindcss.

adamwathan avatar adamwathan commented on May 19, 2024 4

@louisjacksonrees planning to explore the API for this and the default values soon. In the mean time you can always install a plugin like this one:

https://github.com/benface/tailwindcss-transitions

Or simply write the classes yourself:

https://tailwindcss.com/docs/adding-new-utilities/

from tailwindcss.

bshoults avatar bshoults commented on May 19, 2024 3

I prefer the keyword based approach as well. As with the shadows, Tailwind makes some design decisions on how the shadow should look which is easy enough to customize. As with the shadow feature, it uses a default value as stated above. I think something like the below is just enough to be effective.

.transition (fast by default)
.transition-medium (or to be consistent, do we need to use 'md' like the shadow does?
.transition-slow

from tailwindcss.

MichaelDeBoey avatar MichaelDeBoey commented on May 19, 2024 2

I think the best way to implement this, is to do something similar like we did with the border utilities.

from tailwindcss.

niallobrien avatar niallobrien commented on May 19, 2024 1

I like the keyword based approach you suggested.

from tailwindcss.

aarondfrancis avatar aarondfrancis commented on May 19, 2024 1

I'm currently using the slow/md/fast convention in my project, but have also found it useful to have an instant with duration set to 0. (None would work too.)

from tailwindcss.

m1guelpf avatar m1guelpf commented on May 19, 2024

@niallobrien Why did you close this?

from tailwindcss.

niallobrien avatar niallobrien commented on May 19, 2024

That's strange...I didn't. 4 hours ago would've been 7am my time, just as I was getting up for work...
@adamwathan Should we reopen this or take it to the new discussion area I saw you mention on Twitter?
Thanks.

from tailwindcss.

kbond avatar kbond commented on May 19, 2024

I'd reopen as it is a feature request.

from tailwindcss.

perkola avatar perkola commented on May 19, 2024

What is the current process on this feature? Would it also be possible to add transition timings following the same convention as i.e. the border styles; border-solid, border-dashed but transition-ease, transision-linear instead?

Edit: referring to the transitionTimingFunctions mentioned by @sebastiandedeyne.

from tailwindcss.

rightaway avatar rightaway commented on May 19, 2024

@inxilpro Are those custom utilities just in a css file or is there a way to set them in tailwind.js and have them be generated?

from tailwindcss.

inxilpro avatar inxilpro commented on May 19, 2024

@rightaway Take a look at my tailwind plugin — they can be fully configured if you use the plugin, or else you can just copy-and-paste the above if you just want a quick-and-dirty solution.

from tailwindcss.

Vidhya-Dilip avatar Vidhya-Dilip commented on May 19, 2024

We can add common utilities which are not present in tailwind by default, in plugins section of tailwind.config.js as 'addUtilities' function.
https://tailwindcss.com/docs/plugins

from tailwindcss.

louisjrdev avatar louisjrdev commented on May 19, 2024

Will this be merged into the core project this is kind of make or break to be honest?

from tailwindcss.

Related Issues (20)

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.