Responsive Framer Motion with Tailwind CSS

Поділитися
Вставка
  • Опубліковано 26 сер 2024

КОМЕНТАРІ • 94

  • @Diego_Cabrera
    @Diego_Cabrera Рік тому +18

    This is a game changer, thank you! Definitely going to implement this in my future videos!

  • @DEV_XO
    @DEV_XO Рік тому +7

    This is a game changer!
    Keep up with the Radix / Framer / Tailwind CSS stuff. We all love it!
    Love your content, thank you!

    • @samselikoff
      @samselikoff  Рік тому

      Appreciate the kind words brother!

  • @wfl-junior
    @wfl-junior Рік тому +3

    I've been using tailwind for a while now, and I never knew about that trick for css properties xD
    Thank you so much, this is awesome

    • @wfl-junior
      @wfl-junior Рік тому

      Also didn't know about the inverted breakpoints, that will be useful

  • @nexxai
    @nexxai Рік тому +3

    This is great, man. Such a simple (in retrospect) way to accomplish what would otherwise be a really clunky task. Thanks for sharing!

  • @mertdr
    @mertdr Рік тому

    Man your channel is definitely gold, one of top ones. Everytime I watch a video of yours, I learn something interesting and save it to my list to give it a try as soon as I have a chance.

  • @chrismixlist
    @chrismixlist Рік тому +1

    You always create extremely valuable content. Glad I found your channel

  • @AndreasStraub
    @AndreasStraub Рік тому +1

    Amazing 🤩. Thx for sharing

  • @austincodes
    @austincodes Рік тому +1

    Very practical and easy to follow. Well done 😊

  • @usamariaz3765
    @usamariaz3765 Рік тому +1

    Can you please also bring some content on the 3d model website's using three.js . Like model change its positions while scrolling using framer motion

  • @LabhamJain
    @LabhamJain Рік тому

    I love this channel man, even though I have quiet solid experience in react still I learn something new in every video!!

  • @Benjamin-Chavez
    @Benjamin-Chavez Рік тому

    This is exaclty what i needed today. I have been creating multiple components with different animations and using the hidden class. I can finally take that hacky code out of my codebase. Thank you!

  • @officiallydheeraj
    @officiallydheeraj Рік тому

    I also love to use CSS for functionality as much as I can. Absolutely loved it!

  • @LearnFrontendNow
    @LearnFrontendNow Рік тому

    Awesome job Sam, love the calm presentation style in your work. This is a fantastic Framer motion tutorial as well, thoroughly enjoyed it :)

  • @ajgubi19
    @ajgubi19 Рік тому

    This video is helpful on many levels. Thank you so much! Subscription was totally worth it.

  • @MmmMmmGood17
    @MmmMmmGood17 Рік тому

    We’ll done, great demo/explanation!

  • @ygordimas
    @ygordimas 7 місяців тому

    Worked beautifully, thank you!

  • @aymenbachiri-yh2hd
    @aymenbachiri-yh2hd 19 днів тому

    Thank you so much

  • @igrb
    @igrb Рік тому

    OMG THIS IS AMAZING, thank you!
    I've been using CSS variables to throw stuff between js and CSS BUT didn't realize I could do them from tailwind. Time to get rid of all those style props

  • @sujalvanjare06
    @sujalvanjare06 5 місяців тому

    This is exactly what I was looking for, Thanks man. Could you please change the title of the video because I was only able to find solution for this problem because somebody mentioned your video on their blog.

    • @samselikoff
      @samselikoff  5 місяців тому

      Yeah! Curious what your google searches were for?

    • @sujalvanjare06
      @sujalvanjare06 5 місяців тому

      something like , responsive animation with framer motion without any hooks or with tailwind CSS@@samselikoff

  • @x1expert1x
    @x1expert1x 10 місяців тому

    This is so awesome, I was wondering today how come no one has done this

  • @craigcaski
    @craigcaski Рік тому +6

    How does this man not have more subs?

  • @prashlovessamosa
    @prashlovessamosa Рік тому

    Thanks for making this.

  • @MahmoudGamal-sx3bj
    @MahmoudGamal-sx3bj Місяць тому

    just wow 🔥👍

  • @usamariaz3765
    @usamariaz3765 Рік тому

    Love that 🎉 thank you for providing amazing content ...

  • @codex1758
    @codex1758 Рік тому

    Hi Sam! Amazing video as always! Could you please make a video on how to use Framer Motion to create loading screens between page transitions with NextJS or React Router? That would be amazing!

  • @realdevdiv
    @realdevdiv 11 місяців тому

    Wow i learnt a lot from this video, You deserve a sub from me😁

  • @ivodelev9794
    @ivodelev9794 Рік тому

    This is amazing!

  • @moondevonyt
    @moondevonyt Рік тому

    mad respect for diving deep into integrating framer motion with tailwind css, that's some next-level stuff
    but here's a hot take: using css variables with framer motion, while creative, might be an overkill for some
    feels like it's adding another layer of complexity
    but hey, can't deny the elegance of the final outcome
    top-notch work!

  • @nihil_um
    @nihil_um Рік тому +6

    hi, Sam.
    Have you been able to make the Framer Motion exit transition between pages work in a Next.js 13 project with the App folder structure?.
    Regards.

    • @grouby3850
      @grouby3850 Рік тому +1

      It would be great. I have a similar problem. I can do the exit page animations in next 12 because of , but I can't implement the same in next 13.

    • @samselikoff
      @samselikoff  Рік тому +1

      Not yet but will definitely be sharing when I get it working!

    • @nihil_um
      @nihil_um Рік тому

      @@samselikoff 👍

  • @ThugLifeModafocah
    @ThugLifeModafocah Рік тому

    That's so awesome. Thank you for this. It would be awesome to see how you would do the carousel motions of material design 3 using framer motion. It would be really cool. But anyways, thank you very much for all awesome content you provides.

  • @ojknation
    @ojknation Рік тому

    Great video as always, learnt a lot from this video

  • @Weagle1337
    @Weagle1337 Рік тому

    I missed you Sam! I love your videos

  • @alainkaiser2697
    @alainkaiser2697 Рік тому

    nice!!!

  • @gradientO
    @gradientO Рік тому

    Sam it would be really helpful if we can see your keystrokes (for vim keybindigs) just put them in some corner in small size

  • @angeromeogouebi2948
    @angeromeogouebi2948 Рік тому

    Can you make a video about react native & tailwind ?

  • @grouby3850
    @grouby3850 Рік тому

    I love your videos.

  • @greendsnow
    @greendsnow Рік тому

    6:30 Get ready to be shocked! Who knew this?!

  • @rodrigotrigosso
    @rodrigotrigosso 2 місяці тому

    Great tutorial, but it only works for properties of type string since "var(--..." is a string. How would you make it work for properties of type number, like duration and delay.

  • @hl7297
    @hl7297 Рік тому

    nice

  • @blankspace6342
    @blankspace6342 Місяць тому

    When i use arbitrary property on animate prop on x. It resets to its original position

  • @TheGaoNan
    @TheGaoNan Рік тому

    Hi Sam, what kind of microphone do you use?
    Thanks!

  • @johnbrandess
    @johnbrandess 11 місяців тому

    This doesn't work with the useTransform hook, tho. Right?
    At least it doesn't seem to work for me

  • @kasper369
    @kasper369 Рік тому

    Can you create a video on framer motion exit animation in nextjs 13 ?

  • @roguesherlock
    @roguesherlock Рік тому

    this was really good sam, always learn something new from you!
    I also absolutely love this stack (radix, motion, tailwind), All such a high quality libraries with great DX!
    P.S. what's the colorscheme you're using? I thought it was dracula but it's not

    • @samselikoff
      @samselikoff  Рік тому +1

      It's Dracula with a few tweaks so the base colors match Tailwind's slate-900: gist.github.com/samselikoff/cf0fcde8e6d7d118359096ee53191af0

    • @roguesherlock
      @roguesherlock Рік тому

      sweet. Thanks for sharing! @@samselikoff

  • @joshua4262
    @joshua4262 Рік тому

    can this be achieved with the framer motion hooks?

  • @Yeyppe
    @Yeyppe Рік тому

    Hey sam, I’m watching your tutorial from last 6 months, and i just wanna make a request to you that can you please make a video for frontend developers to create a backend just for showing data using appwrite/supabase/firebase, it’s a request, I’m good at designing good at component creation but no data for backend is bothering me

    • @samselikoff
      @samselikoff  9 місяців тому

      Hey! What are you wanting the backend for? A side project, an app for work?

  • @incacube
    @incacube Рік тому +1

    man i learnt too much about tailwind here

  • @waqasabi
    @waqasabi Рік тому +1

    Hi, I see that TailwindUI uses HeadlessUI but you are using RadixUI - Is there a difference between the two or are they just both libraries trying to do the same thing? It also looks like HeadlessUI was designed with TailwindCSS in mind, so naturally I'm curious about the decision about using RadixUI over HeadlessUI
    Edit: Oh I spoke too soon, looks you are using HeadlessUI in this video:)
    But would still be curious if there was a difference between two (as you use Radix in some of your videos, and HeadlessUI in this video) - Maybe an interesting idea for a video

    • @samselikoff
      @samselikoff  Рік тому +1

      Yep this vid uses Headless since it's from a Tailwind UI example, but they're both great libs! These days I'm liking Radix, it has more components + exposes some more events than Headless does. Really can't go wrong with Headless, Radix or Aria these days!

  • @es20x
    @es20x Рік тому

    Great. But how SSR works with motion component?

    • @samselikoff
      @samselikoff  Рік тому +1

      If you specify `initial` then Framer Motion will use that as the starting value if a motion component is SSR.
      Nice thing about using CSS Properties is that if the starting value is derived from there, it is robust to media breakpoints (since CSS knows the screen size on first paint).

  • @rudzkygen
    @rudzkygen 10 місяців тому

    Hey, what extension or setting you use to allow new line in classNames? 😅

    • @samselikoff
      @samselikoff  10 місяців тому

      Hm no extension, just newline inside of it!

  • @real-oppenheimer
    @real-oppenheimer Рік тому

    I assume the CSS variables from Tailwind's arbitrary syntax have to have a unique name, right? As they're part of the global CSS file, using the same name in different places would clash, right?

    • @samselikoff
      @samselikoff  Рік тому +1

      Nope - the generated utility class is part of the global file, but the utility only defines the variable on the element where it's used. Since CSS Variables are scoped (similar to CSS rules), they don't affect siblings or parents, and can be overwritten by children 👍

    • @real-oppenheimer
      @real-oppenheimer Рік тому

      @@samselikoff That's really cool! Thanks!

  • @federicottavio
    @federicottavio Рік тому

    Any way to use tailwind css colors with framer? For example creating a class like [--color-to:grey-400]. The only way i found so far is to expose all tailwind colors as css variables

    • @samselikoff
      @samselikoff  Рік тому +1

      You can actually, using the theme() helper! Try
      [--color-to:theme(colors.gray.400)]

    • @federicottavio
      @federicottavio Рік тому

      @@samselikoff it works!!! 🥹🥹 thank you!!

    • @samselikoff
      @samselikoff  Рік тому

      @@federicottavio Amazing! You got it!

  • @demarco6967
    @demarco6967 Рік тому

    great video!
    how do you hide the browser toolbar?

    • @samselikoff
      @samselikoff  Рік тому

      +Shift+F in Chrome when it's in Full Screen mode (green button in top-left of window). In Safari it's an option under the View menu (Always Show Toolbar in Full Screen)

  • @cinques
    @cinques Рік тому

    But these css variables are not scoped to component? And if you define same vars in another component - there will be conflict

    • @samselikoff
      @samselikoff  Рік тому

      Nope, they are scoped! CSS Variables are similar to rules in that they are scoped to a tree. So, they don't affect siblings or parents, and they can be overridden by children.

  • @pheisar
    @pheisar Рік тому

    I heard framer motion supports entry and exit animations. Sorry if its a dumb question, but why would one grab framer motion for this simple animation instead of using only css? Thanks

    • @EvertJunior
      @EvertJunior Рік тому +1

      With framer motion you get spring animations, which are physics based and intuitive. Instead of playing with weird cubic Bézier curves, you define values such as stiffness, damping, bounce. Also it makes animations cancelable, which means they change course if the state change in the middle of the transition. I would not install it just to animate a modal, but if you're already using it, it's nice to get consistent feeling animations through out the app.

    • @RegalWK
      @RegalWK Рік тому

      I think framer use GPU instead of CPU underneath to make calculation which is much faster than CSS which uses CPU but I might be wrong

    • @samselikoff
      @samselikoff  Рік тому +3

      Main reason is for the exit animations. In React, we conditionally render (mount/unmount) components in our JSX:
      {open && }
      When open is false, is umounted. It's not in the DOM, none of its effects are running, and its state is reset.
      If you want to animate that conditional , you can't do it with just CSS, and currently React has no first-class APIs for animating unmounting components either. This is where Framer Motion comes in. It lets you animate components while they're unmounting by wrapping the conditional in :
      {open && }
      If the Modal has a with an exit prop, Framer Motion will run that animation whenever it's unmounted. So, you get unmount animations while preserving everything about the React model.

    • @samselikoff
      @samselikoff  Рік тому +1

      @@RegalWK Framer Motion is animating CSS properties under the hood so whether an animation uses CPU or GPU is the same: it depends on which property is being animated. For example, browsers use GPU to animate the `transform` property (which is why Framer Motion uses it when animating values like `x` and `y` rather than the left and right CSS properties). So, both FM and CSS animations can be GPU or CPU accelerated.
      But Framer Motion does help nudge you to use the best property for a given situation.

    • @RegalWK
      @RegalWK Рік тому

      Thanks for explanation :) @@samselikoff

  • @mahadevovnl
    @mahadevovnl Рік тому

    Tailwind is such a FOTM cancer. A complete anti-pattern, technical debt from day 1, complete vendor lock-in (it's in every single HTML tag), a utility class bombardment, and going by all the job applications I've reviewed: TW is a predictor for very bad understanding of HTML and CSS.
    Learn CSS first, folks. When TW goes away (like they all do) you won't have a clue what's going on. Learn about cascading, learn about specificity, learn about paint/composite/layout, use SCSS for some nifty tools.
    TW is by far the worst tech I've seen in my long career as a web dev and front-end specialist.

  • @greendsnow
    @greendsnow Рік тому

    Come to think of it, this is another punishing complexity and half bakedness of React.
    With Svelte it's reusable, much performant because it's a CSS animation not JS, so much easier to write, and SSR safe as a cherry on the top!
    let innerWidth
    $: innerWidth < 768 ? mobile= true : mobile= false;
    function modalAnimation(node, { delay = 0, duration = 400 }) {
    const o = +getComputedStyle(node).opacity;
    if(mobile){
    return { delay, duration, css: (t) => `opacity: ${t * o}` };
    } else{ // do whatever you want for bigger screens}
    }

    • @samselikoff
      @samselikoff  Рік тому

      Hm that doesn't look easier to me... one of the benefits is being able to use the same screen size breakpoints as you're already using in Tailwind. Here you need to hard-code 768 (it's a magic number).
      Also I don't think this is SSR-safe, since window is not available on the server

  • @ryan_roga
    @ryan_roga Рік тому +1

    Eww. React. No.

    • @xrkuzd1569
      @xrkuzd1569 Рік тому +1

      As a newly Sveltekit man myself, I wholeheartedly agree with this sentiment!

    • @N8X4TE
      @N8X4TE Рік тому

      @@xrkuzd1569 sveltekit sucks man

    • @xrkuzd1569
      @xrkuzd1569 Рік тому +1

      @@N8X4TE Spoken like a man who hasn't actually tried it. React feels stupid once you switch and it's less performant too. Zero benefits other than legacy adoption rates. If you're starting a side project there is zero reason to use React over Sveltekit....zero.

    • @ryan_roga
      @ryan_roga Рік тому +1

      @@xrkuzd1569 Absolutely. I don't know who thought JSX was the answer but that person has no place making technical decisions of any significant importance. What a joke.

  • @tcortega
    @tcortega Рік тому

    i never really had an usecase for framer, well, nothing I couldn't do without tailwind itself. am i wrong or this is normal

    • @samselikoff
      @samselikoff  Рік тому

      Main benefit of Framer Motion here is the exit animations - can't do it with just CSS! FM also has more sophisticated animation curves like a spring, which also can't be replicated in pure CSS.