Responsive Framer Motion with Tailwind CSS

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 พ.ย. 2024

ความคิดเห็น • 93

  • @Diego_Cabrera
    @Diego_Cabrera ปีที่แล้ว +20

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

  • @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

  • @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!

  • @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.

  • @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!

  • @levyjr6857
    @levyjr6857 2 หลายเดือนก่อน

    Really really useful. Thank you for making this video

  • @Iammrunkown
    @Iammrunkown ปีที่แล้ว

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

  • @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!

  • @AndreasStraub
    @AndreasStraub ปีที่แล้ว +1

    Amazing 🤩. Thx for sharing

  • @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 :)

  • @chrismixlist
    @chrismixlist ปีที่แล้ว +1

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

  • @MmmMmmGood17
    @MmmMmmGood17 ปีที่แล้ว

    We’ll done, great demo/explanation!

  • @austincodes
    @austincodes ปีที่แล้ว +1

    Very practical and easy to follow. Well done 😊

  • @LabhamJain
    @LabhamJain ปีที่แล้ว

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

  • @ajgubi19
    @ajgubi19 ปีที่แล้ว

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

  • @ygordimas
    @ygordimas 10 หลายเดือนก่อน

    Worked beautifully, thank you!

  • @usamariaz3765
    @usamariaz3765 ปีที่แล้ว

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

  • @prashlovessamosa
    @prashlovessamosa ปีที่แล้ว

    Thanks for making this.

  • @x1expert1x
    @x1expert1x ปีที่แล้ว

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

  • @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

  • @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!

  • @ivodelev9794
    @ivodelev9794 ปีที่แล้ว

    This is amazing!

  • @Weagle1337
    @Weagle1337 ปีที่แล้ว

    I missed you Sam! I love your videos

  • @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

  • @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!

  • @aymenbachiri-yh2hd
    @aymenbachiri-yh2hd 3 หลายเดือนก่อน

    Thank you so much

  • @ojknation
    @ojknation ปีที่แล้ว

    Great video as always, learnt a lot from this video

  • @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.

  • @grouby3850
    @grouby3850 ปีที่แล้ว

    I love your videos.

  • @MahmoudGamal-sx3bj
    @MahmoudGamal-sx3bj 4 หลายเดือนก่อน

    just wow 🔥👍

  • @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

  • @realdevdiv
    @realdevdiv ปีที่แล้ว

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

  • @alainkaiser2697
    @alainkaiser2697 ปีที่แล้ว

    nice!!!

  • @rodrigotrigosso
    @rodrigotrigosso 5 หลายเดือนก่อน

    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.

  • @craigcaski
    @craigcaski ปีที่แล้ว +6

    How does this man not have more subs?

    • @gradientO
      @gradientO ปีที่แล้ว +2

      Such a goldmine of content

    • @jasmeetkaur20112
      @jasmeetkaur20112 11 หลายเดือนก่อน +1

      ​@@gradientO0:40 0:40

  • @TheGaoNan
    @TheGaoNan ปีที่แล้ว

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

  • @greendsnow
    @greendsnow ปีที่แล้ว

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

  • @angeromeogouebi2948
    @angeromeogouebi2948 ปีที่แล้ว

    Can you make a video about react native & tailwind ?

  • @blankspace6342
    @blankspace6342 4 หลายเดือนก่อน

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

  • @johnbrandess
    @johnbrandess ปีที่แล้ว

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

  • @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?

  • @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).

  • @kasper369
    @kasper369 ปีที่แล้ว

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

  • @rudzkygen
    @rudzkygen ปีที่แล้ว

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

    • @samselikoff
      @samselikoff  ปีที่แล้ว

      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!

  • @hl7297
    @hl7297 ปีที่แล้ว

    nice

  • @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)

  • @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!

  • @incacube
    @incacube ปีที่แล้ว +1

    man i learnt too much about tailwind here

  • @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  ปีที่แล้ว

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

  • @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!

  • @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

  • @trejohnson7677
    @trejohnson7677 2 หลายเดือนก่อน

    tailwind is OP

  • @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.

  • @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.